Skip to content

Commit d7afdb5

Browse files
Meinersburzmodem
authored andcommitted
[CMake] Default to static linking for subprojects.
Pass plugins introduced in D61446 do not support dynamic linking on Windows, hence the option LLVM_${name_upper}_LINK_INTO_TOOLS can only work being set to "ON". Currently, it defaults to "OFF" such that such plugins are inoperable by default on Windows. Change the default for subprojects to follow LLVM_ENABLE_PROJECTS. Reviewed By: serge-sans-paille, MaskRay Differential Revision: https://reviews.llvm.org/D72372 (cherry picked from commit 6369b9b) This is for PR45001.
1 parent 5cfd30a commit d7afdb5

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

llvm/cmake/modules/AddLLVM.cmake

+13-2
Original file line numberDiff line numberDiff line change
@@ -854,14 +854,25 @@ endmacro(add_llvm_executable name)
854854
#
855855
# If NO_MODULE is specified, when option LLVM_${name_upper}_LINK_INTO_TOOLS is set to OFF,
856856
# only an object library is built, and no module is built. This is specific to the Polly use case.
857+
#
858+
# The SUBPROJECT argument contains the LLVM project the plugin belongs
859+
# to. If set, the plugin will link statically by default it if the
860+
# project was enabled.
857861
function(add_llvm_pass_plugin name)
858862
cmake_parse_arguments(ARG
859-
"NO_MODULE" "" ""
863+
"NO_MODULE" "SUBPROJECT" ""
860864
${ARGN})
861865

862866
string(TOUPPER ${name} name_upper)
863867

864-
option(LLVM_${name_upper}_LINK_INTO_TOOLS "Statically link ${name} into tools (if available)" OFF)
868+
# Enable the plugin by default if it was explicitly enabled by the user.
869+
# Note: If was set to "all", LLVM's CMakeLists.txt replaces it with a
870+
# list of all projects, counting as explicitly enabled.
871+
set(link_into_tools_default OFF)
872+
if (ARG_SUBPROJECT AND LLVM_TOOL_${name_upper}_BUILD)
873+
set(link_into_tools_default ON)
874+
endif()
875+
option(LLVM_${name_upper}_LINK_INTO_TOOLS "Statically link ${name} into tools (if available)" ${link_into_tools_default})
865876

866877
if(LLVM_${name_upper}_LINK_INTO_TOOLS)
867878
list(REMOVE_ITEM ARG_UNPARSED_ARGUMENTS BUILDTREE_ONLY)

polly/lib/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ endif ()
2525
# the sources them to be recompiled for each of them.
2626
add_llvm_pass_plugin(Polly
2727
NO_MODULE
28+
SUBPROJECT Polly
2829
Analysis/DependenceInfo.cpp
2930
Analysis/PolyhedralInfo.cpp
3031
Analysis/ScopDetection.cpp

0 commit comments

Comments
 (0)