Opened 5 years ago

Last modified 3 years ago

#24712 new defect

clang using compiler-rt rather than libgcc_s produce broken mpfr libraries

Reported by: François Bissey Owned by:
Priority: major Milestone: sage-8.2
Component: porting Keywords:
Cc: Dima Pasechnik Merged in:
Authors: Reviewers:
Report Upstream: N/A Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Status badges

Description (last modified by François Bissey)

Which causes failures when building mpc which in turns stop the build. libmpfr.so.6 is not healthy

fbissey@moonloop ~/sandbox/git-fork/sage-clang5 $ ldd -r local/lib/libmpfr.so.6
        linux-vdso.so.1 (0x00007ffdbd9b5000)
        libgmp.so.23 => /home/fbissey/sandbox/git-fork/sage-clang5/local/lib/libgmp.so.23 (0x00007f094d754000)
        libc.so.6 => /lib64/libc.so.6 (0x00007f094d3a1000)
        /lib64/ld-linux-x86-64.so.2 (0x00007f094dc52000)
undefined symbol: __floatunditf (local/lib/libmpfr.so.6)
undefined symbol: __multf3      (local/lib/libmpfr.so.6)
undefined symbol: __gttf2       (local/lib/libmpfr.so.6)
undefined symbol: __extenddftf2 (local/lib/libmpfr.so.6)
undefined symbol: __netf2       (local/lib/libmpfr.so.6)
undefined symbol: __addtf3      (local/lib/libmpfr.so.6)
undefined symbol: __trunctfdf2  (local/lib/libmpfr.so.6)
undefined symbol: __lttf2       (local/lib/libmpfr.so.6)
undefined symbol: __fixunstfdi  (local/lib/libmpfr.so.6)
undefined symbol: __unordtf2    (local/lib/libmpfr.so.6)
undefined symbol: __getf2       (local/lib/libmpfr.so.6)
undefined symbol: __subtf3      (local/lib/libmpfr.so.6)

These are gcc specific functions and shouldn't be used when compiling with clang https://gcc.gnu.org/onlinedocs/gccint/Soft-float-library-routines.html. mpfr upstream hasn't checked clang-5 and over, stopping at clang-4.0.1.

Change History (7)

comment:1 Changed 5 years ago by François Bissey

Summary: clang-5.0 miscompile mpfr-4.0clang-5.0 miscompile mpfr-4.0.0 and 4.0.1

comment:2 Changed 5 years ago by François Bissey

Building clang/clang-runtime on Gentoo with "-default-compiler-rt" and "-compiler-rt -sanitize" fixes the problem as it now uses bits of gcc to provide those functions. I think it is a bug somewhere in the clang install as those symbols (which are not requested by mpfr) shouldn't be generated when using clang's compiler-rt.

comment:3 Changed 5 years ago by François Bissey

Description: modified (diff)

I think the problem is in how the compiler generates object code. There is nothing in the configuration of mpfr that indicates that soft-float math will be selected. The logs are not different either. So I think the behavior is linked to the use of -mtune= and -march=.

comment:4 Changed 5 years ago by François Bissey

Nope, march and mtune are innocent.

comment:5 Changed 5 years ago by François Bissey

Summary: clang-5.0 miscompile mpfr-4.0.0 and 4.0.1clang using compiler-rt rather than libgcc_s produce broken mpfr libraries

comment:6 Changed 3 years ago by Dima Pasechnik

I see this while trying to build mpc on openbsd 6.4.

$ nm -D local/lib/libmpfr.so.6.1 | grep floatunditf
         U __floatunditf

and then mpc ./configure bails out without recongnising mpfr:

configure:13910: cc -o conftest -O2 -pipe -I/home/dimpase/sage/local/include -I/usr/local/include -L/home/dimpase/sage/local/lib -L/hom
e/dimpase/sage/local/lib -Wl,-rpath,/home/dimpase/sage/local/lib -L/usr/local/lib conftest.c -lmpfr -lgmp -lm  >&5
/home/dimpase/sage/local/lib/libmpfr.so.6.1: warning: sprintf() is often misused, please use snprintf()
/home/dimpase/sage/local/lib/libmpfr.so.6.1: warning: strcpy() is almost always misused, please use strlcpy()
/usr/local/lib/libgmp.so.10.0: warning: vsprintf() is often misused, please use vsnprintf()
/home/dimpase/sage/local/lib/libmpfr.so.6.1: undefined reference to `__getf2'
/home/dimpase/sage/local/lib/libmpfr.so.6.1: undefined reference to `__addtf3'
/home/dimpase/sage/local/lib/libmpfr.so.6.1: undefined reference to `__fixunstfdi'
/home/dimpase/sage/local/lib/libmpfr.so.6.1: undefined reference to `__unordtf2'
/home/dimpase/sage/local/lib/libmpfr.so.6.1: undefined reference to `__lttf2'
/home/dimpase/sage/local/lib/libmpfr.so.6.1: undefined reference to `__netf2'
/home/dimpase/sage/local/lib/libmpfr.so.6.1: undefined reference to `__extenddftf2'
/home/dimpase/sage/local/lib/libmpfr.so.6.1: undefined reference to `__multf3'
/home/dimpase/sage/local/lib/libmpfr.so.6.1: undefined reference to `__gttf2'
/home/dimpase/sage/local/lib/libmpfr.so.6.1: undefined reference to `__subtf3'
/home/dimpase/sage/local/lib/libmpfr.so.6.1: undefined reference to `__floatunditf'
/home/dimpase/sage/local/lib/libmpfr.so.6.1: undefined reference to `__trunctfdf2'
cc: error: linker command failed with exit code 1 (use -v to see invocation)
...
configure:13915: result: no
configure:13917: error: libmpfr not found or uses a different ABI (including static vs shared).

where

$ cc -v
OpenBSD clang version 6.0.0 (tags/RELEASE_600/final) (based on LLVM 6.0.0)
Target: amd64-unknown-openbsd6.4
Thread model: posix
InstalledDir: /usr/bin

comment:7 Changed 3 years ago by Dima Pasechnik

needless to say, mpfr's selftests fail with this error too. The workaround (found here) is to configure mpfr with --disable-float128 flag, at least in the openbsd case.

Last edited 3 years ago by Dima Pasechnik (previous) (diff)
Note: See TracTickets for help on using tickets.