Skip to content

[powerpc64le][XRay] XRay fails with linker errors when building C codes #141598

Open
@Thyre

Description

@Thyre

This initially came up after merging #140068. Build Bots for powerpc64le started failing because of an added C test, with the following error message:

AIL: XRay-powerpc64le-linux :: TestCases/Posix/patching-unpatching.c (4110 of 4158)
******************** TEST 'XRay-powerpc64le-linux :: TestCases/Posix/patching-unpatching.c' FAILED ********************
Exit Code: 1

Command Output (stderr):
--
/home/users/reuter1/Sources/llvm-project/_build/./bin/clang  -fxray-instrument  -m64 -fno-function-sections  -fxray-instrument -std=c23 /storage/users/reuter1/Sources/llvm-project/compiler-rt/test/xray/TestCases/Posix/patching-unpatching.c -o /storage/users/reuter1/Sources/llvm-project/_build/runtimes/runtimes-bins/compiler-rt/test/xray/POWERPC64LELinuxConfig/TestCases/Posix/Output/patching-unpatching.c.tmp # RUN: at line 4
+ /home/users/reuter1/Sources/llvm-project/_build/./bin/clang -fxray-instrument -m64 -fno-function-sections -fxray-instrument -std=c23 /storage/users/reuter1/Sources/llvm-project/compiler-rt/test/xray/TestCases/Posix/patching-unpatching.c -o /storage/users/reuter1/Sources/llvm-project/_build/runtimes/runtimes-bins/compiler-rt/test/xray/POWERPC64LELinuxConfig/TestCases/Posix/Output/patching-unpatching.c.tmp
/storage/users/reuter1/Sources/llvm-project/_build/lib/clang/21/lib/powerpc64le-unknown-linux-gnu/libclang_rt.xray-basic.a(xray_basic_logging.cpp.o): In function `__xray::basicLoggingInit(unsigned long, unsigned long, void*, unsigned long)::$_0::__invoke()':
/usr/include/sys/platform/gthr-default.h:107: undefined reference to `std::__throw_system_error(int)'
/storage/users/reuter1/Sources/llvm-project/_build/lib/clang/21/lib/powerpc64le-unknown-linux-gnu/libclang_rt.xray-basic.a(xray_basic_logging.cpp.o): In function `__xray::getLog()::$_0::__invoke()':
/usr/include/sys/platform/gthr-default.h:107: undefined reference to `std::__throw_system_error(int)'
/storage/users/reuter1/Sources/llvm-project/_build/lib/clang/21/lib/powerpc64le-unknown-linux-gnu/libclang_rt.xray-fdr.a(xray_fdr_logging.cpp.o): In function `__xray::fdrCommonHeaderInfo()::$_0::__invoke()':
/usr/lib/gcc/ppc64le-redhat-linux/8/../../../../include/c++/8/gthr-default.h:107: undefined reference to `std::__throw_system_error(int)'
/storage/users/reuter1/Sources/llvm-project/_build/lib/clang/21/lib/powerpc64le-unknown-linux-gnu/libclang_rt.xray-fdr.a(xray_fdr_logging.cpp.o): In function `__xray::fdrLoggingInit(unsigned long, unsigned long, void*, unsigned long)::$_0::__invoke()':
/usr/lib/gcc/ppc64le-redhat-linux/8/../../../../include/c++/8/gthr-default.h:107: undefined reference to `std::__throw_system_error(int)'
clang: error: linker command failed with exit code 1 (use -v to see invocation)

I was able to reproduce the message shown above on a Power10 machine. Build failures can be seen at:

Looking into this a bit further, the issue is not limited to the linked PR, nor the compiler-rt XRay tests.
See the following reproducer:

[reuter1@mammatus _build]$ which clang
~/Sources/llvm-project/stage1.install/bin/clang
[reuter1@mammatus _build]$ clang --version
clang version 21.0.0git (https://github.com/llvm/llvm-project.git 1d5bf04030f0345690243553a7d2ea8f60b26604)
Target: powerpc64le-unknown-linux-gnu
Thread model: posix
InstalledDir: /storage/users/reuter1/Sources/llvm-project/stage1.install/bin
Build config: +assertions
[reuter1@mammatus _build]$ cat test.c
int main( void )
{}
[reuter1@mammatus _build]$ clang -fxray-instrument -fxray-instruction-threshold=1 test.c 
/storage/users/reuter1/Sources/llvm-project/stage1.install/lib/clang/21/lib/powerpc64le-unknown-linux-gnu/libclang_rt.xray-basic.a(xray_basic_logging.cpp.o): In function `__xray::basicLoggingInit(unsigned long, unsigned long, void*, unsigned long)::$_0::__invoke()':
/usr/include/sys/platform/gthr-default.h:107: undefined reference to `std::__throw_system_error(int)'
/storage/users/reuter1/Sources/llvm-project/stage1.install/lib/clang/21/lib/powerpc64le-unknown-linux-gnu/libclang_rt.xray-basic.a(xray_basic_logging.cpp.o): In function `__xray::getLog()::$_0::__invoke()':
/usr/include/sys/platform/gthr-default.h:107: undefined reference to `std::__throw_system_error(int)'
/storage/users/reuter1/Sources/llvm-project/stage1.install/lib/clang/21/lib/powerpc64le-unknown-linux-gnu/libclang_rt.xray-fdr.a(xray_fdr_logging.cpp.o): In function `__xray::fdrCommonHeaderInfo()::$_0::__invoke()':
/usr/lib/gcc/ppc64le-redhat-linux/8/../../../../include/c++/8/gthr-default.h:107: undefined reference to `std::__throw_system_error(int)'
/storage/users/reuter1/Sources/llvm-project/stage1.install/lib/clang/21/lib/powerpc64le-unknown-linux-gnu/libclang_rt.xray-fdr.a(xray_fdr_logging.cpp.o): In function `__xray::fdrLoggingInit(unsigned long, unsigned long, void*, unsigned long)::$_0::__invoke()':
/usr/lib/gcc/ppc64le-redhat-linux/8/../../../../include/c++/8/gthr-default.h:107: undefined reference to `std::__throw_system_error(int)'
clang: error: linker command failed with exit code 1 (use -v to see invocation)

This commit is just before the PR changes landed. Trying to build a C code with XRay enabled causes the same linker errors to appear. LLVM is built with the pretty much the same arguments used for one of the build runner builds:

$ cmake ../llvm -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_ASSERTIONS=True '-DLLVM_LIT_ARGS='"'"'-v'"'"'' -DCMAKE_INSTALL_PREFIX=../stage1.install -DLLVM_ENABLE_ASSERTIONS=ON -DBUILD_SHARED_LIBS=ON -DCMAKE_C_COMPILER_LAUNCHER=gcc -DCMAKE_CXX_COMPILER_LAUNCHER=g++ '-DLLVM_ENABLE_PROJECTS=clang-tools-extra;clang;llvm' -DLLVM_ENABLE_RUNTIMES=compiler-rt

This may also affect Fortran, but I unfortunately haven't built flang in addition to clang.

CC: @sebastiankreutzer

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions