[llvm] a9604cd - [CMake] Fix DynamicLibraryTests exports symbol when plugins are enabled (#102941)

via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 13 09:56:05 PDT 2024


Author: Steven Wu
Date: 2024-08-13T09:56:02-07:00
New Revision: a9604cd3212beb6cdb41a79f248723140ab9939d

URL: https://github.com/llvm/llvm-project/commit/a9604cd3212beb6cdb41a79f248723140ab9939d
DIFF: https://github.com/llvm/llvm-project/commit/a9604cd3212beb6cdb41a79f248723140ab9939d.diff

LOG: [CMake] Fix DynamicLibraryTests exports symbol when plugins are enabled (#102941)

Exporting symbols from tools directory never worked with
`LLVM_EXPORT_SYMBOLS_FOR_PLUGINS=On`. When that options is on, only
symbols from the static library is linked is exported due to the export
symbols computation script. DynamicLibraryTests needs to export a symbol
from the tools/executable directory, so update it to use export list
instead.

Added: 
    llvm/unittests/Support/DynamicLibrary/DynamicLibraryTests.exports

Modified: 
    llvm/cmake/modules/AddLLVM.cmake
    llvm/unittests/Support/DynamicLibrary/CMakeLists.txt

Removed: 
    


################################################################################
diff  --git a/llvm/cmake/modules/AddLLVM.cmake b/llvm/cmake/modules/AddLLVM.cmake
index 3e7e3a965559af..99959ecfae9cba 100644
--- a/llvm/cmake/modules/AddLLVM.cmake
+++ b/llvm/cmake/modules/AddLLVM.cmake
@@ -1071,7 +1071,7 @@ macro(add_llvm_executable name)
 
   if (DEFINED LLVM_ENABLE_EXPORTED_SYMBOLS_IN_EXECUTABLES AND
       NOT LLVM_ENABLE_EXPORTED_SYMBOLS_IN_EXECUTABLES AND
-      NOT ARG_EXPORT_SYMBOLS AND NOT ARG_EXPORT_SYMBOLS_FOR_PLUGINS)
+      NOT ARG_EXPORT_SYMBOLS)
     if(LLVM_LINKER_SUPPORTS_NO_EXPORTED_SYMBOLS)
       set_property(TARGET ${name} APPEND_STRING PROPERTY
         LINK_FLAGS " -Wl,-no_exported_symbols")

diff  --git a/llvm/unittests/Support/DynamicLibrary/CMakeLists.txt b/llvm/unittests/Support/DynamicLibrary/CMakeLists.txt
index d8dff1ef4a3f77..ff0b2f07ee1363 100644
--- a/llvm/unittests/Support/DynamicLibrary/CMakeLists.txt
+++ b/llvm/unittests/Support/DynamicLibrary/CMakeLists.txt
@@ -15,6 +15,8 @@ set_output_directory(DynamicLibraryLib
   LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}
   )
 
+set(LLVM_EXPORTED_SYMBOL_FILE ${CMAKE_CURRENT_SOURCE_DIR}/DynamicLibraryTests.exports)
+
 add_llvm_unittest(DynamicLibraryTests
   DynamicLibraryTest.cpp
 
@@ -22,6 +24,8 @@ add_llvm_unittest(DynamicLibraryTests
   )
 target_link_libraries(DynamicLibraryTests PRIVATE DynamicLibraryLib)
 
+unset(LLVM_EXPORTED_SYMBOL_FILE)
+
 function(dynlib_add_module NAME)
   add_library(${NAME} MODULE
     PipSqueak.cpp

diff  --git a/llvm/unittests/Support/DynamicLibrary/DynamicLibraryTests.exports b/llvm/unittests/Support/DynamicLibrary/DynamicLibraryTests.exports
new file mode 100644
index 00000000000000..a9122211071ee6
--- /dev/null
+++ b/llvm/unittests/Support/DynamicLibrary/DynamicLibraryTests.exports
@@ -0,0 +1 @@
+TestA


        


More information about the llvm-commits mailing list