[clang] [llvm] [CMake] Add a linker test for -Bsymbolic-functions to AddLLVM (PR #79539)
@@ -355,6 +349,9 @@ function(add_link_opts target_name)
set_property(TARGET ${target_name} APPEND_STRING PROPERTY
LINK_FLAGS " -Wl,-brtl")
endif()
+
+ check_linker_flag(CXX "-Wl,-Bsymbolic-functions"
christopherbate wrote:
Why was this `check_linker_flag` put inside `add_linker_opts` instead of at the
call site where it is actually used in the `llvm-shlib` target? This function
is called *every time LLVM creates a library*. Even after the first call when
the cache variable is populated, this function seems to have significant
overhead.
https://github.com/llvm/llvm-project/pull/79539
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [CMake] Add a linker test for -Bsymbolic-functions to AddLLVM (PR #79539)
@@ -355,6 +349,9 @@ function(add_link_opts target_name)
set_property(TARGET ${target_name} APPEND_STRING PROPERTY
LINK_FLAGS " -Wl,-brtl")
endif()
+
+ check_linker_flag(CXX "-Wl,-Bsymbolic-functions"
MaskRay wrote:
@mati865 This might be true for other, smaller projects, but for LLVM we have
to be careful introducing new checks.
https://discourse.llvm.org/t/cmake-compiler-flag-checks-are-really-slow-ideas-to-speed-them-up/78882
It could be slower on a slow device like NFS. For this single check_linker_flag
it might be fine.
https://github.com/llvm/llvm-project/pull/79539
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [CMake] Add a linker test for -Bsymbolic-functions to AddLLVM (PR #79539)
llvm-ci wrote: LLVM Buildbot has detected a new failure on builder `llvm-clang-x86_64-gcc-ubuntu-no-asserts` running on `doug-worker-6` while building `clang,llvm` at step 6 "test-build-unified-tree-check-all". Full details are available at: https://lab.llvm.org/buildbot/#/builders/202/builds/1313 Here is the relevant piece of the build log for the reference ``` Step 6 (test-build-unified-tree-check-all) failure: test (failure) TEST 'LLVM :: tools/dsymutil/X86/op-convert-offset.test' FAILED Exit Code: 1 Command Output (stdout): -- warning: /home/buildbot/buildbot-root/gcc-no-asserts/llvm-project/llvm/test/tools/dsymutil/X86/../Inputs/private/tmp/op-convert-offset/op-convert-offset.o: timestamp mismatch between object file (2025-03-11 17:27:45.671531848) and debug map (2022-07-12 20:49:30.0) warning: /home/buildbot/buildbot-root/gcc-no-asserts/llvm-project/llvm/test/tools/dsymutil/X86/../Inputs/private/tmp/op-convert-offset/op-convert-offset.o: timestamp mismatch between object file (2025-03-11 17:27:45.671531848) and debug map (2022-07-12 20:49:30.0) warning: cann't read address attribute value. note: while processing op-convert-offset1.c -- Command Output (stderr): -- /home/buildbot/buildbot-root/gcc-no-asserts/build/bin/dsymutil -oso-prepend-path /home/buildbot/buildbot-root/gcc-no-asserts/llvm-project/llvm/test/tools/dsymutil/X86/../Inputs /home/buildbot/buildbot-root/gcc-no-asserts/llvm-project/llvm/test/tools/dsymutil/X86/../Inputs/private/tmp/op-convert-offset/op-convert-offset -o /home/buildbot/buildbot-root/gcc-no-asserts/build/test/tools/dsymutil/X86/Output/op-convert-offset.test.tmp.dSYM 2>&1 # RUN: at line 23 + /home/buildbot/buildbot-root/gcc-no-asserts/build/bin/dsymutil -oso-prepend-path /home/buildbot/buildbot-root/gcc-no-asserts/llvm-project/llvm/test/tools/dsymutil/X86/../Inputs /home/buildbot/buildbot-root/gcc-no-asserts/llvm-project/llvm/test/tools/dsymutil/X86/../Inputs/private/tmp/op-convert-offset/op-convert-offset -o /home/buildbot/buildbot-root/gcc-no-asserts/build/test/tools/dsymutil/X86/Output/op-convert-offset.test.tmp.dSYM /home/buildbot/buildbot-root/gcc-no-asserts/build/bin/llvm-dwarfdump /home/buildbot/buildbot-root/gcc-no-asserts/llvm-project/llvm/test/tools/dsymutil/X86/../Inputs/private/tmp/op-convert-offset/op-convert-offset.o 2>&1 | /home/buildbot/buildbot-root/gcc-no-asserts/build/bin/FileCheck /home/buildbot/buildbot-root/gcc-no-asserts/llvm-project/llvm/test/tools/dsymutil/X86/op-convert-offset.test --check-prefix OBJ # RUN: at line 24 + /home/buildbot/buildbot-root/gcc-no-asserts/build/bin/llvm-dwarfdump /home/buildbot/buildbot-root/gcc-no-asserts/llvm-project/llvm/test/tools/dsymutil/X86/../Inputs/private/tmp/op-convert-offset/op-convert-offset.o + /home/buildbot/buildbot-root/gcc-no-asserts/build/bin/FileCheck /home/buildbot/buildbot-root/gcc-no-asserts/llvm-project/llvm/test/tools/dsymutil/X86/op-convert-offset.test --check-prefix OBJ /home/buildbot/buildbot-root/gcc-no-asserts/build/bin/llvm-dwarfdump /home/buildbot/buildbot-root/gcc-no-asserts/build/test/tools/dsymutil/X86/Output/op-convert-offset.test.tmp.dSYM 2>&1 | /home/buildbot/buildbot-root/gcc-no-asserts/build/bin/FileCheck /home/buildbot/buildbot-root/gcc-no-asserts/llvm-project/llvm/test/tools/dsymutil/X86/op-convert-offset.test --check-prefix DSYM # RUN: at line 25 + /home/buildbot/buildbot-root/gcc-no-asserts/build/bin/llvm-dwarfdump /home/buildbot/buildbot-root/gcc-no-asserts/build/test/tools/dsymutil/X86/Output/op-convert-offset.test.tmp.dSYM + /home/buildbot/buildbot-root/gcc-no-asserts/build/bin/FileCheck /home/buildbot/buildbot-root/gcc-no-asserts/llvm-project/llvm/test/tools/dsymutil/X86/op-convert-offset.test --check-prefix DSYM /home/buildbot/buildbot-root/gcc-no-asserts/build/bin/dsymutil --linker parallel -oso-prepend-path /home/buildbot/buildbot-root/gcc-no-asserts/llvm-project/llvm/test/tools/dsymutil/X86/../Inputs /home/buildbot/buildbot-root/gcc-no-asserts/llvm-project/llvm/test/tools/dsymutil/X86/../Inputs/private/tmp/op-convert-offset/op-convert-offset -o /home/buildbot/buildbot-root/gcc-no-asserts/build/test/tools/dsymutil/X86/Output/op-convert-offset.test.tmp.dSYM 2>&1 # RUN: at line 27 + /home/buildbot/buildbot-root/gcc-no-asserts/build/bin/dsymutil --linker parallel -oso-prepend-path /home/buildbot/buildbot-root/gcc-no-asserts/llvm-project/llvm/test/tools/dsymutil/X86/../Inputs /home/buildbot/buildbot-root/gcc-no-asserts/llvm-project/llvm/test/tools/dsymutil/X86/../Inputs/private/tmp/op-convert-offset/op-convert-offset -o /home/buildbot/buildbot-root/gcc-no-asserts/build/test/tools/dsymutil/X86/Output/op-convert-offset.test.tmp.dSYM /home/buildbot/buildbot-root/gcc-no-asserts/build/bin/llvm-dwarfdump /home/buildbot/buildbot-root/gcc-no-asserts/llvm-project/llvm/test/tools/dsymutil/X86/../Inputs/private/tmp/op-convert-offset/op-convert-offset.o 2>&1| /home
[clang] [llvm] [CMake] Add a linker test for -Bsymbolic-functions to AddLLVM (PR #79539)
https://github.com/brad0 closed https://github.com/llvm/llvm-project/pull/79539 ___ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [CMake] Add a linker test for -Bsymbolic-functions to AddLLVM (PR #79539)
https://github.com/jeremyd2019 approved this pull request. LGTM https://github.com/llvm/llvm-project/pull/79539 ___ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [CMake] Add a linker test for -Bsymbolic-functions to AddLLVM (PR #79539)
@@ -355,6 +349,9 @@ function(add_link_opts target_name)
set_property(TARGET ${target_name} APPEND_STRING PROPERTY
LINK_FLAGS " -Wl,-brtl")
endif()
+
+ check_linker_flag(CXX "-Wl,-Bsymbolic-functions"
mati865 wrote:
I'd argue it's much faster than autotools for other large projects. It would be
nice if the configuration phase could be parallelized, at least to some degree,
but even with a single thread, it's a matter of seconds.
https://github.com/llvm/llvm-project/pull/79539
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [CMake] Add a linker test for -Bsymbolic-functions to AddLLVM (PR #79539)
https://github.com/MaskRay edited https://github.com/llvm/llvm-project/pull/79539 ___ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [CMake] Add a linker test for -Bsymbolic-functions to AddLLVM (PR #79539)
@@ -355,6 +349,9 @@ function(add_link_opts target_name)
set_property(TARGET ${target_name} APPEND_STRING PROPERTY
LINK_FLAGS " -Wl,-brtl")
endif()
+
+ check_linker_flag(CXX "-Wl,-Bsymbolic-functions"
MaskRay wrote:
While I am aware of https://ewontfix.com/13/ ("Incorrect configure checks for
availability of functions"), there have been many cmake changes to skip some
checks that are guaranteed to succeed, to make cmake run faster (llvm's cmake
is really slow). I wonder whether there is a condition that can skip the check
for systems that always have -Bsymbolic-functions.
https://github.com/llvm/llvm-project/pull/79539
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [CMake] Add a linker test for -Bsymbolic-functions to AddLLVM (PR #79539)
brad0 wrote: Added a comment. https://github.com/llvm/llvm-project/pull/79539 ___ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [CMake] Add a linker test for -Bsymbolic-functions to AddLLVM (PR #79539)
@@ -355,6 +349,9 @@ function(add_link_opts target_name)
set_property(TARGET ${target_name} APPEND_STRING PROPERTY
LINK_FLAGS " -Wl,-brtl")
endif()
+
+ check_linker_flag(CXX "-Wl,-Bsymbolic-functions"
rorth wrote:
**Please** don't go this route: it makes feature tests completely
unmaintainable. Consider the Solaris case where initially only `/bin/ld` was
supported which didn't accept `-Bsymbolic-functions`. Only later when GNU `ld`
became an alternative linker that one **would** support that option. How on
earth is one supposed to know that I now have to revise the cmake check to
detect this if it were restricted to some platforms?
https://github.com/llvm/llvm-project/pull/79539
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [CMake] Add a linker test for -Bsymbolic-functions to AddLLVM (PR #79539)
@@ -355,6 +349,9 @@ function(add_link_opts target_name)
set_property(TARGET ${target_name} APPEND_STRING PROPERTY
LINK_FLAGS " -Wl,-brtl")
endif()
+
+ check_linker_flag(CXX "-Wl,-Bsymbolic-functions"
MaskRay wrote:
Add a comment what targets may need the -Wl,-Bsymbolic-functions check?
While configure is right, llvm cmake is so complex and so slow that many
contributors want to optimize the number of compile/linke checks. I would still
hope that we only do this on targets that actually need it.
https://github.com/llvm/llvm-project/pull/79539
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [CMake] Add a linker test for -Bsymbolic-functions to AddLLVM (PR #79539)
https://github.com/brad0 updated https://github.com/llvm/llvm-project/pull/79539
>From 03859cb1b4eb4132c831fdc8a36909df2981292d Mon Sep 17 00:00:00 2001
From: Brad Smith
Date: Thu, 25 Jan 2024 16:20:47 -0500
Subject: [PATCH] [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.
---
clang/tools/clang-shlib/CMakeLists.txt | 2 +-
llvm/cmake/modules/AddLLVM.cmake | 11 ---
llvm/tools/llvm-shlib/CMakeLists.txt | 2 +-
3 files changed, 6 insertions(+), 9 deletions(-)
diff --git a/clang/tools/clang-shlib/CMakeLists.txt
b/clang/tools/clang-shlib/CMakeLists.txt
index 317964de4fb17..945076e1ad810 100644
--- a/clang/tools/clang-shlib/CMakeLists.txt
+++ b/clang/tools/clang-shlib/CMakeLists.txt
@@ -57,7 +57,7 @@ endif()
# Optimize function calls for default visibility definitions to avoid PLT and
# reduce dynamic relocations.
-if (NOT APPLE AND NOT MINGW AND NOT CYGWIN AND NOT
LLVM_LINKER_IS_SOLARISLD_ILLUMOS)
+if (NOT APPLE AND LLVM_LINKER_SUPPORTS_B_SYMBOLIC_FUNCTIONS)
target_link_options(clang-cpp PRIVATE LINKER:-Bsymbolic-functions)
endif()
if (MINGW OR CYGWIN)
diff --git a/llvm/cmake/modules/AddLLVM.cmake b/llvm/cmake/modules/AddLLVM.cmake
index 52bf7ca0906a3..70da261293011 100644
--- a/llvm/cmake/modules/AddLLVM.cmake
+++ b/llvm/cmake/modules/AddLLVM.cmake
@@ -257,12 +257,6 @@ if (NOT DEFINED LLVM_LINKER_DETECTED AND NOT WIN32)
set(LLVM_LINKER_DETECTED YES CACHE INTERNAL "")
set(LLVM_LINKER_IS_GNULD YES CACHE INTERNAL "")
message(STATUS "Linker detection: GNU ld")
-elseif("${stderr}" MATCHES "(illumos)" OR
- "${stdout}" MATCHES "(illumos)")
- set(LLVM_LINKER_DETECTED YES CACHE INTERNAL "")
- set(LLVM_LINKER_IS_SOLARISLD YES CACHE INTERNAL "")
- set(LLVM_LINKER_IS_SOLARISLD_ILLUMOS YES CACHE INTERNAL "")
- message(STATUS "Linker detection: Solaris ld (illumos)")
elseif("${stderr}" MATCHES "Solaris Link Editors" OR
"${stdout}" MATCHES "Solaris Link Editors")
set(LLVM_LINKER_DETECTED YES CACHE INTERNAL "")
@@ -296,6 +290,7 @@ if (NOT DEFINED LLVM_LINKER_DETECTED AND NOT WIN32)
endif()
function(add_link_opts target_name)
+ include(CheckLinkerFlag)
get_llvm_distribution(${target_name} in_distribution in_distribution_var)
if(NOT in_distribution)
# Don't LTO optimize targets that aren't part of any distribution.
@@ -327,7 +322,6 @@ function(add_link_opts target_name)
elseif(${CMAKE_SYSTEM_NAME} MATCHES "SunOS" AND LLVM_LINKER_IS_SOLARISLD)
# Support for ld -z discard-unused=sections was only added in
# Solaris 11.4. GNU ld ignores it, but warns every time.
-include(CheckLinkerFlag)
check_linker_flag(CXX "-Wl,-z,discard-unused=sections"
LINKER_SUPPORTS_Z_DISCARD_UNUSED)
if (LINKER_SUPPORTS_Z_DISCARD_UNUSED)
set_property(TARGET ${target_name} APPEND_STRING PROPERTY
@@ -355,6 +349,9 @@ function(add_link_opts target_name)
set_property(TARGET ${target_name} APPEND_STRING PROPERTY
LINK_FLAGS " -Wl,-brtl")
endif()
+
+ check_linker_flag(CXX "-Wl,-Bsymbolic-functions"
+LLVM_LINKER_SUPPORTS_B_SYMBOLIC_FUNCTIONS)
endfunction(add_link_opts)
# Set each output directory according to ${CMAKE_CONFIGURATION_TYPES}.
diff --git a/llvm/tools/llvm-shlib/CMakeLists.txt
b/llvm/tools/llvm-shlib/CMakeLists.txt
index 4968c4e24e15b..089255f361045 100644
--- a/llvm/tools/llvm-shlib/CMakeLists.txt
+++ b/llvm/tools/llvm-shlib/CMakeLists.txt
@@ -70,7 +70,7 @@ if(LLVM_BUILD_LLVM_DYLIB)
# Solaris ld does not accept global: *; so there is no way to version
*all* global symbols
set(LIB_NAMES
-Wl,--version-script,${LLVM_LIBRARY_DIR}/tools/llvm-shlib/simple_version_script.map
${LIB_NAMES})
endif()
- if (NOT MINGW AND NOT LLVM_LINKER_IS_SOLARISLD_ILLUMOS)
+ if (LLVM_LINKER_SUPPORTS_B_SYMBOLIC_FUNCTIONS)
# Optimize function calls for default visibility definitions to avoid
PLT and
# reduce dynamic relocations.
# Note: for -fno-pic default, the address of a function may be
different from
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [CMake] Add a linker test for -Bsymbolic-functions to AddLLVM (PR #79539)
brad0 wrote: @rorth Thanks. It was more so the native linker I wasn't sure about. https://github.com/llvm/llvm-project/pull/79539 ___ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [CMake] Add a linker test for -Bsymbolic-functions to AddLLVM (PR #79539)
rorth wrote:
> @rorth Can you please check this on Solaris?
I've now tested the patch on `amd64-pc-solaris2.11` with both the native linker
(which doesn't support` -Bsymbolic-functions`) and GNU `ld` (which does) as
well as `sparcv9-sun-solaris2.11` with `/bin/ld`: no regressions on either,
with the exception of the `gld` case: I get a failure in `Flang ::
Driver/dynamic-linker.f90` which is unrelated, though: when configured with
`-DCLANG_DEFAULT_LINKER=gld`, the test has
```
+
/var/llvm/local-amd64-release-stage2-A-flang-openmp-gcc14-gld/tools/clang/stage2-bins/bin/flang
-### --target=x86_64-windows-msvc -rpath /path/to/dir -shared -static
/vol/llvm/src/llvm-project/local/flang/test/Driver/dynamic-linker.f90
+
/var/llvm/local-amd64-release-stage2-A-flang-openmp-gcc14-gld/tools/clang/stage2-bins/bin/FileCheck
--check-prefixes=MSVC-LINKER-OPTIONS
--implicit-check-not=MSVC-LINKER-OPTIONS-NOT
/vol/llvm/src/llvm-project/local/flang/test/Driver/dynamic-linker.f90
/vol/llvm/src/llvm-project/local/flang/test/Driver/dynamic-linker.f90:24:24:
error: MSVC-LINKER-OPTIONS: expected string not found in input
! MSVC-LINKER-OPTIONS: "{{.*}}link{{(.exe)?}}"
^
```
while `flang` emits
```
7: "/usr/bin/gld" "-out:a.exe" "-libpath:lib/amd64"
"-libpath:atlmfc/lib/amd64"
"-libpath:/var/llvm/local-amd64-release-stage2-A-flang-openmp-gcc14-gld/tools/clang/stage2-bins/lib"
"/subsystem:console" "-nologo" "-dll" "-implib:a.lib" "-rpath" "/path/to/dir"
"/tmp/lit-tmp-s10rro7u/dynamic-linker-074508.o"
```
https://github.com/llvm/llvm-project/pull/79539
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [CMake] Add a linker test for -Bsymbolic-functions to AddLLVM (PR #79539)
brad0 wrote: @rorth Can you please check this on Solaris? https://github.com/llvm/llvm-project/pull/79539 ___ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [CMake] Add a linker test for -Bsymbolic-functions to AddLLVM (PR #79539)
@@ -314,6 +308,11 @@ function(add_link_opts target_name)
set_property(TARGET ${target_name} APPEND_STRING PROPERTY
LINK_FLAGS " -Wl,-brtl")
endif()
+
+ if (NOT MINGW)
+llvm_check_linker_flag(CXX "-Wl,-Bsymbolic-functions"
+ LINKER_SUPPORTS_B_SYMBOLIC_FUNCTIONS)
+ endif()
jeremyd2019 wrote:
BFD accepts `-Bsymbolic-functions` but it's a no-op for anything other than
ELF. LLD rejects the option as unknown in the MinGW driver. So it would be
fine to remove the `if (NOT MINGW)` wrapping that, and let it use the flag or
not depending on whether the linker accepts it.
https://github.com/llvm/llvm-project/pull/79539
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [CMake] Add a linker test for -Bsymbolic-functions to AddLLVM (PR #79539)
@@ -314,6 +308,11 @@ function(add_link_opts target_name)
set_property(TARGET ${target_name} APPEND_STRING PROPERTY
LINK_FLAGS " -Wl,-brtl")
endif()
+
+ if (NOT MINGW)
+llvm_check_linker_flag(CXX "-Wl,-Bsymbolic-functions"
+ LINKER_SUPPORTS_B_SYMBOLIC_FUNCTIONS)
+ endif()
brad0 wrote:
That didn't make any sense to me. Which ```if``` and which PR?
https://github.com/llvm/llvm-project/pull/79539
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [CMake] Add a linker test for -Bsymbolic-functions to AddLLVM (PR #79539)
@@ -314,6 +308,11 @@ function(add_link_opts target_name)
set_property(TARGET ${target_name} APPEND_STRING PROPERTY
LINK_FLAGS " -Wl,-brtl")
endif()
+
+ if (NOT MINGW)
+llvm_check_linker_flag(CXX "-Wl,-Bsymbolic-functions"
+ LINKER_SUPPORTS_B_SYMBOLIC_FUNCTIONS)
+ endif()
mati865 wrote:
This `if` is unnecessary thanks to this PR.
https://github.com/llvm/llvm-project/pull/79539
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [CMake] Add a linker test for -Bsymbolic-functions to AddLLVM (PR #79539)
jeremyd2019 wrote: This would be nice for Cygwin as well. It seems GNU ld just silently ignores `-Bsymbolic-functions` there, but the lld mingw driver rejects it. https://github.com/llvm/llvm-project/pull/79539 ___ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [CMake] Add a linker test for -Bsymbolic-functions to AddLLVM (PR #79539)
brad0 wrote: > What's the issue? GNU ld has had -Bsymbolic-functions since 2007 and for > quite a few releases LLVM has been using `-Bsymbolic-functions`. This is binutils 2.17. We've had patches for awhile in our tree too specifically for the exceptions not using LLD. https://github.com/llvm/llvm-project/pull/79539 ___ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [CMake] Add a linker test for -Bsymbolic-functions to AddLLVM (PR #79539)
MaskRay wrote: > OpenBSD also has a local patch for linking with the old BFD linker on mips64 > and sparc64. What's the issue? GNU ld has had -Bsymbolic-functions since 2007 and for quite a few releases LLVM has been using `-Bsymbolic-functions`. https://github.com/llvm/llvm-project/pull/79539 ___ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [CMake] Add a linker test for -Bsymbolic-functions to AddLLVM (PR #79539)
https://github.com/brad0 updated https://github.com/llvm/llvm-project/pull/79539
>From 024e972034d5e6a91157feeba30cc76368819b8f Mon Sep 17 00:00:00 2001
From: Brad Smith
Date: Thu, 25 Jan 2024 16:20:47 -0500
Subject: [PATCH] [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.
---
clang/tools/clang-shlib/CMakeLists.txt | 2 +-
llvm/cmake/modules/AddLLVM.cmake | 13 ++---
llvm/tools/llvm-shlib/CMakeLists.txt | 2 +-
3 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/clang/tools/clang-shlib/CMakeLists.txt
b/clang/tools/clang-shlib/CMakeLists.txt
index 298d3a9d18fec8..6afd3efebe53a0 100644
--- a/clang/tools/clang-shlib/CMakeLists.txt
+++ b/clang/tools/clang-shlib/CMakeLists.txt
@@ -50,7 +50,7 @@ add_clang_library(clang-cpp
${_DEPS})
# Optimize function calls for default visibility definitions to avoid PLT and
# reduce dynamic relocations.
-if (NOT APPLE AND NOT MINGW AND NOT LLVM_LINKER_IS_SOLARISLD_ILLUMOS)
+if (NOT APPLE AND LINKER_SUPPORTS_B_SYMBOLIC_FUNCTIONS)
target_link_options(clang-cpp PRIVATE LINKER:-Bsymbolic-functions)
endif()
if (MINGW OR CYGWIN)
diff --git a/llvm/cmake/modules/AddLLVM.cmake b/llvm/cmake/modules/AddLLVM.cmake
index 5e989618552824..a030489b619602 100644
--- a/llvm/cmake/modules/AddLLVM.cmake
+++ b/llvm/cmake/modules/AddLLVM.cmake
@@ -241,12 +241,6 @@ if (NOT DEFINED LLVM_LINKER_DETECTED AND NOT WIN32)
set(LLVM_LINKER_DETECTED YES CACHE INTERNAL "")
set(LLVM_LINKER_IS_GNULD YES CACHE INTERNAL "")
message(STATUS "Linker detection: GNU ld")
-elseif("${stderr}" MATCHES "(illumos)" OR
- "${stdout}" MATCHES "(illumos)")
- set(LLVM_LINKER_DETECTED YES CACHE INTERNAL "")
- set(LLVM_LINKER_IS_SOLARISLD YES CACHE INTERNAL "")
- set(LLVM_LINKER_IS_SOLARISLD_ILLUMOS YES CACHE INTERNAL "")
- message(STATUS "Linker detection: Solaris ld (illumos)")
elseif("${stderr}" MATCHES "Solaris Link Editors" OR
"${stdout}" MATCHES "Solaris Link Editors")
set(LLVM_LINKER_DETECTED YES CACHE INTERNAL "")
@@ -260,6 +254,7 @@ if (NOT DEFINED LLVM_LINKER_DETECTED AND NOT WIN32)
endif()
function(add_link_opts target_name)
+ include(LLVMCheckLinkerFlag)
get_llvm_distribution(${target_name} in_distribution in_distribution_var)
if(NOT in_distribution)
# Don't LTO optimize targets that aren't part of any distribution.
@@ -291,7 +286,6 @@ function(add_link_opts target_name)
elseif(${CMAKE_SYSTEM_NAME} MATCHES "SunOS" AND LLVM_LINKER_IS_SOLARISLD)
# Support for ld -z discard-unused=sections was only added in
# Solaris 11.4. GNU ld ignores it, but warns every time.
-include(LLVMCheckLinkerFlag)
llvm_check_linker_flag(CXX "-Wl,-z,discard-unused=sections"
LINKER_SUPPORTS_Z_DISCARD_UNUSED)
if (LINKER_SUPPORTS_Z_DISCARD_UNUSED)
set_property(TARGET ${target_name} APPEND_STRING PROPERTY
@@ -314,6 +308,11 @@ function(add_link_opts target_name)
set_property(TARGET ${target_name} APPEND_STRING PROPERTY
LINK_FLAGS " -Wl,-brtl")
endif()
+
+ if (NOT MINGW)
+llvm_check_linker_flag(CXX "-Wl,-Bsymbolic-functions"
+ LINKER_SUPPORTS_B_SYMBOLIC_FUNCTIONS)
+ endif()
endfunction(add_link_opts)
# Set each output directory according to ${CMAKE_CONFIGURATION_TYPES}.
diff --git a/llvm/tools/llvm-shlib/CMakeLists.txt
b/llvm/tools/llvm-shlib/CMakeLists.txt
index a47a0ec84c625c..3e08dd5459a3f1 100644
--- a/llvm/tools/llvm-shlib/CMakeLists.txt
+++ b/llvm/tools/llvm-shlib/CMakeLists.txt
@@ -49,7 +49,7 @@ if(LLVM_BUILD_LLVM_DYLIB)
# Solaris ld does not accept global: *; so there is no way to version
*all* global symbols
set(LIB_NAMES
-Wl,--version-script,${LLVM_LIBRARY_DIR}/tools/llvm-shlib/simple_version_script.map
${LIB_NAMES})
endif()
-if (NOT MINGW AND NOT LLVM_LINKER_IS_SOLARISLD_ILLUMOS)
+if (LINKER_SUPPORTS_B_SYMBOLIC_FUNCTIONS)
# Optimize function calls for default visibility definitions to avoid
PLT and
# reduce dynamic relocations.
# Note: for -fno-pic default, the address of a function may be different
from
___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
