Open
Description
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?