Skip to content

Commit a3bb9c2

Browse files
authored
[cmake] Prevent implicitly passing -no_exported_symbols (#87846)
* It is possible to setup llvm-project builds without going through `llvm/CMakeList.txt` so the fatal error handling should be smarter. * Disable option on Apple style lldb-linux builds.
1 parent 10b1864 commit a3bb9c2

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

lldb/cmake/caches/Apple-lldb-Linux.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
include(${CMAKE_CURRENT_LIST_DIR}/Apple-lldb-base.cmake)
2+
set(LLVM_ENABLE_EXPORTED_SYMBOLS_IN_EXECUTABLES ON CACHE BOOL "")
23

34
set(LLVM_DISTRIBUTION_COMPONENTS
45
lldb

llvm/cmake/modules/AddLLVM.cmake

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1038,9 +1038,15 @@ macro(add_llvm_executable name)
10381038
add_llvm_symbol_exports( ${name} ${LLVM_EXPORTED_SYMBOL_FILE} )
10391039
endif(LLVM_EXPORTED_SYMBOL_FILE)
10401040

1041-
if (NOT LLVM_ENABLE_EXPORTED_SYMBOLS_IN_EXECUTABLES AND LLVM_LINKER_SUPPORTS_NO_EXPORTED_SYMBOLS)
1041+
if (DEFINED LLVM_ENABLE_EXPORTED_SYMBOLS_IN_EXECUTABLES AND
1042+
NOT LLVM_ENABLE_EXPORTED_SYMBOLS_IN_EXECUTABLES)
1043+
if(LLVM_LINKER_SUPPORTS_NO_EXPORTED_SYMBOLS)
10421044
set_property(TARGET ${name} APPEND_STRING PROPERTY
10431045
LINK_FLAGS " -Wl,-no_exported_symbols")
1046+
else()
1047+
message(FATAL_ERROR
1048+
"LLVM_ENABLE_EXPORTED_SYMBOLS_IN_EXECUTABLES cannot be disabled when linker does not support \"-no_exported_symbols\"")
1049+
endif()
10441050
endif()
10451051

10461052
if (LLVM_LINK_LLVM_DYLIB AND NOT ARG_DISABLE_LLVM_LINK_LLVM_DYLIB)

0 commit comments

Comments
 (0)