Skip to content

Commit 6369b9b

Browse files
committed
[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
1 parent 3d65dd1 commit 6369b9b

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
@@ -859,14 +859,25 @@ endmacro(add_llvm_executable name)
859859
#
860860
# If NO_MODULE is specified, when option LLVM_${name_upper}_LINK_INTO_TOOLS is set to OFF,
861861
# only an object library is built, and no module is built. This is specific to the Polly use case.
862+
#
863+
# The SUBPROJECT argument contains the LLVM project the plugin belongs
864+
# to. If set, the plugin will link statically by default it if the
865+
# project was enabled.
862866
function(add_llvm_pass_plugin name)
863867
cmake_parse_arguments(ARG
864-
"NO_MODULE" "" ""
868+
"NO_MODULE" "SUBPROJECT" ""
865869
${ARGN})
866870

867871
string(TOUPPER ${name} name_upper)
868872

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

871882
if(LLVM_${name_upper}_LINK_INTO_TOOLS)
872883
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)