llvm-gcc miscompiles gmp-5.0.x

Jack Howarth howarth at bromo.med.uc.edu
Mon May 16 17:46:52 CEST 2011


Torbjörn,
    While we have fixed building gmp 5.0.2 using clang on darwin, the build with the llvm-gcc
compiler (which will likely be the default compiler for 10.7) is still broken. The current
test...

extern const int foo;      /*   Suppresses C++'s suppression of foo */
const int foo = {1,2,3};

produces...

[MacPro:~/gmp_bug] howarth% more conftest.s
        .section        __TEXT,__text,regular,pure_instructions
        .section        __TEXT,__literal4,4byte_literals
        .globl  _foo
        .align  2
_foo:
        .long   1


.subsections_via_symbols

using...

llvm-gcc -std=gnu99 -O2 -pedantic -m64 -mtune=core2 -march=core2  -S conftest.c

which causes the same breakage we previously saw with clang (due to the __literal4,4byte_literals).
I find if I change the test to just...

static const int foo = {1,2,3};

the test now produces...

        .section        __TEXT,__text,regular,pure_instructions

.subsections_via_symbols

which allows the resulting gmp-5.0.2 build with Apple's llvm-gcc to pass it's make check.
I am waiting for feedback from the Darwin linker developer as to whether a better fix exists.
           Jack
ps The above test change to "static const int foo = {1,2,3};" also works with clang.




More information about the gmp-bugs mailing list