Skip to content

Commit 583f7a8

Browse files
[CMake] Fold export_executable_symbols_* into function args
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 9f1932b commit 583f7a8

File tree

43 files changed

+33
-88
lines changed

Some content is hidden

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

43 files changed

+33
-88
lines changed

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)

llvm/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1212,7 +1212,7 @@ if( ${CMAKE_SYSTEM_NAME} MATCHES SunOS )
12121212
endif( ${CMAKE_SYSTEM_NAME} MATCHES SunOS )
12131213

12141214
# Make sure we don't get -rdynamic in every binary. For those that need it,
1215-
# use export_executable_symbols(target).
1215+
# use EXPORT_SYMBOLS argument.
12161216
set(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "")
12171217

12181218
include(AddLLVM)
@@ -1253,7 +1253,7 @@ if( LLVM_INCLUDE_UTILS )
12531253
if( LLVM_INCLUDE_TESTS )
12541254
set(LLVM_SUBPROJECT_TITLE "Third-Party/Google Test")
12551255
add_subdirectory(${LLVM_THIRD_PARTY_DIR}/unittest ${CMAKE_CURRENT_BINARY_DIR}/third-party/unittest)
1256-
set(LLVM_SUBPROJECT_TITLE)
1256+
set(LLVM_SUBPROJECT_TITLE)
12571257
endif()
12581258
else()
12591259
if ( LLVM_INCLUDE_TESTS )

llvm/cmake/modules/AddLLVM.cmake

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1016,7 +1016,7 @@ endmacro()
10161016

10171017
macro(add_llvm_executable name)
10181018
cmake_parse_arguments(ARG
1019-
"DISABLE_LLVM_LINK_LLVM_DYLIB;IGNORE_EXTERNALIZE_DEBUGINFO;NO_INSTALL_RPATH;SUPPORT_PLUGINS"
1019+
"DISABLE_LLVM_LINK_LLVM_DYLIB;IGNORE_EXTERNALIZE_DEBUGINFO;NO_INSTALL_RPATH;SUPPORT_PLUGINS;EXPORT_SYMBOLS"
10201020
"ENTITLEMENTS;BUNDLE_PATH"
10211021
""
10221022
${ARGN})
@@ -1076,7 +1076,8 @@ macro(add_llvm_executable name)
10761076
endif(LLVM_EXPORTED_SYMBOL_FILE)
10771077

10781078
if (DEFINED LLVM_ENABLE_EXPORTED_SYMBOLS_IN_EXECUTABLES AND
1079-
NOT LLVM_ENABLE_EXPORTED_SYMBOLS_IN_EXECUTABLES)
1079+
NOT LLVM_ENABLE_EXPORTED_SYMBOLS_IN_EXECUTABLES AND
1080+
NOT ARG_EXPORT_SYMBOLS)
10801081
if(LLVM_LINKER_SUPPORTS_NO_EXPORTED_SYMBOLS)
10811082
set_property(TARGET ${name} APPEND_STRING PROPERTY
10821083
LINK_FLAGS " -Wl,-no_exported_symbols")
@@ -1117,6 +1118,10 @@ macro(add_llvm_executable name)
11171118
endif()
11181119

11191120
llvm_codesign(${name} ENTITLEMENTS ${ARG_ENTITLEMENTS} BUNDLE_PATH ${ARG_BUNDLE_PATH})
1121+
1122+
if (ARG_EXPORT_SYMBOLS)
1123+
export_executable_symbols(${name})
1124+
endif()
11201125
endmacro(add_llvm_executable name)
11211126

11221127
# add_llvm_pass_plugin(name [NO_MODULE] ...)
@@ -1469,7 +1474,7 @@ macro(add_llvm_example name)
14691474
if( NOT LLVM_BUILD_EXAMPLES )
14701475
set(EXCLUDE_FROM_ALL ON)
14711476
endif()
1472-
add_llvm_executable(${name} ${ARGN})
1477+
add_llvm_executable(${name} EXPORT_SYMBOLS ${ARGN})
14731478
if( LLVM_BUILD_EXAMPLES )
14741479
install(TARGETS ${name} RUNTIME DESTINATION "${LLVM_EXAMPLES_INSTALL_DIR}")
14751480
endif()

llvm/examples/ExceptionDemo/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@ endif()
1616

1717
add_llvm_example(ExceptionDemo
1818
ExceptionDemo.cpp
19-
)
2019

21-
export_executable_symbols(ExceptionDemo)
20+
EXPORT_SYMBOLS
21+
)

llvm/examples/HowToUseLLJIT/CMakeLists.txt

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

88
add_llvm_example(HowToUseLLJIT
99
HowToUseLLJIT.cpp
10-
)
1110

12-
export_executable_symbols(HowToUseLLJIT)
11+
EXPORT_SYMBOLS
12+
)

llvm/examples/Kaleidoscope/BuildingAJIT/Chapter1/CMakeLists.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,3 @@ set(LLVM_LINK_COMPONENTS
1414
add_kaleidoscope_chapter(BuildingAJIT-Ch1
1515
toy.cpp
1616
)
17-
18-
export_executable_symbols(BuildingAJIT-Ch1)

llvm/examples/Kaleidoscope/BuildingAJIT/Chapter2/CMakeLists.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,3 @@ set(LLVM_LINK_COMPONENTS
1414
add_kaleidoscope_chapter(BuildingAJIT-Ch2
1515
toy.cpp
1616
)
17-
18-
export_executable_symbols(BuildingAJIT-Ch2)

llvm/examples/Kaleidoscope/BuildingAJIT/Chapter3/CMakeLists.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,3 @@ set(LLVM_LINK_COMPONENTS
1515
add_kaleidoscope_chapter(BuildingAJIT-Ch3
1616
toy.cpp
1717
)
18-
19-
export_executable_symbols(BuildingAJIT-Ch3)

llvm/examples/Kaleidoscope/BuildingAJIT/Chapter4/CMakeLists.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,3 @@ set(LLVM_LINK_COMPONENTS
1515
add_kaleidoscope_chapter(BuildingAJIT-Ch4
1616
toy.cpp
1717
)
18-
19-
export_executable_symbols(BuildingAJIT-Ch4)

0 commit comments

Comments
 (0)