Skip to content
Advertisement

gcc 4.x not supporting x87 FPU math?

I’ve been trying to compile gcc 4.x from the sources using --with-fpmath=387 but I’m getting this error: "Invalid --with-fpmath=387". I looked in the configs and found that it doesn’t support this option (even though docs still mention it as a possible option):

case ${with_fpmath} in
  avx)
    tm_file="${tm_file} i386/avxmath.h"
    ;;
  sse)
    tm_file="${tm_file} i386/ssemath.h"
    ;;
  *)
    echo "Invalid --with-fpmath=$with_fpmath" 1>&2
    exit 1

Basically, I started this whole thing because I need to supply an executable for an old target platform (in fact, it’s an old Celeron but without any SSE2 instructions that are apparently used by libstdc++ by DEFAULT). The executable crashes at the first instruction (movq XMM0,…) coming from copying routines in libstdc++ with an “Illegal instruction” message. Is there any way to resolve this? I need to be on a fairly recent g++ to be able to port my existing code base.

I was wondering if it’s possible to supply these headers/sources from an older build to enable support for regular x87 instructions, so that no SSE instructions are referenced?

UPDATE: Please note I’m talking about compiled libstdc++ having SSE2 instructions in the object code, so the question is not about gcc command line arguments. No matter what I’m supplying to gcc when compiling my code, it will link with libstdc++ that already has built-in SSE2 instructions.

The real answer is not to use ANY –with-fpmath switches when compiling GCC. I got confused by the configure script switch statement thinking that it only supports sse or avx, while, in fact, the default value (not mentioned in this switch is “387”). So make sure you don’t use –with-fpmath when running configure. I recompiled GCC without it and it now works fine.

Thanks.

Advertisement

Answer

Please note the question was about compiled libstdc++ having SSE2 instructions in the object code, so the question was not about gcc command line arguments. No matter what I’m supplying to gcc when compiling my code, it will link with libstdc++ that already has built-in SSE2 instructions.

The real answer is not to use ANY –with-fpmath switches when compiling GCC. I got confused by the configure script switch statement thinking that it only supports sse or avx, while, in fact, the default value (not mentioned in this switch is “387”). So make sure you don’t use –with-fpmath when running configure. I recompiled GCC without it and it now works fine.

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement