Author: David Spickett
Date: 2025-09-15T09:20:58+01:00
New Revision: e85926545e6313fd3c5c6147e82db42132c389ac

URL: 
https://github.com/llvm/llvm-project/commit/e85926545e6313fd3c5c6147e82db42132c389ac
DIFF: 
https://github.com/llvm/llvm-project/commit/e85926545e6313fd3c5c6147e82db42132c389ac.diff

LOG: [libcxx][CI] Use lld for everything in the ARM picolib builds (#158320)

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_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.

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.

Added: 
    

Modified: 
    libcxx/cmake/caches/Armv7M-picolibc.cmake
    libcxx/test/configs/armv7m-picolibc-libc++.cfg.in
    libcxx/utils/ci/build-picolibc.sh
    libcxxabi/test/configs/armv7m-picolibc-libc++abi.cfg.in
    libunwind/test/configs/armv7m-picolibc-libunwind.cfg.in

Removed: 
    


################################################################################
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'


        
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to