Skip to content

Commit 024e972

Browse files
committed
[CMake] Add a linker test for -Bsymbolic-functions to AddLLVM
Add a linker test for -Bsymbolic-functions to AddLLVM and remove the illumos hardcoded bits for its handling. OpenBSD also has a local patch for linking with the old BFD linker on mips64 and sparc64.
1 parent 23b233c commit 024e972

File tree

3 files changed

+8
-9
lines changed

3 files changed

+8
-9
lines changed

clang/tools/clang-shlib/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ add_clang_library(clang-cpp
5050
${_DEPS})
5151
# Optimize function calls for default visibility definitions to avoid PLT and
5252
# reduce dynamic relocations.
53-
if (NOT APPLE AND NOT MINGW AND NOT LLVM_LINKER_IS_SOLARISLD_ILLUMOS)
53+
if (NOT APPLE AND LINKER_SUPPORTS_B_SYMBOLIC_FUNCTIONS)
5454
target_link_options(clang-cpp PRIVATE LINKER:-Bsymbolic-functions)
5555
endif()
5656
if (MINGW OR CYGWIN)

llvm/cmake/modules/AddLLVM.cmake

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -241,12 +241,6 @@ if (NOT DEFINED LLVM_LINKER_DETECTED AND NOT WIN32)
241241
set(LLVM_LINKER_DETECTED YES CACHE INTERNAL "")
242242
set(LLVM_LINKER_IS_GNULD YES CACHE INTERNAL "")
243243
message(STATUS "Linker detection: GNU ld")
244-
elseif("${stderr}" MATCHES "(illumos)" OR
245-
"${stdout}" MATCHES "(illumos)")
246-
set(LLVM_LINKER_DETECTED YES CACHE INTERNAL "")
247-
set(LLVM_LINKER_IS_SOLARISLD YES CACHE INTERNAL "")
248-
set(LLVM_LINKER_IS_SOLARISLD_ILLUMOS YES CACHE INTERNAL "")
249-
message(STATUS "Linker detection: Solaris ld (illumos)")
250244
elseif("${stderr}" MATCHES "Solaris Link Editors" OR
251245
"${stdout}" MATCHES "Solaris Link Editors")
252246
set(LLVM_LINKER_DETECTED YES CACHE INTERNAL "")
@@ -260,6 +254,7 @@ if (NOT DEFINED LLVM_LINKER_DETECTED AND NOT WIN32)
260254
endif()
261255

262256
function(add_link_opts target_name)
257+
include(LLVMCheckLinkerFlag)
263258
get_llvm_distribution(${target_name} in_distribution in_distribution_var)
264259
if(NOT in_distribution)
265260
# Don't LTO optimize targets that aren't part of any distribution.
@@ -291,7 +286,6 @@ function(add_link_opts target_name)
291286
elseif(${CMAKE_SYSTEM_NAME} MATCHES "SunOS" AND LLVM_LINKER_IS_SOLARISLD)
292287
# Support for ld -z discard-unused=sections was only added in
293288
# Solaris 11.4. GNU ld ignores it, but warns every time.
294-
include(LLVMCheckLinkerFlag)
295289
llvm_check_linker_flag(CXX "-Wl,-z,discard-unused=sections" LINKER_SUPPORTS_Z_DISCARD_UNUSED)
296290
if (LINKER_SUPPORTS_Z_DISCARD_UNUSED)
297291
set_property(TARGET ${target_name} APPEND_STRING PROPERTY
@@ -314,6 +308,11 @@ function(add_link_opts target_name)
314308
set_property(TARGET ${target_name} APPEND_STRING PROPERTY
315309
LINK_FLAGS " -Wl,-brtl")
316310
endif()
311+
312+
if (NOT MINGW)
313+
llvm_check_linker_flag(CXX "-Wl,-Bsymbolic-functions"
314+
LINKER_SUPPORTS_B_SYMBOLIC_FUNCTIONS)
315+
endif()
317316
endfunction(add_link_opts)
318317

319318
# Set each output directory according to ${CMAKE_CONFIGURATION_TYPES}.

llvm/tools/llvm-shlib/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ if(LLVM_BUILD_LLVM_DYLIB)
4949
# Solaris ld does not accept global: *; so there is no way to version *all* global symbols
5050
set(LIB_NAMES -Wl,--version-script,${LLVM_LIBRARY_DIR}/tools/llvm-shlib/simple_version_script.map ${LIB_NAMES})
5151
endif()
52-
if (NOT MINGW AND NOT LLVM_LINKER_IS_SOLARISLD_ILLUMOS)
52+
if (LINKER_SUPPORTS_B_SYMBOLIC_FUNCTIONS)
5353
# Optimize function calls for default visibility definitions to avoid PLT and
5454
# reduce dynamic relocations.
5555
# Note: for -fno-pic default, the address of a function may be different from

0 commit comments

Comments
 (0)