-
Notifications
You must be signed in to change notification settings - Fork 15.3k
[libcxx][CI] Use lld for everything in the ARM picolib builds #158320
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Our host compiler is a clang install that will default to ld if not told otherwise. We were telling meson to use lld, but the way that we did it was outdated, which lead to picolib producing a linker script that lld could not use. Using the `c_ld` setting fixes this problem. See: https://mesonbuild.com/Machine-files.html#binaries Then to use lld in tests we need `-fuse-ld=lld` in the config files.
|
@llvm/pr-subscribers-libcxxabi @llvm/pr-subscribers-libcxx Author: David Spickett (DavidSpickett) ChangesOur host compiler is a clang install that will default to ld if not told otherwise. We were telling meson to use lld, but the way that we did it was outdated, which lead to picolib producing a linker script that lld could not use. The tests were in fact linking with ld instead. Using the Then to use lld in tests we need Full diff: https://github.com/llvm/llvm-project/pull/158320.diff 5 Files Affected:
diff --git a/libcxx/cmake/caches/Armv7M-picolibc.cmake b/libcxx/cmake/caches/Armv7M-picolibc.cmake
index 0f8189b457285..9df71fba2cadd 100644
--- a/libcxx/cmake/caches/Armv7M-picolibc.cmake
+++ b/libcxx/cmake/caches/Armv7M-picolibc.cmake
@@ -5,6 +5,7 @@ set(CMAKE_C_COMPILER_TARGET "armv7m-none-eabi" CACHE STRING "")
set(CMAKE_C_FLAGS "-mfloat-abi=soft" CACHE STRING "")
set(CMAKE_SYSTEM_NAME Generic CACHE STRING "")
set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY CACHE STRING "")
+set(LLVM_USE_LINKER "lld" CACHE STRING "")
set(COMPILER_RT_BAREMETAL_BUILD ON CACHE BOOL "")
set(COMPILER_RT_BUILD_LIBFUZZER OFF CACHE BOOL "")
set(COMPILER_RT_BUILD_PROFILE OFF CACHE BOOL "")
diff --git a/libcxx/test/configs/armv7m-picolibc-libc++.cfg.in b/libcxx/test/configs/armv7m-picolibc-libc++.cfg.in
index 9bff5021494ef..b2669a713e2c0 100644
--- a/libcxx/test/configs/armv7m-picolibc-libc++.cfg.in
+++ b/libcxx/test/configs/armv7m-picolibc-libc++.cfg.in
@@ -13,7 +13,7 @@ config.substitutions.append(('%{compile_flags}',
' -Wno-atomic-alignment'
))
config.substitutions.append(('%{link_flags}',
- '-nostdlib -nostdlib++ -L %{lib-dir} -lc++ -lc++abi'
+ '-fuse-ld=lld -nostdlib -nostdlib++ -L %{lib-dir} -lc++ -lc++abi'
' -lc -lm -lclang_rt.builtins -lsemihost -lcrt0-semihost' +
' -T {}'.format(libc_linker_script) +
' -Wl,--defsym=__flash=0x0'
diff --git a/libcxx/utils/ci/build-picolibc.sh b/libcxx/utils/ci/build-picolibc.sh
index 521c1bef9fc7e..4be768d741230 100755
--- a/libcxx/utils/ci/build-picolibc.sh
+++ b/libcxx/utils/ci/build-picolibc.sh
@@ -81,7 +81,7 @@ cat <<EOF > "${picolibc_build_dir}/meson-cross-build.txt"
c = ['${CC:-cc}', '--target=${target}', '-mfloat-abi=soft', '-nostdlib']
ar = 'llvm-ar'
as = 'llvm-as'
-ld = 'lld'
+c_ld = 'lld'
strip = 'llvm-strip'
[host_machine]
system = 'none'
diff --git a/libcxxabi/test/configs/armv7m-picolibc-libc++abi.cfg.in b/libcxxabi/test/configs/armv7m-picolibc-libc++abi.cfg.in
index b4744f935ad85..0594ba4ce89b7 100644
--- a/libcxxabi/test/configs/armv7m-picolibc-libc++abi.cfg.in
+++ b/libcxxabi/test/configs/armv7m-picolibc-libc++abi.cfg.in
@@ -8,7 +8,7 @@ config.substitutions.append(('%{compile_flags}',
'-nostdinc++ -I %{include} -I %{cxx-include} -I %{cxx-target-include} %{maybe-include-libunwind} -I %{libcxx}/test/support -I %{libcxx}/src -D_LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS'
))
config.substitutions.append(('%{link_flags}',
- '-nostdlib -nostdlib++ -L %{lib} -lc++ -lc++abi'
+ '-fuse-ld=lld -nostdlib -nostdlib++ -L %{lib} -lc++ -lc++abi'
' -lc -lm -lclang_rt.builtins -lsemihost -lcrt0-semihost' +
' -T {}'.format(libc_linker_script) +
' -Wl,--defsym=__flash=0x0'
diff --git a/libunwind/test/configs/armv7m-picolibc-libunwind.cfg.in b/libunwind/test/configs/armv7m-picolibc-libunwind.cfg.in
index e8f68a51fc53f..fc54900e1e0a1 100644
--- a/libunwind/test/configs/armv7m-picolibc-libunwind.cfg.in
+++ b/libunwind/test/configs/armv7m-picolibc-libunwind.cfg.in
@@ -8,7 +8,7 @@ config.substitutions.append(('%{compile_flags}',
'-nostdinc++ -I %{include}'
))
config.substitutions.append(('%{link_flags}',
- '-nostdlib -nostdlib++ -L %{lib} -lunwind'
+ '-fuse-ld=lld -nostdlib -nostdlib++ -L %{lib} -lunwind'
' -lc -lm -lclang_rt.builtins -lsemihost -lcrt0-semihost' +
' -T {}'.format(libc_linker_script) +
' -Wl,--defsym=__flash=0x0'
|
|
Did not expect this to be so neat, so this PR is an alternative to #158300. I think using lld throughout is simpler, and better represents how you'd be cross compiling in most situations including Arm's toolchains. |
|
It is unfortunate that picolibc can't ship with a linker script that works with both ld.lld and ld.bfd. I think building with lld makes the most sense here. |
philnik777
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm happy with this if it's the preferred way to build things for picolibc.
It matches what Arm is doing with picolibc, and I think we always intended to use lld anyway but didn't realise we had to enable it when testing. And a nice bonus is that since we can install lld anywhere, this "ARM" build can now be portable to other hosts. The MacOS builds failed but as nothing else failed, and these changes are isolated to picolibc builds, I'm going to merge this now. |
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/72/builds/15071 Here is the relevant piece of the build log for the reference |
Our host compiler is a clang install that will default to ld if not told otherwise.
We were telling meson to use lld, but the way that we did it was outdated, which lead to picolib producing a linker script that lld could not use. The tests were in fact linking with ld instead.
Using the
c_ldsetting fixes this problem. See:https://mesonbuild.com/Machine-files.html#binaries
Then to use lld in tests we need
-fuse-ld=lldin the config files.Some of these options were not needed for clang 19.1.7, but were for clang 21.1.1. We will soon update to 21.1.1 so I have included all of the required options in this PR.