Opened 3 years ago

Closed 3 years ago

#64355 closed defect (worksforme)

gcc10 @10.3.0_1: fixincludes math.h missing for Intel hardware on Mac OS X 10.7 Lion

Reported by: johnrosshunt Owned by:
Priority: Normal Milestone:
Component: ports Version: 2.7.1
Keywords: lion i386 x86_64 Cc:
Port: gcc10

Description

Programs that include math.h fail to build using gcc10 on Intel hardware.

In file included from /opt/local/include/LegacySupport/math.h:79,
                 from /opt/local/include/libavutil/common.h:36,
                 from /opt/local/include/libavutil/avutil.h:296,
                 from /opt/local/include/libavutil/samplefmt.h:24,
                 from /opt/local/include/libavcodec/avcodec.h:31,
                 from /opt/local/include/libavformat/avformat.h:312,
                 from src/libav.h:26,
                 from src/main.c:70:
/opt/local/lib/gcc10/gcc/x86_64-apple-darwin11/10.3.0/include-fixed/math.h:37:10: fatal error: architecture/i386/math.h: No such file or directory
   37 | #include <architecture/i386/math.h>
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.

The header file from above contains the following snippet of code:

#if (defined(__ppc__) || defined(__ppc64__))
#include <architecture/ppc/math.h>
#elif (defined (__i386__) || defined( __x86_64__ ))
#include <architecture/i386/math.h>
#elif defined(__arm__)
#include <architecture/arm/math.h>
#else
#error Unknown architecture
#endif

There is a corresponding header file for PPC architecture, but not for Intel and ARM. As a workaround, programs compile fine if you create the missing directory and symlink /usr/include/architecture/i386/math.h to math.h. But, headers should probably be generated during the build. I took a peek at gcc11 and it appears the same headers are missing from that port as well.

Change History (4)

comment:1 Changed 3 years ago by kencu (Ken)

I seem to have that file as part of my standard kit:

$ uname -a
Darwin macbook21.local 11.4.2 Darwin Kernel Version 11.4.2: Thu Aug 23 16:26:45 PDT 2012; root:xnu-1699.32.7~1/RELEASE_I386 i386

$ ls -la /usr/include/architecture/i386/math.h
-rw-r--r--  1 root  wheel  24257 25 May  2011 /usr/include/architecture/i386/math.h

I presume you have the command line tools installed, of course.

However, even once you figure out where your standard headers went (I presume reinstalling your command line tools is what is needed there) all does not seem to be well with the macports gcc versions I have installed on 10.7:

$ cat mathtest.c
#include <math.h>
int main(void)
{
    return 0;
}

$/usr/bin/gcc mathtest.c
-- all good --

$ /opt/local/bin/gcc-mp-11  mathtest.c
In file included from /opt/local/lib/gcc11/gcc/x86_64-apple-darwin11/11.2.0/include-fixed/math.h:37,
                 from mathtest.c:1:
/usr/include/architecture/i386/math.h: In function '__inline_isnormalf':
/usr/include/architecture/i386/math.h:191:9: internal compiler error: Illegal instruction: 4
  191 |         static __inline__  int __inline_isnormalf( float __x ) { float fabsf = __builtin_fabsf(__x); if( __x != __x ) return 0; return fabsf < __builtin_inff() && fabsf >= __FLT_MIN__; }
      |         ^~~~~~
Please submit a full bug report,
with preprocessed source if appropriate.
See <https://trac.macports.org/newticket> for instructions.


$ /opt/local/bin/gcc-mp-10  mathtest.c
In file included from /opt/local/lib/gcc10/gcc/x86_64-apple-darwin11/10.3.0/include-fixed/math.h:37,
                 from mathtest.c:1:
/usr/include/architecture/i386/math.h: In function '__inline_isnormalf':
/usr/include/architecture/i386/math.h:191:2: internal compiler error: Illegal instruction: 4
  191 |  static __inline__  int __inline_isnormalf( float __x ) { float fabsf = __builtin_fabsf(__x); if( __x != __x ) return 0; return fabsf < __builtin_inff() && fabsf >= __FLT_MIN__; }
      |  ^~~~~~
libbacktrace could not find executable to open
Please submit a full bug report,
with preprocessed source if appropriate.
See <https://trac.macports.org/newticket> for instructions.

So -- something is just hosed here, whether it is something on my specific system (could be, can't promise it is not) or whether it is a general MP problem I don't know at present.

comment:2 Changed 3 years ago by kencu (Ken)

see #48004

suggestion is to rebuild gmp, so I guess I can try that

comment:3 Changed 3 years ago by kencu (Ken)

Rebuilding gmp on this machine from source fixed the ICE. So now all works well:

$ cat mathtest.c
#include <math.h>
#include <stdio.h>
int main(int argc, char* argv[])
{
    int i = 1000;
    double b = log2(i);
    printf("%f \n",b);

    double d = log2(2.3456789f);
    printf("%f \n",d);
    return 0;
}

$ /opt/local/bin/gcc-mp-10 mathtest.c

$ ./a.out
9.965784 
1.230005 

No problem with any missing header files noted.

comment:4 Changed 3 years ago by kencu (Ken)

Resolution: worksforme
Status: newclosed

John, I'm going to close this as a "worksforme" as I think the issue lies on your machine based on mine working fine.

Please reinstall the command line tools for 10.7, and try your previously failed build again. Perhaps also try the test program I have outlined above.

If reinstalling your command line tools fails to fix you up, and you still get errors related to

#include <architecture/i386/math.h>

being missing on your machine, please re-open this ticket, with a full log for the failed build, and we'll see if we can get you sorted out properly.

Note: See TracTickets for help on using tickets.