<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/141598>141598</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[powerpc64le][XRay] XRay fails with linker errors when building C codes
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
Thyre
</td>
</tr>
</table>
<pre>
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:
- https://lab.llvm.org/buildbot/#/builders/95/builds/13758
- https://lab.llvm.org/buildbot/#/builders/72/builds/11568
- https://lab.llvm.org/buildbot/#/builders/76/builds/9949
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:
```console
[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:
```console
$ 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
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJzsWVtz27rx_zTwyw45JEiK0oMeqNs_-lexPbLSpk8akFySOCYBDQDaUR_62TsAKceJc9JcetrTU89wZF4A7OW3u9ifwbTmtUCck2RBktUV600j1fzQnBVe5bI8zw8N18AFN5y17RkK1iH0J2CVQQUdqpqLGgiNwjgIJlMfFj1vS1hIo6GSCk7yEdWpmMQtgjZMGSyhYry1s3IsWK8RZAVMACtLLGEJBrUhdAmP3DRgGoRKtq18tBNQKWmFas1qJFFGAndNgvEKsmy7I1EG7_fs7D0T7bVc9B_ATokyOKA2S6ZRE7q5lZp_IHRzYqZouKi9Xlxu_QIIncZhGFgN4zCZEjqz8uiPX3BY3x2A0PRfpCGhKWyy7W69gp9RiwTZ-gM3sJSl9SuEg2eXsuuYKOGmN6feWG9oU6JS1g_O-57n_LFpZIeEbnqNyqqssDeoQkI3d7JXhTOjbR8676TkL1gYQjfH3MYJoRuf0E3OBaGbomWiBq_6oNjZ40Ib1XcoDIDXTWLwKiG9qheF4VJ4Gt1fDV8Y72lTkmhV0AgI3WgjlY2W79KukN2Jt6g8ZZ-GiNxYOYRuvj16PPnDCjy5R_XC8M4Nudx6ORf6nyh5e_OX9f52OYl3650NrKUUFa9_RfsB3l8zwzfdySY47N9d29hgBlouEGIH_QJ-a_i_hv4r-P8G8IcU_zlLWp5fICZ0Q8OnV89LYC_uhXwUQyn0atEPo9ysozK-wzpnmhc-I3RqH4_u8djKunb6nk6-HKoTbAVcAgbIJDgenXdcfXWTdsOcreCG0Gkv3EZYQiutikt48eJB8tJVyxffZsOqhMbHYLg9Hrl4kPdIqNszaDpuVtZ5itANF0Xbl9aZ-mzddmqZqaTqCN3UplFeiRXrW-M3JMrCwM6GXpRYcStUYYUKRYFgpLXMRfwg1TRKPh71WRvs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