cas_non_power_of_2.pass.cpp fails to link when using clang 23 and ARM picolibc builder configuration
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
Currently the test has some xfails and skips:
```
// XFAIL: clang-20, clang-21, apple-clang-17
// UNSUPPORTED: c++03
// TODO: remove the UNSUPPORTED clang-22 once libc++ CI's clang is updated to include
// the fix https://github.com/llvm/llvm-project/pull/78707
// UNSUPPORTED: clang-22
```
So on the current bot, it's XFAIL which is hiding the link failure I think. For 22 is doesn't run at all, but I expect the same issue if you enabled it.
I found the problem trying a clang 23:
```
$ export PATH=/home/davspi01/build-llvm-aarch64/bin/:$PATH
$ export CC=/home/davspi01/build-llvm-aarch64/bin/clang
$ export CXX=/home/davspi01/build-llvm-aarch64/bin/clang++
$ ./libcxx/utils/ci/run-buildbot armv7m-picolibc
```
```
FAIL: armv7m-picolibc-libc++.cfg.in :: std/atomics/atomics.types.generic/cas_non_power_of_2.pass.cpp (3138 of 11191)
******************** TEST 'armv7m-picolibc-libc++.cfg.in :: std/atomics/atomics.types.generic/cas_non_power_of_2.pass.cpp' FAILED ********************
Exit Code: 1
Command Output (stdout):
--
# COMPILED WITH
/home/davspi01/build-llvm-aarch64/bin/clang++ /home/davspi01/llvm-project/libcxx/test/std/atomics/atomics.types.generic/cas_non_power_of_2.pass.cpp --sysroot=/home/davspi01/llvm-project/build/armv7m-picolibc/install --target=armv7m-none-eabi -nostdinc++ -I /home/davspi01/llvm-project/build/armv7m-picolibc/libcxx/test-suite-install/include/c++/v1 -I /home/davspi01/llvm-project/build/armv7m-picolibc/libcxx/test-suite-install/include/c++/v1 -I /home/davspi01/llvm-project/libcxx/test/support -Wno-atomic-alignment -std=c++26 -Werror -Wall -Wctad-maybe-unsupported -Wextra -Wshadow -Wundef -Wunused-template -Wno-unused-command-line-argument -Wno-attributes -Wno-pessimizing-move -Wno-noexcept-type -Wno-atomic-alignment -Wno-reserved-module-identifier -Wdeprecated-copy -Wdeprecated-copy-dtor -Wshift-negative-value -Wno-user-defined-literals -Wno-tautological-compare -Wsign-compare -Wunused-variable -Wunused-parameter -Wunreachable-code -Wno-unused-local-typedef -Wno-local-type-template-args -Wno-c++11-extensions -Wno-unknown-pragmas -Wno-pass-failed -Wno-mismatched-new-delete -Wno-redundant-move -Wno-self-move -Wno-nullability-completeness -flax-vector-conversions=none -D_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER -D_LIBCPP_ENABLE_EXPERIMENTAL -Wuser-defined-warnings -lc++experimental -fuse-ld=lld -nostdlib -nostdlib++ -L /home/davspi01/llvm-project/build/armv7m-picolibc/libcxx/test-suite-install/lib -lc++ -lc++abi -lc -lm -lclang_rt.builtins -lsemihost -lcrt0-semihost -T /home/davspi01/llvm-project/build/armv7m-picolibc/install/lib/picolibcpp.ld -Wl,--defsym=__flash=0x0 -Wl,--defsym=__flash_size=0x400000 -Wl,--defsym=__ram=0x21000000 -Wl,--defsym=__ram_size=0x1000000 -Wl,--defsym=__stack_size=0x1000 -o /home/davspi01/llvm-project/build/armv7m-picolibc/libcxx/test/std/atomics/atomics.types.generic/Output/cas_non_power_of_2.pass.cpp.dir/t.tmp.exe
# executed command: /home/davspi01/build-llvm-aarch64/bin/clang++ /home/davspi01/llvm-project/libcxx/test/std/atomics/atomics.types.generic/cas_non_power_of_2.pass.cpp --sysroot=/home/davspi01/llvm-project/build/armv7m-picolibc/install --target=armv7m-none-eabi -nostdinc++ -I /home/davspi01/llvm-project/build/armv7m-picolibc/libcxx/test-suite-install/include/c++/v1 -I /home/davspi01/llvm-project/build/armv7m-picolibc/libcxx/test-suite-install/include/c++/v1 -I /home/davspi01/llvm-project/libcxx/test/support -Wno-atomic-alignment -std=c++26 -Werror -Wall -Wctad-maybe-unsupported -Wextra -Wshadow -Wundef -Wunused-template -Wno-unused-command-line-argument -Wno-attributes -Wno-pessimizing-move -Wno-noexcept-type -Wno-atomic-alignment -Wno-reserved-module-identifier -Wdeprecated-copy -Wdeprecated-copy-dtor -Wshift-negative-value -Wno-user-defined-literals -Wno-tautological-compare -Wsign-compare -Wunused-variable -Wunused-parameter -Wunreachable-code -Wno-unused-local-typedef -Wno-local-type-template-args -Wno-c++11-extensions -Wno-unknown-pragmas -Wno-pass-failed -Wno-mismatched-new-delete -Wno-redundant-move -Wno-self-move -Wno-nullability-completeness -flax-vector-conversions=none -D_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER -D_LIBCPP_ENABLE_EXPERIMENTAL -Wuser-defined-warnings -lc++experimental -fuse-ld=lld -nostdlib -nostdlib++ -L /home/davspi01/llvm-project/build/armv7m-picolibc/libcxx/test-suite-install/lib -lc++ -lc++abi -lc -lm -lclang_rt.builtins -lsemihost -lcrt0-semihost -T /home/davspi01/llvm-project/build/armv7m-picolibc/install/lib/picolibcpp.ld -Wl,--defsym=__flash=0x0 -Wl,--defsym=__flash_size=0x400000 -Wl,--defsym=__ram=0x21000000 -Wl,--defsym=__ram_size=0x1000000 -Wl,--defsym=__stack_size=0x1000 -o /home/davspi01/llvm-project/build/armv7m-picolibc/libcxx/test/std/atomics/atomics.types.generic/Output/cas_non_power_of_2.pass.cpp.dir/t.tmp.exe
# .---command stderr------------
# | ld.lld: error: undefined symbol: __atomic_load
# | >>> referenced by cas_non_power_of_2.pass.cpp
# | >>> /tmp/lit-tmp-q4b03px4/cas_non_power_of_2-05732a.o:(S<5> std::__1::__cxx_atomic_load[abi:nqe230000]>(std::__1::__cxx_atomic_base_impl> const*, std::__1::memory_order))
# | >>> referenced by cas_non_power_of_2.pass.cpp
# | >>> /tmp/lit-tmp-q4b03px4/cas_non_power_of_2-05732a.o:(S<6> std::__1::__cxx_atomic_load[abi:nqe230000]>(std::__1::__cxx_atomic_base_impl> const*, std::__1::memory_order))
# |
# | ld.lld: error: undefined symbol: __atomic_compare_exchange
# | >>> referenced by cas_non_power_of_2.pass.cpp
# | >>> /tmp/lit-tmp-q4b03px4/cas_non_power_of_2-05732a.o:(bool std::__1::__cxx_atomic_compare_exchange_strong[abi:nqe230000]>(std::__1::__cxx_atomic_base_impl>*, S<5>*, S<5>, std::__1::memory_order, std::__1::memory_order))
# | >>> referenced by cas_non_power_of_2.pass.cpp
# | >>> /tmp/lit-tmp-q4b03px4/cas_non_power_of_2-05732a.o:(bool std::__1::__cxx_atomic_compare_exchange_strong[abi:nqe230000]>(std::__1::__cxx_atomic_base_impl>*, S<6>*, S<6>, std::__1::memory_order, std::__1::memory_order))
# | clang++: error: linker command failed with exit code 1 (use -v to see invocation)
# `-----------------------------
# error: command failed with exit status: 1
********************
Failed Tests (1):
armv7m-picolibc-libc++.cfg.in :: std/atomics/atomics.types.generic/cas_non_power_of_2.pass.cpp
```
Removing the `5` and `6` tests "fixes" the issue:
```
int main(int, char**) {
test<1>();
test<2>();
test<3>();
test<4>();
// test<5>();
// test<6>();
return 0;
}
```
The smaller tests are compiled directly to atomic instructions, only 5 and 6 are a library call. I'm not sure if we could just link libatomic or not, maybe we have not done the work for Cortex M.
Anyway, short term this needs some sort of skip or ifdef so we don't block a future CI update to clang 23.
Contributor guide
Research direction
Start with libcxx/test/std/atomics/atomics.types.generic/cas_non_power_of_2.pass.cpp and reproduce the failure using ./libcxx/utils/ci/run-buildbot armv7m-picolibc with the shown ARM and Clang configuration. Inspect the existing XFAIL and UNSUPPORTED conditions and the linker output for tests 5 and 6. Done means the test has an appropriate configuration for this builder and the armv7m-picolibc CI run no longer fails unexpectedly.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- ci-cd, embedded-iot, testing-qa
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100