https://github.com/DavidSpickett created https://github.com/llvm/llvm-project/pull/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. 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. >From 4a3eb398dd1fad28160dd860476c6c642c8abf22 Mon Sep 17 00:00:00 2001 From: David Spickett <david.spick...@linaro.org> Date: Fri, 12 Sep 2025 15:54:58 +0000 Subject: [PATCH] [libcxx][CI] Use lld for everything in the ARM picolib builds 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. --- libcxx/cmake/caches/Armv7M-picolibc.cmake | 1 + libcxx/test/configs/armv7m-picolibc-libc++.cfg.in | 2 +- libcxx/utils/ci/build-picolibc.sh | 2 +- libcxxabi/test/configs/armv7m-picolibc-libc++abi.cfg.in | 2 +- libunwind/test/configs/armv7m-picolibc-libunwind.cfg.in | 2 +- 5 files changed, 5 insertions(+), 4 deletions(-) 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