<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/126174>126174</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[X86][compiler-rt][builtin] Static Link Failure Caused by the Builtins Function Dependence on libm
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
zhangtianhao6
</td>
</tr>
</table>
<pre>
case:
```
#include <complex.h>
int
test (long double _Complex x, long double _Complex ref)
{
long double re, im;
re = creall(ref);
im = cimagl(ref);
return x / ref;
}
int main (){
long double _Complex x;
long double _Complex ref;
test(x, ref);
}
```
**compiler-rt** options: -rtlib=compiler-rt -static -unwindlib=libunwind -lm
failed:
```
/opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/15.0.1/../../../../x86_64-linux-gnu/bin/ld: /opt/compiler-explorer/clang-trunk-20250206/lib/clang/21/lib/x86_64-unknown-linux-gnu/libclang_rt.builtins.a(divxc3.c.o): in function `__divxc3':
divxc3.c:(.text+0x47): undefined reference to `fmaxl'
/opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/15.0.1/../../../../x86_64-linux-gnu/bin/ld: divxc3.c:(.text+0x4f): undefined reference to `logbl'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Compiler returned: 1
```
https://godbolt.org/z/Ks61aGoqs
**libgcc** options: -static
link ok.
https://godbolt.org/z/qo1cPYo31
**Reason**:
The __divxc3 symbol of the builtin function in compiler-rt depends on the fmaxl and logbl symbols of libm. The ld linker fails to be statically linked.
But the __divxc3 symbol in libgcc doesn't depend on the fmaxl and logbl symbols of libm.
Is this a bug and is there a plan to fix it or a means to circumvent it?
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJzMVU1v4zYQ_TX0ZSBBIm1ZPvggx1VRtIei7aE9BRQ1tthQpJcfjrK_viAlZ72bpN1jA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