Counteracting LTO and "strange objects" (FP format detection). [patch]

Geoff Nixon geoff.nixon at aol.com
Tue Mar 18 01:39:39 UTC 2014


Hello!

A few months ago, I sent an email to the bugs list about a failure in 
the test suite due to compilation with LTO, particularly with LLVM, but 
also affecting ICC, and I believe some versions of GCC's LTO 
implementation. (Note I was using another email address at the time.)

You may recall this precipitating a discussion regarding proper 
rounding direction for integers greater than 2**54 when represented 
with floating point types; however, there was no real resolution to the 
bug, since no one could really come up with a solution (for the 
detection code in the configure script) that wasn't hopelessly brittle. 
(The best I could think of was filtering flags, at that time.)

I'm please to say that I *believe* I have now found a more robust 
solution. Patch:

https://gist.github.com/g--n/9611363#file-gmp-lto-fix-patch

I believe the patch resolves the issue (at least for me); it 
successfully applies against the 5.1.3 release and both the main devel 
and the 5.1 maintenance branches.

Please let me know if more explanation is needed, (or, of course, if it 
doesn't work!).


--------


Unfortunately, there appears to be another bug that crops up with LTO 
now (only affecting the development branch):

(Possibly? due to a similar assumption, i.e., that the intermediate 
compiler assembly, will in fact, be something like regular assembly.
That's pure speculation ...but it does not occur with LTO disabled).


```
/Applications/Xcode.app/Contents/Developer/usr/bin/make  libtests.la 
t-bswap t-constants t-count_zeros t-gmpmax t-hightomask t-modlinv 
t-popc t-parity t-sub
make[4]: `libtests.la' is up to date.
/bin/sh ../libtool  --tag=CC   --mode=link clang  -Ofast -flto -fpic 
-Wno-error   -o t-bswap t-bswap.o libtests.la ../libgmp.la

libtool: link: clang -Ofast -flto -fpic -Wno-error -o t-bswap t-bswap.o 
 ./.libs/libtests.a /Users/user/gmp/.libs/libgmp.a ../.libs/libgmp.a
<inline asm>:1:7: error: invalid operand for instruction
        subq    $8589934592, (%rax)
                ^~~~~~~~~~~
LLVM ERROR: Error parsing inline asm

clang: error: linker command failed with exit code 1 (use -v to see 
invocation)
make[4]: [t-bswap] Error 1 (ignored)
clang -DHAVE_CONFIG_H -I. -I.. -I..    -Ofast -flto -fpic -Wno-error -c 
-o t-constants.o t-constants.c
/bin/sh ../libtool  --tag=CC   --mode=link clang  -Ofast -flto -fpic 
-Wno-error   -o t-constants t-constants.o libtests.la ../libgmp.la
libtool: link: clang -Ofast -flto -fpic -Wno-error -o t-constants 
t-constants.o  ./.libs/libtests.a /Users/user/gmp/.libs/libgmp.a 
../.libs/libgmp.a
clang -DHAVE_CONFIG_H -I. -I.. -I..    -Ofast -flto -fpic -Wno-error -c 
-o t-count_zeros.o t-count_zeros.c
/bin/sh ../libtool  --tag=CC   --mode=link clang  -Ofast -flto -fpic 
-Wno-error   -o t-count_zeros t-count_zeros.o libtests.la ../libgmp.la
libtool: link: clang -Ofast -flto -fpic -Wno-error -o t-count_zeros 
t-count_zeros.o  ./.libs/libtests.a /Users/user/gmp/.libs/libgmp.a 
../.libs/libgmp.a
<inline asm>:1:7: error: invalid operand for instruction
        subq    $8589934592, (%rax)
                ^~~~~~~~~~~
LLVM ERROR: Error parsing inline asm

clang: error: linker command failed with exit code 1 (use -v to see 
invocation)
make[4]: [t-count_zeros] Error 1 (ignored)
```

Any idea here?


All the best,

Geoff Nixon
geoff.nixon at aol.com


More information about the gmp-devel mailing list