[llvm] 2d6d476 - [Polly][CMake] Fix exports (#122123)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Jan 20 03:33:33 PST 2025
Author: Nikita Popov
Date: 2025-01-20T12:33:29+01:00
New Revision: 2d6d476ffbfc207aae2bf9f12be14483b31d100a
URL: https://github.com/llvm/llvm-project/commit/2d6d476ffbfc207aae2bf9f12be14483b31d100a
DIFF: https://github.com/llvm/llvm-project/commit/2d6d476ffbfc207aae2bf9f12be14483b31d100a.diff
LOG: [Polly][CMake] Fix exports (#122123)
If Polly is built with LLVM_POLLY_LINK_INTO_TOOLS=ON (the default for
monorepo builds), then Polly will become a dependency of the
LLVMExtensions component, which is part of LLVMExports. As such, all the
Polly libraries also have to be part of LLVMExports.
However, if Polly is built with LLVM_POLLY_LINK_INTO_TOOLS=OFF, we also
end up adding Polly libraries to LLVMExports. This is undesirable, as it
adds a hard dependency from llvm on polly.
Fix this by only exporting polly libraries from LLVMExports if
LLVM_POLLY_LINK_INTO_TOOLS is enabled.
Added:
Modified:
llvm/cmake/modules/AddLLVM.cmake
polly/CMakeLists.txt
polly/cmake/polly_macros.cmake
Removed:
################################################################################
diff --git a/llvm/cmake/modules/AddLLVM.cmake b/llvm/cmake/modules/AddLLVM.cmake
index e046e3798e544b..d3e9377c8d2f7e 100644
--- a/llvm/cmake/modules/AddLLVM.cmake
+++ b/llvm/cmake/modules/AddLLVM.cmake
@@ -1220,9 +1220,9 @@ function(add_llvm_pass_plugin name)
endif()
set_property(GLOBAL APPEND PROPERTY LLVM_STATIC_EXTENSIONS ${name})
elseif(NOT ARG_NO_MODULE)
- add_llvm_library(${name} MODULE ${ARG_UNPARSED_ARGUMENTS})
+ add_llvm_library(${name} MODULE NO_EXPORT ${ARG_UNPARSED_ARGUMENTS})
else()
- add_llvm_library(${name} OBJECT ${ARG_UNPARSED_ARGUMENTS})
+ add_llvm_library(${name} OBJECT NO_EXPORT ${ARG_UNPARSED_ARGUMENTS})
endif()
message(STATUS "Registering ${name} as a pass plugin (static build: ${LLVM_${name_upper}_LINK_INTO_TOOLS})")
diff --git a/polly/CMakeLists.txt b/polly/CMakeLists.txt
index 955c171b3967fe..c3232752d307cf 100644
--- a/polly/CMakeLists.txt
+++ b/polly/CMakeLists.txt
@@ -112,6 +112,14 @@ if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
)
endif()
+# add_llvm_pass_plugin() already declares the option, but we need access to
+# it earlier than that.
+set(link_into_tools_default OFF)
+if (LLVM_TOOL_POLLY_BUILD)
+ set(link_into_tools_default ON)
+endif()
+option(LLVM_POLLY_LINK_INTO_TOOLS "Statically link Polly into tools (if available)" ${link_into_tools_default})
+
add_definitions( -D_GNU_SOURCE )
add_subdirectory(docs)
diff --git a/polly/cmake/polly_macros.cmake b/polly/cmake/polly_macros.cmake
index ddd6376273376a..9bd7b0b0ea5919 100644
--- a/polly/cmake/polly_macros.cmake
+++ b/polly/cmake/polly_macros.cmake
@@ -39,15 +39,21 @@ macro(add_polly_library name)
llvm_config(${name} ${LLVM_LINK_COMPONENTS})
endif( LLVM_LINK_COMPONENTS )
if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY OR ${name} STREQUAL "LLVMPolly")
+ set(exports)
+ if (LLVM_POLLY_LINK_INTO_TOOLS)
+ set(exports EXPORT LLVMExports)
+ endif()
install(TARGETS ${name}
COMPONENT ${name}
- EXPORT LLVMExports
+ ${exports}
LIBRARY DESTINATION lib${LLVM_LIBDIR_SUFFIX}
ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX})
add_llvm_install_targets(install-${name}
COMPONENT ${name})
endif()
- set_property(GLOBAL APPEND PROPERTY LLVM_EXPORTS ${name})
+ if (LLVM_POLLY_LINK_INTO_TOOLS)
+ set_property(GLOBAL APPEND PROPERTY LLVM_EXPORTS ${name})
+ endif()
endmacro(add_polly_library)
macro(add_polly_loadable_module name)
More information about the llvm-commits
mailing list