GMP doesn't honor march flag

Paul Jähne paul.jaehne at
Thu Dec 21 09:48:47 UTC 2017


I encountered a problem with GMP when using the march flag.

I build GMP 6.1.1 with march=corei7 or march=westmere with GCC 5.4.0 on 
a server with a Haswell processor (E5-2630 v3). When executing curl 
(version 7.47.0 on Ubuntu 16.04) which uses GMP to retrieve a https 
website on a system with a Westmere Processor (Intel Xeon E5645) it 
crashes with the error: Illegal instruction (core dumped).

I also reproduced it with my laptop (it has a Browadwell i5-5200U). Here 
are the commands I used to built on my laptop:

$ cd /dev/shm
$ wget
$ tar -xjf gmp-6.1.1.tar.bz2
$ cd gmp-6.1.1/
$ CFLAGS="-march=corei7" CPPFLAGS=$CFLAGS CXXFLAGS=$CFLAGS ./configure --enable-cxx
$ make

Then copying the libraries to the server and executing it with the 
selfcompiled GMP:

$ scp .libs/libgmp* user at node015:/libgmptest
$ ssh user at node015
$ LD_LIBRARY_PATH=/home/user/libgmptest/ curl
Illegal instruction (core dumped)
$ LD_LIBRARY_PATH=/home/user/libgmptest/ ldd /usr/bin/curl =>  (0x00007ffd76339000) => /usr/lib/x86_64-linux-gnu/ (0x00007f22b9123000) => /lib/x86_64-linux-gnu/ (0x00007f22b8f09000) => /lib/x86_64-linux-gnu/ (0x00007f22b8cec000) => /lib/x86_64-linux-gnu/ (0x00007f22b8922000) => /usr/lib/x86_64-linux-gnu/ (0x00007f22b86ef000) => /usr/lib/x86_64-linux-gnu/ (0x00007f22b84d3000) => /usr/lib/x86_64-linux-gnu/ (0x00007f22b829d000) => /usr/lib/x86_64-linux-gnu/ (0x00007f22b7f6d000) => /usr/lib/x86_64-linux-gnu/ (0x00007f22b7d23000) => /usr/lib/x86_64-linux-gnu/ (0x00007f22b7b14000) => /usr/lib/x86_64-linux-gnu/ (0x00007f22b78c3000)
         /lib64/ (0x00007f22b95bf000) => /usr/lib/x86_64-linux-gnu/ (0x00007f22b7690000)
         * => /home/user/libgmptest/ (0x00007f22b73f3000)* => /usr/lib/x86_64-linux-gnu/ (0x00007f22b718f000) => /usr/lib/x86_64-linux-gnu/ (0x00007f22b6f7c000) => /usr/lib/x86_64-linux-gnu/ (0x00007f22b6caa000) => /usr/lib/x86_64-linux-gnu/ (0x00007f22b6a7b000) => /lib/x86_64-linux-gnu/ (0x00007f22b6877000) => /usr/lib/x86_64-linux-gnu/ (0x00007f22b666c000) => /lib/x86_64-linux-gnu/ (0x00007f22b6451000) => /usr/lib/x86_64-linux-gnu/ (0x00007f22b6236000) => /usr/lib/x86_64-linux-gnu/ (0x00007f22b5ff5000) => /usr/lib/x86_64-linux-gnu/ (0x00007f22b5ded000) => /lib/x86_64-linux-gnu/ (0x00007f22b5be9000) => /lib/x86_64-linux-gnu/ (0x00007f22b59e5000) => /usr/lib/x86_64-linux-gnu/ (0x00007f22b57dc000) => /usr/lib/x86_64-linux-gnu/ (0x00007f22b5552000) => /usr/lib/x86_64-linux-gnu/ (0x00007f22b52b0000) => /usr/lib/x86_64-linux-gnu/ (0x00007f22b507d000) => /usr/lib/x86_64-linux-gnu/ (0x00007f22b4e67000) => /usr/lib/x86_64-linux-gnu/ (0x00007f22b4c3e000) => /usr/lib/x86_64-linux-gnu/ (0x00007f22b4a2f000) => /usr/lib/x86_64-linux-gnu/ (0x00007f22b47e4000) => /usr/lib/x86_64-linux-gnu/ (0x00007f22b450f000) => /lib/x86_64-linux-gnu/ (0x00007f22b42d7000)

So my guess is that GMP somehow ignores the march flag and builds for 
the current architecture. Therefore running with the library on older 
architectures fails.

/The GMP version number, and if pre-packaged or patched then say so.
/6.1.1 no modifications/

/A test program that makes it possible for us to reproduce the bug. 
Include instructions on how to run the program.
/LD_LIBRARY_PATH=/home/user/libgmptest/ curl
(or any other https website)/

/A description of what is wrong. If the results are incorrect, in what 
way. If you get a crash, say so.
/curl crashes with illegal instruction

/If you get a crash, include a stack backtrace from the debugger if it’s 
informative (‘where’ in gdb, or ‘$C’ in adb).
/not informative

/Please do not send core dumps, executables or straces./

/The ‘configure’ options you used when building GMP, if any.
/CFLAGS="-march=corei7" CPPFLAGS=$CFLAGS CXXFLAGS=$CFLAGS ./configure 

/The output from ‘configure’, as printed to stdout, with any options used.
/attached as configure.gz/

/The name of the compiler and its version. For gcc, get the version with 
‘gcc -v’, otherwise perhaps ‘what `which cc`’, or similar.
/$ gcc -v
Using built-in specs.
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 
--prefix=/usr --program-suffix=-5 --enable-shared 
--enable-linker-build-id --libexecdir=/usr/lib 
--without-included-gettext --enable-threads=posix --libdir=/usr/lib 
--enable-nls --with-sysroot=/ --enable-clocale=gnu 
--enable-libstdcxx-debug --enable-libstdcxx-time=yes 
--with-default-libstdcxx-abi=new --enable-gnu-unique-object 
--disable-vtable-verify --enable-libmpx --enable-plugin 
--with-system-zlib --disable-browser-plugin --enable-java-awt=gtk 
--with-ecj-jar=/usr/share/java/eclipse-ecj.jar --enable-objc-gc 
--enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 
--with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic 
--enable-checking=release --build=x86_64-linux-gnu 
--host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.5)/

/The output from running ‘uname -a’.
/laptop: $ uname -a
Linux FIZI-LEX-072 4.13.0-19-generic #22~16.04.1-Ubuntu SMP Mon Dec 4 
15:35:18 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
server: $ uname -a
Linux ribnode015 4.4.0-103-generic #126-Ubuntu SMP Mon Dec 4 16:23:28 
UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

/The output from running ‘./config.guess’, and from running 
‘./configfsf.guess’ (might be the same).
/$ ./config.guess
$ ./configfsf.guess

/If the bug is related to ‘configure’, then the compressed contents of 
/attached as config.log.gz

/If the bug is related to an asm file not assembling, then the contents 
of config.m4 and the offending line or lines from the temporary 
not related to asm

Is there any way to make GMP respect the march flag?

Kind regards


-------------- next part --------------
A non-text attachment was scrubbed...
Name: configure.gz
Type: application/gzip
Size: 4858 bytes
Desc: not available
URL: <>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: config.log.gz
Type: application/gzip
Size: 36567 bytes
Desc: not available
URL: <>

More information about the gmp-bugs mailing list