Skip to content

Reapply "[CMake] Fold export_executable_symbols_* into function args. (#101741)" #102138

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

cachemeifyoucan
Copy link
Collaborator

@cachemeifyoucan cachemeifyoucan commented Aug 6, 2024

Fix the builds with LLVM_TOOL_LLVM_DRIVER_BUILD enabled.

LLVM_ENABLE_EXPORTED_SYMBOLS_IN_EXECUTABLES is not completely
compatible with export_executable_symbols as the later will be ignored
if the previous is set to NO.

Fix the issue by passing if symbols need to be exported to
llvm_add_exectuable so the link flag can be determined directly
without calling export_executable_symbols_* later.

Created using spr 1.3.5
@llvmbot llvmbot added cmake Build system in general and CMake in particular clang Clang issues not falling into any other category clang-tools-extra lld clang-tidy mlir:core MLIR Core Infrastructure flang:driver mlir flang Flang issues not falling into any other category llvm:support llvm:analysis Includes value tracking, cost tables and constant folding labels Aug 6, 2024
@llvmbot
Copy link
Member

llvmbot commented Aug 6, 2024

@llvm/pr-subscribers-llvm-analysis
@llvm/pr-subscribers-lld
@llvm/pr-subscribers-mlir
@llvm/pr-subscribers-clang-tools-extra

@llvm/pr-subscribers-llvm-support

Author: Steven Wu (cachemeifyoucan)

Changes

Fix the builds with LLVM_TOOL_LLVM_DRIVER_BUILD enabled.


Patch is 32.90 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/102138.diff

58 Files Affected:

  • (modified) clang-tools-extra/clang-tidy/tool/CMakeLists.txt (+2-4)
  • (modified) clang/cmake/modules/AddClang.cmake (+1-1)
  • (modified) clang/tools/clang-linker-wrapper/CMakeLists.txt (+1-2)
  • (modified) clang/tools/clang-repl/CMakeLists.txt (+2-2)
  • (modified) clang/tools/driver/CMakeLists.txt (+2-5)
  • (modified) clang/unittests/Interpreter/CMakeLists.txt (+2-2)
  • (modified) clang/unittests/Interpreter/ExceptionTests/CMakeLists.txt (+2-2)
  • (modified) flang/tools/flang-driver/CMakeLists.txt (+9-7)
  • (modified) lld/cmake/modules/AddLLD.cmake (+1-1)
  • (modified) lld/tools/lld/CMakeLists.txt (+1-1)
  • (modified) llvm/CMakeLists.txt (+2-2)
  • (modified) llvm/cmake/modules/AddLLVM.cmake (+10-3)
  • (modified) llvm/examples/ExceptionDemo/CMakeLists.txt (+2-2)
  • (modified) llvm/examples/HowToUseLLJIT/CMakeLists.txt (+2-2)
  • (modified) llvm/examples/Kaleidoscope/BuildingAJIT/Chapter1/CMakeLists.txt (-2)
  • (modified) llvm/examples/Kaleidoscope/BuildingAJIT/Chapter2/CMakeLists.txt (-2)
  • (modified) llvm/examples/Kaleidoscope/BuildingAJIT/Chapter3/CMakeLists.txt (-2)
  • (modified) llvm/examples/Kaleidoscope/BuildingAJIT/Chapter4/CMakeLists.txt (-2)
  • (modified) llvm/examples/Kaleidoscope/CMakeLists.txt (+1-1)
  • (modified) llvm/examples/Kaleidoscope/Chapter4/CMakeLists.txt (-2)
  • (modified) llvm/examples/Kaleidoscope/Chapter5/CMakeLists.txt (-2)
  • (modified) llvm/examples/Kaleidoscope/Chapter6/CMakeLists.txt (-2)
  • (modified) llvm/examples/Kaleidoscope/Chapter7/CMakeLists.txt (-2)
  • (modified) llvm/examples/Kaleidoscope/Chapter8/CMakeLists.txt (-2)
  • (modified) llvm/examples/Kaleidoscope/Chapter9/CMakeLists.txt (-2)
  • (modified) llvm/examples/OrcV2Examples/LLJITDumpObjects/CMakeLists.txt (-2)
  • (modified) llvm/examples/OrcV2Examples/LLJITRemovableCode/CMakeLists.txt (-2)
  • (modified) llvm/examples/OrcV2Examples/LLJITWithCustomObjectLinkingLayer/CMakeLists.txt (-2)
  • (modified) llvm/examples/OrcV2Examples/LLJITWithExecutorProcessControl/CMakeLists.txt (-2)
  • (modified) llvm/examples/OrcV2Examples/LLJITWithGDBRegistrationListener/CMakeLists.txt (-4)
  • (modified) llvm/examples/OrcV2Examples/LLJITWithInitializers/CMakeLists.txt (-2)
  • (modified) llvm/examples/OrcV2Examples/LLJITWithLazyReexports/CMakeLists.txt (-2)
  • (modified) llvm/examples/OrcV2Examples/LLJITWithObjectCache/CMakeLists.txt (-2)
  • (modified) llvm/examples/OrcV2Examples/LLJITWithObjectLinkingLayerPlugin/CMakeLists.txt (-2)
  • (modified) llvm/examples/OrcV2Examples/LLJITWithOptimizingIRTransform/CMakeLists.txt (-2)
  • (modified) llvm/examples/OrcV2Examples/LLJITWithRemoteDebugging/CMakeLists.txt (-2)
  • (modified) llvm/examples/OrcV2Examples/LLJITWithThinLTOSummaries/CMakeLists.txt (-2)
  • (modified) llvm/examples/OrcV2Examples/OrcV2CBindingsAddObjectFile/CMakeLists.txt (-2)
  • (modified) llvm/examples/OrcV2Examples/OrcV2CBindingsBasicUsage/CMakeLists.txt (-2)
  • (modified) llvm/examples/OrcV2Examples/OrcV2CBindingsDumpObjects/CMakeLists.txt (-2)
  • (modified) llvm/examples/OrcV2Examples/OrcV2CBindingsIRTransforms/CMakeLists.txt (-2)
  • (modified) llvm/examples/OrcV2Examples/OrcV2CBindingsLazy/CMakeLists.txt (-2)
  • (modified) llvm/examples/OrcV2Examples/OrcV2CBindingsRemovableCode/CMakeLists.txt (-2)
  • (modified) llvm/examples/OrcV2Examples/OrcV2CBindingsVeryLazy/CMakeLists.txt (-2)
  • (modified) llvm/tools/bugpoint/CMakeLists.txt (+1-1)
  • (modified) llvm/tools/llc/CMakeLists.txt (+1-2)
  • (modified) llvm/tools/lli/CMakeLists.txt (+2-2)
  • (modified) llvm/tools/lli/ChildTarget/CMakeLists.txt (+2-2)
  • (modified) llvm/tools/llvm-jitlink/CMakeLists.txt (+2-2)
  • (modified) llvm/tools/llvm-jitlink/llvm-jitlink-executor/CMakeLists.txt (+2-2)
  • (modified) llvm/tools/llvm-lto2/CMakeLists.txt (+2-1)
  • (modified) llvm/tools/opt/CMakeLists.txt (+1-2)
  • (modified) llvm/unittests/Analysis/CMakeLists.txt (+6-5)
  • (modified) llvm/unittests/ExecutionEngine/Orc/CMakeLists.txt (+2-2)
  • (modified) llvm/unittests/Passes/Plugins/CMakeLists.txt (+2-1)
  • (modified) llvm/unittests/Support/DynamicLibrary/CMakeLists.txt (+4-3)
  • (modified) mlir/tools/mlir-cpu-runner/CMakeLists.txt (+2-2)
  • (modified) mlir/tools/mlir-opt/CMakeLists.txt (+1-1)
diff --git a/clang-tools-extra/clang-tidy/tool/CMakeLists.txt b/clang-tools-extra/clang-tidy/tool/CMakeLists.txt
index b220cbea80f1b..9f327ce838b70 100644
--- a/clang-tools-extra/clang-tidy/tool/CMakeLists.txt
+++ b/clang-tools-extra/clang-tidy/tool/CMakeLists.txt
@@ -33,6 +33,7 @@ clang_target_link_libraries(clangTidyMain
 # Support plugins.
 if(CLANG_PLUGIN_SUPPORT)
   set(support_plugins SUPPORT_PLUGINS)
+  set(export_symbols EXPORT_SYMBOLS_FOR_PLUGINS)
 endif()
 
 add_clang_tool(clang-tidy
@@ -41,6 +42,7 @@ add_clang_tool(clang-tidy
   DEPENDS
   clang-resource-headers
   ${support_plugins}
+  ${export_symbols}
   )
 clang_target_link_libraries(clang-tidy
   PRIVATE
@@ -57,10 +59,6 @@ target_link_libraries(clang-tidy
   ${ALL_CLANG_TIDY_CHECKS}
   )
 
-if(CLANG_PLUGIN_SUPPORT)
-  export_executable_symbols_for_plugins(clang-tidy)
-endif()
-
 install(PROGRAMS clang-tidy-diff.py
   DESTINATION "${CMAKE_INSTALL_DATADIR}/clang"
   COMPONENT clang-tidy)
diff --git a/clang/cmake/modules/AddClang.cmake b/clang/cmake/modules/AddClang.cmake
index 5327b5d2f0892..9f264720b1e9e 100644
--- a/clang/cmake/modules/AddClang.cmake
+++ b/clang/cmake/modules/AddClang.cmake
@@ -160,7 +160,7 @@ macro(add_clang_tool name)
      AND (NOT LLVM_DISTRIBUTION_COMPONENTS OR ${name} IN_LIST LLVM_DISTRIBUTION_COMPONENTS)
     )
     set(get_obj_args ${ARGN})
-    list(FILTER get_obj_args EXCLUDE REGEX "^SUPPORT_PLUGINS$")
+    list(FILTER get_obj_args EXCLUDE REGEX "^(SUPPORT_PLUGINS|EXPORT_SYMBOLS_FOR_PLUGINS)$")
     generate_llvm_objects(${name} ${get_obj_args})
     add_custom_target(${name} DEPENDS llvm-driver clang-resource-headers)
   else()
diff --git a/clang/tools/clang-linker-wrapper/CMakeLists.txt b/clang/tools/clang-linker-wrapper/CMakeLists.txt
index bf37d8031025e..4a16c3ca9f090 100644
--- a/clang/tools/clang-linker-wrapper/CMakeLists.txt
+++ b/clang/tools/clang-linker-wrapper/CMakeLists.txt
@@ -31,6 +31,7 @@ add_clang_tool(clang-linker-wrapper
 
   DEPENDS
   ${tablegen_deps}
+  EXPORT_SYMBOLS_FOR_PLUGINS
   )
 
 set(CLANG_LINKER_WRAPPER_LIB_DEPS
@@ -41,5 +42,3 @@ target_link_libraries(clang-linker-wrapper
   PRIVATE
   ${CLANG_LINKER_WRAPPER_LIB_DEPS}
   )
-
-export_executable_symbols_for_plugins(clang-linker-wrapper)
diff --git a/clang/tools/clang-repl/CMakeLists.txt b/clang/tools/clang-repl/CMakeLists.txt
index a35ff13494e11..52b740b356284 100644
--- a/clang/tools/clang-repl/CMakeLists.txt
+++ b/clang/tools/clang-repl/CMakeLists.txt
@@ -9,6 +9,8 @@ set( LLVM_LINK_COMPONENTS
 
 add_clang_tool(clang-repl
   ClangRepl.cpp
+
+  EXPORT_SYMBOLS_FOR_PLUGINS
   )
 
 if(MSVC)
@@ -61,8 +63,6 @@ clang_target_link_libraries(clang-repl PRIVATE
   clangInterpreter
   )
 
-export_executable_symbols_for_plugins(clang-repl)
-
 # The clang-repl binary can get huge with static linking in debug mode.
 # Some 32-bit targets use PLT slots with limited branch range by default and we
 # start to exceed this limit, e.g. when linking for arm-linux-gnueabihf with
diff --git a/clang/tools/driver/CMakeLists.txt b/clang/tools/driver/CMakeLists.txt
index 018605c2fd4f2..805dffb0d9b70 100644
--- a/clang/tools/driver/CMakeLists.txt
+++ b/clang/tools/driver/CMakeLists.txt
@@ -21,6 +21,7 @@ set( LLVM_LINK_COMPONENTS
 # Support plugins.
 if(CLANG_PLUGIN_SUPPORT)
   set(support_plugins SUPPORT_PLUGINS)
+  set(export_symbols EXPORT_SYMBOLS_FOR_PLUGINS)
 endif()
 
 add_clang_tool(clang
@@ -35,6 +36,7 @@ add_clang_tool(clang
   ARMTargetParserTableGen
   AArch64TargetParserTableGen
   ${support_plugins}
+  ${export_symbols}
   GENERATE_DRIVER
   )
 
@@ -54,11 +56,6 @@ else()
   set_target_properties(clang PROPERTIES VERSION ${CLANG_EXECUTABLE_VERSION})
 endif()
 
-# Support plugins.
-if(CLANG_PLUGIN_SUPPORT)
-  export_executable_symbols_for_plugins(clang)
-endif()
-
 add_dependencies(clang clang-resource-headers)
 
 if(NOT CLANG_LINKS_TO_CREATE)
diff --git a/clang/unittests/Interpreter/CMakeLists.txt b/clang/unittests/Interpreter/CMakeLists.txt
index c0fd2d8f3777a..ec6f81ea19b96 100644
--- a/clang/unittests/Interpreter/CMakeLists.txt
+++ b/clang/unittests/Interpreter/CMakeLists.txt
@@ -13,6 +13,8 @@ add_clang_unittest(ClangReplInterpreterTests
   InterpreterTest.cpp
   InterpreterExtensionsTest.cpp
   CodeCompletionTest.cpp
+
+  EXPORT_SYMBOLS
   )
 target_link_libraries(ClangReplInterpreterTests PUBLIC
   clangAST
@@ -28,8 +30,6 @@ if(NOT WIN32)
   add_subdirectory(ExceptionTests)
 endif()
 
-export_executable_symbols(ClangReplInterpreterTests)
-
 if(MSVC)
   set_target_properties(ClangReplInterpreterTests PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS 1)
 
diff --git a/clang/unittests/Interpreter/ExceptionTests/CMakeLists.txt b/clang/unittests/Interpreter/ExceptionTests/CMakeLists.txt
index 5a6597d1b6728..24ae9cd78b5ca 100644
--- a/clang/unittests/Interpreter/ExceptionTests/CMakeLists.txt
+++ b/clang/unittests/Interpreter/ExceptionTests/CMakeLists.txt
@@ -12,6 +12,8 @@ set(LLVM_LINK_COMPONENTS
 
 add_clang_unittest(ClangReplInterpreterExceptionTests
   InterpreterExceptionTest.cpp
+
+  EXPORT_SYMBOLS
   )
 
 llvm_update_compile_flags(ClangReplInterpreterExceptionTests)
@@ -22,5 +24,3 @@ target_link_libraries(ClangReplInterpreterExceptionTests PUBLIC
   clangFrontend
   )
 add_dependencies(ClangReplInterpreterExceptionTests clang-resource-headers)
-
-export_executable_symbols(ClangReplInterpreterExceptionTests)
diff --git a/flang/tools/flang-driver/CMakeLists.txt b/flang/tools/flang-driver/CMakeLists.txt
index 9f33cdfe3fa90..baa9496002835 100644
--- a/flang/tools/flang-driver/CMakeLists.txt
+++ b/flang/tools/flang-driver/CMakeLists.txt
@@ -11,9 +11,18 @@ set( LLVM_LINK_COMPONENTS
   TargetParser
 )
 
+option(FLANG_PLUGIN_SUPPORT "Build Flang with plugin support." ON)
+
+# Enable support for plugins, which need access to symbols from flang-new
+if(FLANG_PLUGIN_SUPPORT)
+  set(export_symbols EXPORT_SYMBOLS_FOR_PLUGINS)
+endif()
+
 add_flang_tool(flang-new
   driver.cpp
   fc1_main.cpp
+
+  ${export_symbols}
 )
 
 target_link_libraries(flang-new
@@ -28,11 +37,4 @@ clang_target_link_libraries(flang-new
   clangBasic
 )
 
-option(FLANG_PLUGIN_SUPPORT "Build Flang with plugin support." ON)
-
-# Enable support for plugins, which need access to symbols from flang-new
-if(FLANG_PLUGIN_SUPPORT)
-  export_executable_symbols_for_plugins(flang-new)
-endif()
-
 install(TARGETS flang-new DESTINATION "${CMAKE_INSTALL_BINDIR}")
diff --git a/lld/cmake/modules/AddLLD.cmake b/lld/cmake/modules/AddLLD.cmake
index 9f2684b6f933e..34f9974efbf50 100644
--- a/lld/cmake/modules/AddLLD.cmake
+++ b/lld/cmake/modules/AddLLD.cmake
@@ -44,7 +44,7 @@ macro(add_lld_tool name)
     AND (NOT LLVM_DISTRIBUTION_COMPONENTS OR ${name} IN_LIST LLVM_DISTRIBUTION_COMPONENTS)
   )
     set(get_obj_args ${ARGN})
-    list(FILTER get_obj_args EXCLUDE REGEX "^SUPPORT_PLUGINS$")
+    list(FILTER get_obj_args EXCLUDE REGEX "^(SUPPORT_PLUGINS|EXPORT_SYMBOLS_FOR_PLUGINS)$")
     generate_llvm_objects(${name} ${get_obj_args})
     add_custom_target(${name} DEPENDS llvm-driver)
   else()
diff --git a/lld/tools/lld/CMakeLists.txt b/lld/tools/lld/CMakeLists.txt
index 8498a91597a93..630d38f770a7f 100644
--- a/lld/tools/lld/CMakeLists.txt
+++ b/lld/tools/lld/CMakeLists.txt
@@ -8,8 +8,8 @@ add_lld_tool(lld
 
   SUPPORT_PLUGINS
   GENERATE_DRIVER
+  EXPORT_SYMBOLS_FOR_PLUGINS
   )
-export_executable_symbols_for_plugins(lld)
 
 function(lld_target_link_libraries target type)
   if (TARGET obj.${target})
diff --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt
index 699de1ccd870c..51f99cb696257 100644
--- a/llvm/CMakeLists.txt
+++ b/llvm/CMakeLists.txt
@@ -1197,7 +1197,7 @@ if( ${CMAKE_SYSTEM_NAME} MATCHES SunOS )
 endif( ${CMAKE_SYSTEM_NAME} MATCHES SunOS )
 
 # Make sure we don't get -rdynamic in every binary. For those that need it,
-# use export_executable_symbols(target).
+# use EXPORT_SYMBOLS argument.
 set(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "")
 
 include(AddLLVM)
@@ -1238,7 +1238,7 @@ if( LLVM_INCLUDE_UTILS )
   if( LLVM_INCLUDE_TESTS )
     set(LLVM_SUBPROJECT_TITLE "Third-Party/Google Test")
     add_subdirectory(${LLVM_THIRD_PARTY_DIR}/unittest ${CMAKE_CURRENT_BINARY_DIR}/third-party/unittest)
-    set(LLVM_SUBPROJECT_TITLE) 
+    set(LLVM_SUBPROJECT_TITLE)
   endif()
 else()
   if ( LLVM_INCLUDE_TESTS )
diff --git a/llvm/cmake/modules/AddLLVM.cmake b/llvm/cmake/modules/AddLLVM.cmake
index bb4e9963d0913..257dc2250bb4e 100644
--- a/llvm/cmake/modules/AddLLVM.cmake
+++ b/llvm/cmake/modules/AddLLVM.cmake
@@ -1010,7 +1010,7 @@ endmacro()
 
 macro(add_llvm_executable name)
   cmake_parse_arguments(ARG
-    "DISABLE_LLVM_LINK_LLVM_DYLIB;IGNORE_EXTERNALIZE_DEBUGINFO;NO_INSTALL_RPATH;SUPPORT_PLUGINS"
+    "DISABLE_LLVM_LINK_LLVM_DYLIB;IGNORE_EXTERNALIZE_DEBUGINFO;NO_INSTALL_RPATH;SUPPORT_PLUGINS;EXPORT_SYMBOLS;EXPORT_SYMBOLS_FOR_PLUGINS"
     "ENTITLEMENTS;BUNDLE_PATH"
     ""
     ${ARGN})
@@ -1070,7 +1070,8 @@ macro(add_llvm_executable name)
   endif(LLVM_EXPORTED_SYMBOL_FILE)
 
   if (DEFINED LLVM_ENABLE_EXPORTED_SYMBOLS_IN_EXECUTABLES AND
-      NOT LLVM_ENABLE_EXPORTED_SYMBOLS_IN_EXECUTABLES)
+      NOT LLVM_ENABLE_EXPORTED_SYMBOLS_IN_EXECUTABLES AND
+      NOT ARG_EXPORT_SYMBOLS AND NOT ARG_EXPORT_SYMBOLS_FOR_PLUGINS)
     if(LLVM_LINKER_SUPPORTS_NO_EXPORTED_SYMBOLS)
       set_property(TARGET ${name} APPEND_STRING PROPERTY
         LINK_FLAGS " -Wl,-no_exported_symbols")
@@ -1080,6 +1081,12 @@ macro(add_llvm_executable name)
     endif()
   endif()
 
+  if (ARG_EXPORT_SYMBOLS)
+    export_executable_symbols(${name})
+  elseif(ARG_EXPORT_SYMBOLS_FOR_PLUGINS)
+    export_executable_symbols_for_plugins(${name})
+  endif()
+
   if (LLVM_LINK_LLVM_DYLIB AND NOT ARG_DISABLE_LLVM_LINK_LLVM_DYLIB)
     set(USE_SHARED USE_SHARED)
   endif()
@@ -1464,7 +1471,7 @@ macro(add_llvm_example name)
   if( NOT LLVM_BUILD_EXAMPLES )
     set(EXCLUDE_FROM_ALL ON)
   endif()
-  add_llvm_executable(${name} ${ARGN})
+  add_llvm_executable(${name} EXPORT_SYMBOLS ${ARGN})
   if( LLVM_BUILD_EXAMPLES )
     install(TARGETS ${name} RUNTIME DESTINATION "${LLVM_EXAMPLES_INSTALL_DIR}")
   endif()
diff --git a/llvm/examples/ExceptionDemo/CMakeLists.txt b/llvm/examples/ExceptionDemo/CMakeLists.txt
index 793cf291ca6f1..6c125fe20fb6f 100644
--- a/llvm/examples/ExceptionDemo/CMakeLists.txt
+++ b/llvm/examples/ExceptionDemo/CMakeLists.txt
@@ -16,6 +16,6 @@ endif()
 
 add_llvm_example(ExceptionDemo
   ExceptionDemo.cpp
-  )
 
-export_executable_symbols(ExceptionDemo)
+  EXPORT_SYMBOLS
+  )
diff --git a/llvm/examples/HowToUseLLJIT/CMakeLists.txt b/llvm/examples/HowToUseLLJIT/CMakeLists.txt
index 3ca99e5598e76..ca5e190c61338 100644
--- a/llvm/examples/HowToUseLLJIT/CMakeLists.txt
+++ b/llvm/examples/HowToUseLLJIT/CMakeLists.txt
@@ -7,6 +7,6 @@ set(LLVM_LINK_COMPONENTS
 
 add_llvm_example(HowToUseLLJIT
   HowToUseLLJIT.cpp
-  )
 
-export_executable_symbols(HowToUseLLJIT)
+  EXPORT_SYMBOLS
+  )
diff --git a/llvm/examples/Kaleidoscope/BuildingAJIT/Chapter1/CMakeLists.txt b/llvm/examples/Kaleidoscope/BuildingAJIT/Chapter1/CMakeLists.txt
index 72c9668f7d3af..d4b7c3fed547d 100644
--- a/llvm/examples/Kaleidoscope/BuildingAJIT/Chapter1/CMakeLists.txt
+++ b/llvm/examples/Kaleidoscope/BuildingAJIT/Chapter1/CMakeLists.txt
@@ -14,5 +14,3 @@ set(LLVM_LINK_COMPONENTS
 add_kaleidoscope_chapter(BuildingAJIT-Ch1
   toy.cpp
   )
-
-export_executable_symbols(BuildingAJIT-Ch1)
diff --git a/llvm/examples/Kaleidoscope/BuildingAJIT/Chapter2/CMakeLists.txt b/llvm/examples/Kaleidoscope/BuildingAJIT/Chapter2/CMakeLists.txt
index ba6abd72d4282..9fd9e8860b2f9 100644
--- a/llvm/examples/Kaleidoscope/BuildingAJIT/Chapter2/CMakeLists.txt
+++ b/llvm/examples/Kaleidoscope/BuildingAJIT/Chapter2/CMakeLists.txt
@@ -14,5 +14,3 @@ set(LLVM_LINK_COMPONENTS
 add_kaleidoscope_chapter(BuildingAJIT-Ch2
   toy.cpp
   )
-
-export_executable_symbols(BuildingAJIT-Ch2)
diff --git a/llvm/examples/Kaleidoscope/BuildingAJIT/Chapter3/CMakeLists.txt b/llvm/examples/Kaleidoscope/BuildingAJIT/Chapter3/CMakeLists.txt
index 51800a64b1e30..cf82552162e01 100644
--- a/llvm/examples/Kaleidoscope/BuildingAJIT/Chapter3/CMakeLists.txt
+++ b/llvm/examples/Kaleidoscope/BuildingAJIT/Chapter3/CMakeLists.txt
@@ -15,5 +15,3 @@ set(LLVM_LINK_COMPONENTS
 add_kaleidoscope_chapter(BuildingAJIT-Ch3
   toy.cpp
   )
-
-export_executable_symbols(BuildingAJIT-Ch3)
diff --git a/llvm/examples/Kaleidoscope/BuildingAJIT/Chapter4/CMakeLists.txt b/llvm/examples/Kaleidoscope/BuildingAJIT/Chapter4/CMakeLists.txt
index 7cd40a1da60dc..241192fa01c93 100644
--- a/llvm/examples/Kaleidoscope/BuildingAJIT/Chapter4/CMakeLists.txt
+++ b/llvm/examples/Kaleidoscope/BuildingAJIT/Chapter4/CMakeLists.txt
@@ -15,5 +15,3 @@ set(LLVM_LINK_COMPONENTS
 add_kaleidoscope_chapter(BuildingAJIT-Ch4
   toy.cpp
   )
-
-export_executable_symbols(BuildingAJIT-Ch4)
diff --git a/llvm/examples/Kaleidoscope/CMakeLists.txt b/llvm/examples/Kaleidoscope/CMakeLists.txt
index 6ad3b61566472..3cc6733c7d307 100644
--- a/llvm/examples/Kaleidoscope/CMakeLists.txt
+++ b/llvm/examples/Kaleidoscope/CMakeLists.txt
@@ -3,7 +3,7 @@ set_target_properties(Kaleidoscope PROPERTIES FOLDER "LLVM/Examples")
 
 macro(add_kaleidoscope_chapter name)
   add_dependencies(Kaleidoscope ${name})
-  add_llvm_example(${name} ${ARGN})
+  add_llvm_example(${name} EXPORT_SYMBOLS ${ARGN})
 endmacro(add_kaleidoscope_chapter name)
 
 add_subdirectory(BuildingAJIT)
diff --git a/llvm/examples/Kaleidoscope/Chapter4/CMakeLists.txt b/llvm/examples/Kaleidoscope/Chapter4/CMakeLists.txt
index 5281941fec874..dcb82ffad4b8d 100644
--- a/llvm/examples/Kaleidoscope/Chapter4/CMakeLists.txt
+++ b/llvm/examples/Kaleidoscope/Chapter4/CMakeLists.txt
@@ -15,5 +15,3 @@ set(LLVM_LINK_COMPONENTS
 add_kaleidoscope_chapter(Kaleidoscope-Ch4
   toy.cpp
   )
-
-export_executable_symbols(Kaleidoscope-Ch4)
diff --git a/llvm/examples/Kaleidoscope/Chapter5/CMakeLists.txt b/llvm/examples/Kaleidoscope/Chapter5/CMakeLists.txt
index 35fb1b7911b86..9639f440d200c 100644
--- a/llvm/examples/Kaleidoscope/Chapter5/CMakeLists.txt
+++ b/llvm/examples/Kaleidoscope/Chapter5/CMakeLists.txt
@@ -15,5 +15,3 @@ set(LLVM_LINK_COMPONENTS
 add_kaleidoscope_chapter(Kaleidoscope-Ch5
   toy.cpp
   )
-
-export_executable_symbols(Kaleidoscope-Ch5)
diff --git a/llvm/examples/Kaleidoscope/Chapter6/CMakeLists.txt b/llvm/examples/Kaleidoscope/Chapter6/CMakeLists.txt
index 627d682bdc57f..0baf3f483e1ba 100644
--- a/llvm/examples/Kaleidoscope/Chapter6/CMakeLists.txt
+++ b/llvm/examples/Kaleidoscope/Chapter6/CMakeLists.txt
@@ -15,5 +15,3 @@ set(LLVM_LINK_COMPONENTS
 add_kaleidoscope_chapter(Kaleidoscope-Ch6
   toy.cpp
   )
-
-export_executable_symbols(Kaleidoscope-Ch6)
diff --git a/llvm/examples/Kaleidoscope/Chapter7/CMakeLists.txt b/llvm/examples/Kaleidoscope/Chapter7/CMakeLists.txt
index f4d8bd9e20c38..2167b4cf55e2c 100644
--- a/llvm/examples/Kaleidoscope/Chapter7/CMakeLists.txt
+++ b/llvm/examples/Kaleidoscope/Chapter7/CMakeLists.txt
@@ -16,5 +16,3 @@ set(LLVM_LINK_COMPONENTS
 add_kaleidoscope_chapter(Kaleidoscope-Ch7
   toy.cpp
   )
-
-export_executable_symbols(Kaleidoscope-Ch7)
diff --git a/llvm/examples/Kaleidoscope/Chapter8/CMakeLists.txt b/llvm/examples/Kaleidoscope/Chapter8/CMakeLists.txt
index 1bb1cd25af72d..29c02c9dbc720 100644
--- a/llvm/examples/Kaleidoscope/Chapter8/CMakeLists.txt
+++ b/llvm/examples/Kaleidoscope/Chapter8/CMakeLists.txt
@@ -5,5 +5,3 @@ set(LLVM_LINK_COMPONENTS
 add_kaleidoscope_chapter(Kaleidoscope-Ch8
   toy.cpp
   )
-
-export_executable_symbols(Kaleidoscope-Ch8)
diff --git a/llvm/examples/Kaleidoscope/Chapter9/CMakeLists.txt b/llvm/examples/Kaleidoscope/Chapter9/CMakeLists.txt
index a5d1a45108872..d21ba342ebe5a 100644
--- a/llvm/examples/Kaleidoscope/Chapter9/CMakeLists.txt
+++ b/llvm/examples/Kaleidoscope/Chapter9/CMakeLists.txt
@@ -11,5 +11,3 @@ set(LLVM_LINK_COMPONENTS
 add_kaleidoscope_chapter(Kaleidoscope-Ch9
   toy.cpp
   )
-
-export_executable_symbols(Kaleidoscope-Ch9)
diff --git a/llvm/examples/OrcV2Examples/LLJITDumpObjects/CMakeLists.txt b/llvm/examples/OrcV2Examples/LLJITDumpObjects/CMakeLists.txt
index 42b9d1c4f9ae8..3d83ee6864d33 100644
--- a/llvm/examples/OrcV2Examples/LLJITDumpObjects/CMakeLists.txt
+++ b/llvm/examples/OrcV2Examples/LLJITDumpObjects/CMakeLists.txt
@@ -11,5 +11,3 @@ set(LLVM_LINK_COMPONENTS
 add_llvm_example(LLJITDumpObjects
   LLJITDumpObjects.cpp
   )
-
-export_executable_symbols(LLJITDumpObjects)
diff --git a/llvm/examples/OrcV2Examples/LLJITRemovableCode/CMakeLists.txt b/llvm/examples/OrcV2Examples/LLJITRemovableCode/CMakeLists.txt
index 2c0036f625607..3ab58c1c1f308 100644
--- a/llvm/examples/OrcV2Examples/LLJITRemovableCode/CMakeLists.txt
+++ b/llvm/examples/OrcV2Examples/LLJITRemovableCode/CMakeLists.txt
@@ -12,5 +12,3 @@ set(LLVM_LINK_COMPONENTS
 add_llvm_example(LLJITRemovableCode
   LLJITRemovableCode.cpp
   )
-
-export_executable_symbols(LLJITRemovableCode)
diff --git a/llvm/examples/OrcV2Examples/LLJITWithCustomObjectLinkingLayer/CMakeLists.txt b/llvm/examples/OrcV2Examples/LLJITWithCustomObjectLinkingLayer/CMakeLists.txt
index 85e11ec1368e0..6034fc6791127 100644
--- a/llvm/examples/OrcV2Examples/LLJITWithCustomObjectLinkingLayer/CMakeLists.txt
+++ b/llvm/examples/OrcV2Examples/LLJITWithCustomObjectLinkingLayer/CMakeLists.txt
@@ -10,5 +10,3 @@ set(LLVM_LINK_COMPONENTS
 add_llvm_example(LLJITWithCustomObjectLinkingLayer
   LLJITWithCustomObjectLinkingLayer.cpp
   )
-
-export_executable_symbols(LLJITWithCustomObjectLinkingLayer)
diff --git a/llvm/examples/OrcV2Examples/LLJITWithExecutorProcessControl/CMakeLists.txt b/llvm/examples/OrcV2Examples/LLJITWithExecutorProcessControl/CMakeLists.txt
index 65a5b1bb3a404..47f50ca746440 100644
--- a/llvm/examples/OrcV2Examples/LLJITWithExecutorProcessControl/CMakeLists.txt
+++ b/llvm/examples/OrcV2Examples/LLJITWithExecutorProcessControl/CMakeLists.txt
@@ -10,5 +10,3 @@ set(LLVM_LINK_COMPONENTS
 add_llvm_example(LLJITWithExecutorProcessControl
   LLJITWithExecutorProcessControl.cpp
   )
-
-export_executable_symbols(LLJITWithExecutorProcessControl)
diff --git a/llvm/examples/OrcV2Examples/LLJITWithGDBRegistrationListener/CMakeLists.txt b/llvm/examples/OrcV2Examples/LLJITWithGDBRegistrationListener/CMakeLists.txt
index 12fe6346ea4e7..61864201ddec6 100644
--- a/llvm/examples/OrcV2Examples/LLJITWithGDBRegistrationListener/CMakeLists.txt
+++ b/llvm/examples/OrcV2Examples/LLJITWithGDBRegistrationListener/CMakeLists.txt
@@ -12,7 +12,3 @@ set(LLVM_LINK_COMPONENTS
 add_llvm_example(LLJITWithGDBRegistrationListener
   LLJITWithGDBRegistrationListener.cpp
   )
-
-# We want JIT'd code to be able to link against process symbols like printf
-# for this example, so make sure they're exported.
-export_executable_symbols(LLJITWithGDBRegistrationListener)
diff --git a/llvm/examples/OrcV2Examples/LLJITWithInitializers/CMakeLists.txt b/llvm/examples/OrcV2Examples/LLJITWithInitializers/CMakeLists.txt
index ed466f4e40652..302647564ab81 100644
--- a/llvm/examples/OrcV2Examples/LLJITWithInitializers/CMakeLists.txt
+++ b/llvm/examples/OrcV2Examples/LLJITWithInitializers/CMakeLists.txt
@@ -11,5 +11,3 @@ set(LLVM_LINK_COMPONENTS
 add_llvm_example(LLJITWithInitializers
   LLJITWithInitializers.cpp
   )
-
-export_executable_symbols(LLJITWithInitializers)
diff --git a/llvm/examples/OrcV2Examples/LLJITWithLazyReexports/CMakeLists.txt b/llvm/examples/OrcV2Examples/LLJITWithLazyReexports/CMakeLists.txt
index 2ed22e161139c..cdff74b10ad03 100644
--- a/llvm/examples/OrcV2Examples/LLJITWithLazyReexports/CMakeLists.txt
+++ b/llvm/examples/OrcV2Examples/LLJITWithLazyReexports/CMakeLists.txt
@@ -10,5 +10,3 @@ set(LLVM_LINK_COMPONENTS
 add_llvm_example(LLJITWithLazyReexports
   LLJITWithLazyReexports.cpp
   )
-
-export_executable_symbols(LLJITWithLazyReexports)
diff --git a/llvm/examples/OrcV2Examples/LLJITWithObjectCache/CMakeLists.txt b/llvm/examples/OrcV2Examples/LLJITWithObjectCache/CMakeLists.txt
index a4eaaadf01521..c5f8fd6a97a7f 100644
--- a/llvm/examples/OrcV2Examples/LLJITWithObjectCache/CMakeLists.txt
+++ b/llvm/examples/OrcV2Examples/LLJITWithObjectCache/CMakeLists.txt
@@ -10,5 +10,3 @@ set(LLVM_LINK_COMPONENTS
 add_llvm_example(LLJITWithObjectCache
   LLJITWithObjectCache.cpp
   )
-
-export_executable_symbols(LLJITWithObjectCache)
diff --git a/llvm/examples/OrcV2Examples/LLJITWithObjectLinkingLayerPlugin/CMakeLists.txt b/llvm/examples/OrcV2Examples/LLJITWithObjectLinkingLayerPlugin/CMakeLists.txt
index 6177d4596e369..54814621a5a5f 100644
--- a/llvm/examples/OrcV2Examples/LLJITWithObjectLinkingLayerPlugin/CMakeLists.txt
+++ b/llvm/examples/OrcV2Examples/LLJITWithObjectLi...
[truncated]

@cachemeifyoucan
Copy link
Collaborator Author

@petrhosek Let me know if you want to check this offline before I merge or you want me to merge and see if it breaks again.

@cachemeifyoucan
Copy link
Collaborator Author

I will merge and watch Fuchsia bot to make sure it doesn't break.

@cachemeifyoucan cachemeifyoucan merged commit 01b488f into main Aug 7, 2024
19 checks passed
@cachemeifyoucan cachemeifyoucan deleted the users/cachemeifyoucan/spr/reapply-cmake-fold-export_executable_symbols_-into-function-args-101741 branch August 7, 2024 16:12
@llvm-ci
Copy link
Collaborator

llvm-ci commented Aug 7, 2024

LLVM Buildbot has detected a new failure on builder clang-ppc64-aix running on aix-ppc64 while building clang-tools-extra,clang,flang,lld,llvm,mlir at step 3 "clean-build-dir".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/64/builds/620

Here is the relevant piece of the build log for the reference:

Step 3 (clean-build-dir) failure: Delete failed. (failure) (timed out)
Step 5 (build-unified-tree) failure: build (failure)
...
7516.350 [162/10/4922] Building CXX object tools/llvm-xray/CMakeFiles/llvm-xray.dir/xray-registry.cpp.o
7516.524 [161/10/4923] Building CXX object tools/llvm-yaml-numeric-parser-fuzzer/CMakeFiles/llvm-yaml-numeric-parser-fuzzer.dir/DummyYAMLNumericParserFuzzer.cpp.o
7516.686 [160/10/4924] Building CXX object tools/llvm-yaml-parser-fuzzer/CMakeFiles/llvm-yaml-parser-fuzzer.dir/DummyYAMLParserFuzzer.cpp.o
7517.065 [159/10/4925] Building CXX object tools/llvm-xray/CMakeFiles/llvm-xray.dir/xray-graph.cpp.o
7517.255 [158/10/4926] Linking CXX executable bin/llvm-rc
7517.564 [157/10/4927] Generating ../../bin/llvm-windres
7519.303 [156/10/4928] Building CXX object tools/llvm-yaml-parser-fuzzer/CMakeFiles/llvm-yaml-parser-fuzzer.dir/yaml-parser-fuzzer.cpp.o
7519.542 [155/10/4929] Building CXX object tools/llvm-yaml-numeric-parser-fuzzer/CMakeFiles/llvm-yaml-numeric-parser-fuzzer.dir/yaml-numeric-parser-fuzzer.cpp.o
7543.643 [154/10/4930] Linking CXX executable bin/llvm-readobj
7543.899 [153/10/4931] Generating export list for clang
FAILED: tools/clang/tools/driver/clang.symbols /home/powerllvm/powerllvm_env/aix-ppc64/clang-ppc64-aix/build/tools/clang/tools/driver/clang.symbols 
cd /home/powerllvm/powerllvm_env/aix-ppc64/clang-ppc64-aix/build/lib && /opt/freeware/bin/python3.9 /home/powerllvm/powerllvm_env/aix-ppc64/clang-ppc64-aix/llvm-project/llvm/utils/extract_symbols.py --mangling=itanium -o /home/powerllvm/powerllvm_env/aix-ppc64/clang-ppc64-aix/build/tools/clang/tools/driver/./clang.symbols --nm=/home/powerllvm/powerllvm_env/aix-ppc64/clang-ppc64-aix/build/bin/llvm-nm --readobj=/home/powerllvm/powerllvm_env/aix-ppc64/clang-ppc64-aix/build/bin/llvm-readobj
usage: extract_symbols.py [-h] --mangling {itanium,microsoft} [--nm path]
                          [--readobj path] [-o file]
                          lib [lib ...]
extract_symbols.py: error: the following arguments are required: lib
7544.070 [153/9/4932] Building CXX object tools/llvm-xray/CMakeFiles/llvm-xray.dir/xray-stacks.cpp.o
7544.071 [153/8/4933] Linking CXX executable bin/llvm-profgen
7544.107 [153/7/4934] Building CXX object tools/obj2yaml/CMakeFiles/obj2yaml.dir/obj2yaml.cpp.o
7544.118 [153/6/4935] Building CXX object tools/obj2yaml/CMakeFiles/obj2yaml.dir/coff2yaml.cpp.o
7544.130 [153/5/4936] Building CXX object tools/obj2yaml/CMakeFiles/obj2yaml.dir/dxcontainer2yaml.cpp.o
7544.142 [153/4/4937] Building CXX object tools/obj2yaml/CMakeFiles/obj2yaml.dir/archive2yaml.cpp.o
7544.148 [153/3/4938] Building CXX object tools/obj2yaml/CMakeFiles/obj2yaml.dir/dwarf2yaml.cpp.o
7544.154 [153/2/4939] Building CXX object tools/llvm-xray/CMakeFiles/llvm-xray.dir/xray-account.cpp.o
7596.058 [153/1/4940] Building CXX object tools/obj2yaml/CMakeFiles/obj2yaml.dir/elf2yaml.cpp.o
ninja: build stopped: subcommand failed.

cachemeifyoucan added a commit that referenced this pull request Aug 8, 2024
Partially remove some of the changes from #102138 as
EXPORT_SYMBOLS_FOR_PLUGINS doesn't work on all the configurations.
cachemeifyoucan added a commit that referenced this pull request Aug 11, 2024
…havior (#102671)

Followup to #102138 and #102396, restore more old behavior to fix
ppc64-aix bot.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang Clang issues not falling into any other category clang-tidy clang-tools-extra cmake Build system in general and CMake in particular flang:driver flang Flang issues not falling into any other category lld llvm:analysis Includes value tracking, cost tables and constant folding llvm:support mlir:core MLIR Core Infrastructure mlir
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants