Skip to content

Commit 01b488f

Browse files
Reapply "[CMake] Fold export_executable_symbols_* into function args. (#101741)" (#102138)
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.
1 parent e4e96b3 commit 01b488f

File tree

58 files changed

+70
-125
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+70
-125
lines changed

clang-tools-extra/clang-tidy/tool/CMakeLists.txt

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ clang_target_link_libraries(clangTidyMain
3333
# Support plugins.
3434
if(CLANG_PLUGIN_SUPPORT)
3535
set(support_plugins SUPPORT_PLUGINS)
36+
set(export_symbols EXPORT_SYMBOLS_FOR_PLUGINS)
3637
endif()
3738

3839
add_clang_tool(clang-tidy
@@ -41,6 +42,7 @@ add_clang_tool(clang-tidy
4142
DEPENDS
4243
clang-resource-headers
4344
${support_plugins}
45+
${export_symbols}
4446
)
4547
clang_target_link_libraries(clang-tidy
4648
PRIVATE
@@ -57,10 +59,6 @@ target_link_libraries(clang-tidy
5759
${ALL_CLANG_TIDY_CHECKS}
5860
)
5961

60-
if(CLANG_PLUGIN_SUPPORT)
61-
export_executable_symbols_for_plugins(clang-tidy)
62-
endif()
63-
6462
install(PROGRAMS clang-tidy-diff.py
6563
DESTINATION "${CMAKE_INSTALL_DATADIR}/clang"
6664
COMPONENT clang-tidy)

clang/cmake/modules/AddClang.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ macro(add_clang_tool name)
160160
AND (NOT LLVM_DISTRIBUTION_COMPONENTS OR ${name} IN_LIST LLVM_DISTRIBUTION_COMPONENTS)
161161
)
162162
set(get_obj_args ${ARGN})
163-
list(FILTER get_obj_args EXCLUDE REGEX "^SUPPORT_PLUGINS$")
163+
list(FILTER get_obj_args EXCLUDE REGEX "^(SUPPORT_PLUGINS|EXPORT_SYMBOLS_FOR_PLUGINS)$")
164164
generate_llvm_objects(${name} ${get_obj_args})
165165
add_custom_target(${name} DEPENDS llvm-driver clang-resource-headers)
166166
else()

clang/tools/clang-linker-wrapper/CMakeLists.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ add_clang_tool(clang-linker-wrapper
3131

3232
DEPENDS
3333
${tablegen_deps}
34+
EXPORT_SYMBOLS_FOR_PLUGINS
3435
)
3536

3637
set(CLANG_LINKER_WRAPPER_LIB_DEPS
@@ -41,5 +42,3 @@ target_link_libraries(clang-linker-wrapper
4142
PRIVATE
4243
${CLANG_LINKER_WRAPPER_LIB_DEPS}
4344
)
44-
45-
export_executable_symbols_for_plugins(clang-linker-wrapper)

clang/tools/clang-repl/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ set( LLVM_LINK_COMPONENTS
99

1010
add_clang_tool(clang-repl
1111
ClangRepl.cpp
12+
13+
EXPORT_SYMBOLS_FOR_PLUGINS
1214
)
1315

1416
if(MSVC)
@@ -61,8 +63,6 @@ clang_target_link_libraries(clang-repl PRIVATE
6163
clangInterpreter
6264
)
6365

64-
export_executable_symbols_for_plugins(clang-repl)
65-
6666
# The clang-repl binary can get huge with static linking in debug mode.
6767
# Some 32-bit targets use PLT slots with limited branch range by default and we
6868
# start to exceed this limit, e.g. when linking for arm-linux-gnueabihf with

clang/tools/driver/CMakeLists.txt

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ set( LLVM_LINK_COMPONENTS
2121
# Support plugins.
2222
if(CLANG_PLUGIN_SUPPORT)
2323
set(support_plugins SUPPORT_PLUGINS)
24+
set(export_symbols EXPORT_SYMBOLS_FOR_PLUGINS)
2425
endif()
2526

2627
add_clang_tool(clang
@@ -35,6 +36,7 @@ add_clang_tool(clang
3536
ARMTargetParserTableGen
3637
AArch64TargetParserTableGen
3738
${support_plugins}
39+
${export_symbols}
3840
GENERATE_DRIVER
3941
)
4042

@@ -54,11 +56,6 @@ else()
5456
set_target_properties(clang PROPERTIES VERSION ${CLANG_EXECUTABLE_VERSION})
5557
endif()
5658

57-
# Support plugins.
58-
if(CLANG_PLUGIN_SUPPORT)
59-
export_executable_symbols_for_plugins(clang)
60-
endif()
61-
6259
add_dependencies(clang clang-resource-headers)
6360

6461
if(NOT CLANG_LINKS_TO_CREATE)

clang/unittests/Interpreter/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ add_clang_unittest(ClangReplInterpreterTests
1313
InterpreterTest.cpp
1414
InterpreterExtensionsTest.cpp
1515
CodeCompletionTest.cpp
16+
17+
EXPORT_SYMBOLS
1618
)
1719
target_link_libraries(ClangReplInterpreterTests PUBLIC
1820
clangAST
@@ -28,8 +30,6 @@ if(NOT WIN32)
2830
add_subdirectory(ExceptionTests)
2931
endif()
3032

31-
export_executable_symbols(ClangReplInterpreterTests)
32-
3333
if(MSVC)
3434
set_target_properties(ClangReplInterpreterTests PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS 1)
3535

clang/unittests/Interpreter/ExceptionTests/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ set(LLVM_LINK_COMPONENTS
1212

1313
add_clang_unittest(ClangReplInterpreterExceptionTests
1414
InterpreterExceptionTest.cpp
15+
16+
EXPORT_SYMBOLS
1517
)
1618

1719
llvm_update_compile_flags(ClangReplInterpreterExceptionTests)
@@ -22,5 +24,3 @@ target_link_libraries(ClangReplInterpreterExceptionTests PUBLIC
2224
clangFrontend
2325
)
2426
add_dependencies(ClangReplInterpreterExceptionTests clang-resource-headers)
25-
26-
export_executable_symbols(ClangReplInterpreterExceptionTests)

flang/tools/flang-driver/CMakeLists.txt

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,18 @@ set( LLVM_LINK_COMPONENTS
1111
TargetParser
1212
)
1313

14+
option(FLANG_PLUGIN_SUPPORT "Build Flang with plugin support." ON)
15+
16+
# Enable support for plugins, which need access to symbols from flang-new
17+
if(FLANG_PLUGIN_SUPPORT)
18+
set(export_symbols EXPORT_SYMBOLS_FOR_PLUGINS)
19+
endif()
20+
1421
add_flang_tool(flang-new
1522
driver.cpp
1623
fc1_main.cpp
24+
25+
${export_symbols}
1726
)
1827

1928
target_link_libraries(flang-new
@@ -28,11 +37,4 @@ clang_target_link_libraries(flang-new
2837
clangBasic
2938
)
3039

31-
option(FLANG_PLUGIN_SUPPORT "Build Flang with plugin support." ON)
32-
33-
# Enable support for plugins, which need access to symbols from flang-new
34-
if(FLANG_PLUGIN_SUPPORT)
35-
export_executable_symbols_for_plugins(flang-new)
36-
endif()
37-
3840
install(TARGETS flang-new DESTINATION "${CMAKE_INSTALL_BINDIR}")

lld/cmake/modules/AddLLD.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ macro(add_lld_tool name)
4444
AND (NOT LLVM_DISTRIBUTION_COMPONENTS OR ${name} IN_LIST LLVM_DISTRIBUTION_COMPONENTS)
4545
)
4646
set(get_obj_args ${ARGN})
47-
list(FILTER get_obj_args EXCLUDE REGEX "^SUPPORT_PLUGINS$")
47+
list(FILTER get_obj_args EXCLUDE REGEX "^(SUPPORT_PLUGINS|EXPORT_SYMBOLS_FOR_PLUGINS)$")
4848
generate_llvm_objects(${name} ${get_obj_args})
4949
add_custom_target(${name} DEPENDS llvm-driver)
5050
else()

lld/tools/lld/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ add_lld_tool(lld
88

99
SUPPORT_PLUGINS
1010
GENERATE_DRIVER
11+
EXPORT_SYMBOLS_FOR_PLUGINS
1112
)
12-
export_executable_symbols_for_plugins(lld)
1313

1414
function(lld_target_link_libraries target type)
1515
if (TARGET obj.${target})

0 commit comments

Comments
 (0)