Skip to content

Commit 576559e

Browse files
serge-sans-pailletstellar
authored andcommitted
Use components instead of libraries in Polly linkage step
As a side effect, this tests (and fix a bug) in the compiler extension handling of components. Differential Revision: https://reviews.llvm.org/D78358 (cherry picked from commit e849e7a)
1 parent 2f6b23d commit 576559e

File tree

2 files changed

+38
-39
lines changed

2 files changed

+38
-39
lines changed

llvm/cmake/modules/AddLLVM.cmake

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -868,6 +868,12 @@ function(add_llvm_pass_plugin name)
868868
endif()
869869
option(LLVM_${name_upper}_LINK_INTO_TOOLS "Statically link ${name} into tools (if available)" ${link_into_tools_default})
870870

871+
# If we statically link the plugin, don't use llvm dylib because we're going
872+
# to be part of it.
873+
if(LLVM_${name_upper}_LINK_INTO_TOOLS)
874+
list(APPEND ARG_UNPARSED_ARGUMENTS DISABLE_LLVM_LINK_LLVM_DYLIB)
875+
endif()
876+
871877
if(LLVM_${name_upper}_LINK_INTO_TOOLS)
872878
list(REMOVE_ITEM ARG_UNPARSED_ARGUMENTS BUILDTREE_ONLY)
873879
# process_llvm_pass_plugins takes care of the actual linking, just create an

polly/lib/CMakeLists.txt

Lines changed: 32 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,34 @@ if (MSVC_IDE OR XCODE)
2121
file(GLOB_RECURSE POLLY_HEADER_FILES "${POLLY_SOURCE_DIR}/include/polly/*.h")
2222
endif ()
2323

24+
set(POLLY_COMPONENTS
25+
Support
26+
Core
27+
ScalarOpts
28+
InstCombine
29+
TransformUtils
30+
Analysis
31+
ipo
32+
MC
33+
Passes
34+
Linker
35+
IRReader
36+
Analysis
37+
# The libraries below are required for darwin: http://PR26392
38+
BitReader
39+
MCParser
40+
Object
41+
ProfileData
42+
Target
43+
Vectorize
44+
)
45+
46+
# Polly-ACC requires the NVPTX backend to work. Ask LLVM about its libraries.
47+
if (GPU_CODEGEN)
48+
# This call emits an error if they NVPTX backend is not enable.
49+
list(APPEND POLLY_COMPONENTS NVPTX)
50+
endif ()
51+
2452
# Use an object-library to add the same files to multiple libs without requiring
2553
# the sources them to be recompiled for each of them.
2654
add_llvm_pass_plugin(Polly
@@ -71,6 +99,9 @@ add_llvm_pass_plugin(Polly
7199
Transform/RewriteByReferenceParameters.cpp
72100
Transform/ScopInliner.cpp
73101
${POLLY_HEADER_FILES}
102+
103+
LINK_COMPONENTS
104+
${POLLY_COMPONENTS}
74105
)
75106
set_target_properties(obj.Polly PROPERTIES FOLDER "Polly")
76107
set_target_properties(Polly PROPERTIES FOLDER "Polly")
@@ -99,45 +130,7 @@ if (GPU_CODEGEN)
99130
target_link_libraries(Polly PUBLIC PollyPPCG)
100131
endif ()
101132

102-
103-
# Polly-ACC requires the NVPTX backend to work. Ask LLVM about its libraries.
104-
set(nvptx_libs)
105-
if (GPU_CODEGEN)
106-
# This call emits an error if they NVPTX backend is not enable.
107-
llvm_map_components_to_libnames(nvptx_libs NVPTX)
108-
endif ()
109-
110-
if (LLVM_LINK_LLVM_DYLIB)
111-
# The shlib/dylib contains all the LLVM components
112-
# (including NVPTX is enabled) already. Adding them to target_link_libraries
113-
# would cause them being twice in the address space
114-
# (their LLVM*.a/so and their copies in libLLVM.so)
115-
# which results in errors when the two instances try to register the same
116-
# command-line switches.
117-
target_link_libraries(Polly PUBLIC LLVM)
118-
else ()
119-
target_link_libraries(Polly PUBLIC
120-
LLVMSupport
121-
LLVMCore
122-
LLVMScalarOpts
123-
LLVMInstCombine
124-
LLVMTransformUtils
125-
LLVMAnalysis
126-
LLVMipo
127-
LLVMMC
128-
LLVMPasses
129-
LLVMLinker
130-
LLVMIRReader
131-
${nvptx_libs}
132-
# The libraries below are required for darwin: http://PR26392
133-
LLVMBitReader
134-
LLVMMCParser
135-
LLVMObject
136-
LLVMProfileData
137-
LLVMTarget
138-
LLVMVectorize
139-
)
140-
133+
if (NOT LLVM_LINK_LLVM_DYLIB)
141134
# Polly-ACC requires the NVPTX target to be present in the executable it is linked to
142135
set_property(TARGET bugpoint APPEND PROPERTY LINK_LIBRARIES LLVMTarget)
143136
endif ()

0 commit comments

Comments
 (0)