Skip to content

Commit 7643092

Browse files
committed
[libcxx][CI] Prepare ARM Picolib builds for upgrade to clang 21
Some time between Clang 19 and Clang 21, changes were made to the bare metal toolchain driver, and on top of that we (Linaro) updated our host OS to Ubuntu Jammy. This has caused the tests to not build with clang-21. 1. The host version of ld (2.38) not being able to parse certain DWARFv5 constructs. Normally I would switch to lld instead. However when I did this, I found that Picolib's ARM linker script uses ALIGN_WITH_INPUT, which lld does not support. So instead I'm sticking with ld and falling back to DWARFv4. Until such time as we upgrade the host to Ubuntu Noble. (if you're wondering how we can use ld in the first place, given the host is AArch64, the AArch64 ld is also capable of linking ARM 32-bit binaries) 2. Many missing symbol errors. This is solved in two parts: * Adding libunwind to the testing linker flags. * Putting the libraries in a group so that the ordering does not matter. And finally for exception_guard.odr.sh.cpp, I have moved the object files to before the linker flags. ld is sensitive to the order of objects on the command line, and this should not break other configurations. I've tested these with 19.1.7 too so my plan is to land these changes first, then proceed with upgrading to 21.x.
1 parent 83b48b1 commit 7643092

File tree

6 files changed

+13
-13
lines changed

6 files changed

+13
-13
lines changed

libcxx/cmake/caches/Armv7M-picolibc.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
set(CMAKE_ASM_COMPILER_TARGET "armv7m-none-eabi" CACHE STRING "")
22
set(CMAKE_CXX_COMPILER_TARGET "armv7m-none-eabi" CACHE STRING "")
3-
set(CMAKE_CXX_FLAGS "-mfloat-abi=soft" CACHE STRING "")
3+
set(CMAKE_CXX_FLAGS "-mfloat-abi=soft -gdwarf-4" CACHE STRING "")
44
set(CMAKE_C_COMPILER_TARGET "armv7m-none-eabi" CACHE STRING "")
5-
set(CMAKE_C_FLAGS "-mfloat-abi=soft" CACHE STRING "")
5+
set(CMAKE_C_FLAGS "-mfloat-abi=soft -gdwarf-4" CACHE STRING "")
66
set(CMAKE_SYSTEM_NAME Generic CACHE STRING "")
77
set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY CACHE STRING "")
88
set(COMPILER_RT_BAREMETAL_BUILD ON CACHE BOOL "")

libcxx/test/configs/armv7m-picolibc-libc++.cfg.in

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,16 @@ libc_linker_script = '@CMAKE_INSTALL_PREFIX@/lib/picolibcpp.ld'
55
config.substitutions.append(('%{flags}', '--sysroot=@CMAKE_INSTALL_PREFIX@'))
66

77
config.substitutions.append(('%{compile_flags}',
8-
'-nostdinc++ -I %{include-dir} -I %{target-include-dir} -I %{libcxx-dir}/test/support'
8+
'-nostdinc++ -I %{include-dir} -I %{target-include-dir} -I %{libcxx-dir}/test/support -gdwarf-4'
99

1010
# Disable warnings in the <atomic> implementation:
1111
# "large atomic operation may incur significant performance penalty; the
1212
# access size (4 bytes) exceeds the max lock-free size (0 bytes)"
1313
' -Wno-atomic-alignment'
1414
))
1515
config.substitutions.append(('%{link_flags}',
16-
'-nostdlib -nostdlib++ -L %{lib-dir} -lc++ -lc++abi'
17-
' -lc -lm -lclang_rt.builtins -lsemihost -lcrt0-semihost' +
16+
'-nostdlib -nostdlib++ -L %{lib-dir} -Wl,--start-group -lc++ -lc++abi'
17+
' -lunwind -lc -lm -lclang_rt.builtins -lsemihost -lcrt0-semihost -Wl,--end-group' +
1818
' -T {}'.format(libc_linker_script) +
1919
' -Wl,--defsym=__flash=0x0'
2020
' -Wl,--defsym=__flash_size=0x400000'

libcxx/test/libcxx/utilities/exception_guard.odr.sh.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
// RUN: %{cxx} %s %{flags} %{compile_flags} -c -o %t.except.o -O1 -fexceptions
1616
// RUN: %{cxx} %s %{flags} %{compile_flags} -c -o %t.noexcept.o -O1 -fno-exceptions
17-
// RUN: %{cxx} %{flags} %{link_flags} -o %t.exe %t.except.o %t.noexcept.o
17+
// RUN: %{cxx} %{flags} -o %t.exe %t.except.o %t.noexcept.o %{link_flags}
1818
// RUN: %{run}
1919

2020
#include <__utility/exception_guard.h>

libcxx/utils/ci/build-picolibc.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ rm -rf "${picolibc_source_dir}/picolibc-${picolibc_commit}"
7878

7979
cat <<EOF > "${picolibc_build_dir}/meson-cross-build.txt"
8080
[binaries]
81-
c = ['${CC:-cc}', '--target=${target}', '-mfloat-abi=soft', '-nostdlib']
81+
c = ['${CC:-cc}', '--target=${target}', '-mfloat-abi=soft', '-nostdlib', '-gdwarf-4']
8282
ar = 'llvm-ar'
8383
as = 'llvm-as'
8484
ld = 'lld'

libcxxabi/test/configs/armv7m-picolibc-libc++abi.cfg.in

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ libc_linker_script = '@CMAKE_INSTALL_PREFIX@/lib/picolibcpp.ld'
55
config.substitutions.append(('%{flags}', '--sysroot=@CMAKE_INSTALL_PREFIX@'))
66

77
config.substitutions.append(('%{compile_flags}',
8-
'-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'
8+
'-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 -gdwarf-4'
99
))
1010
config.substitutions.append(('%{link_flags}',
11-
'-nostdlib -nostdlib++ -L %{lib} -lc++ -lc++abi'
12-
' -lc -lm -lclang_rt.builtins -lsemihost -lcrt0-semihost' +
11+
'-nostdlib -nostdlib++ -L %{lib} -Wl,--start-group -lc++ -lc++abi'
12+
' -lunwind -lc -lm -lclang_rt.builtins -lsemihost -lcrt0-semihost -Wl,--end-group' +
1313
' -T {}'.format(libc_linker_script) +
1414
' -Wl,--defsym=__flash=0x0'
1515
' -Wl,--defsym=__flash_size=0x400000'

libunwind/test/configs/armv7m-picolibc-libunwind.cfg.in

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ libc_linker_script = '@CMAKE_INSTALL_PREFIX@/lib/picolibcpp.ld'
55
config.substitutions.append(('%{flags}', '--sysroot=@CMAKE_INSTALL_PREFIX@'))
66

77
config.substitutions.append(('%{compile_flags}',
8-
'-nostdinc++ -I %{include}'
8+
'-nostdinc++ -I %{include} -gdwarf-4'
99
))
1010
config.substitutions.append(('%{link_flags}',
11-
'-nostdlib -nostdlib++ -L %{lib} -lunwind'
12-
' -lc -lm -lclang_rt.builtins -lsemihost -lcrt0-semihost' +
11+
'-nostdlib -nostdlib++ -L %{lib} -Wl,--start-group -lunwind'
12+
' -lc -lm -lclang_rt.builtins -lsemihost -lcrt0-semihost -Wl,--end-group' +
1313
' -T {}'.format(libc_linker_script) +
1414
' -Wl,--defsym=__flash=0x0'
1515
' -Wl,--defsym=__flash_size=0x400000'

0 commit comments

Comments
 (0)