ibex-team / ibex-lib

IBEX is a C++ library for constraint processing over real numbers.
http://ibex-team.github.io/ibex-lib/
GNU Lesser General Public License v3.0
67 stars 51 forks source link

ibex-lib build is broken for PPC due to gaol and mathlib #524

Open barracuda156 opened 2 years ago

barracuda156 commented 2 years ago

I was trying to update ibex-lib for Macports, and fixing build for PPC turned a problem:

  1. I am building on 10.6.8 Rosetta now, and there ibex-lib build system makes wrong settings, assuming x86 arch, which obviously is wrong: endianness is detected wrong, Intel intrinsics is invoked etc. This applies to CMake and Waf alike. Passing -DCMAKE_SYSTEM_PROCESSOR="ppc" fails to help. Waf cannot understand --build=powerpc-apple-darwin10.
  2. CMake build fails on Intel intrinsics includes present in GAOL. They should not be used at all on PPC BE.
  3. Mathlib does not seem to support PPC at all, definitions are missing for it.

So with Waf it fails like:

err: In file included from DPChange.c:8:
IX86MACOSX_DPChange.c: In function 'Init_Lib':
IX86MACOSX_DPChange.c:35:24: error: request for member '__control' in something not a structure or union
   35 | #define CTRLWORD(v) (v).__control
      |                        ^
IX86MACOSX_DPChange.c:49:23: note: in expansion of macro 'CTRLWORD'
   49 |         OrgDPStatus = CTRLWORD(status);
      |                       ^~~~~~~~
IX86MACOSX_DPChange.c:35:24: error: request for member '__control' in something not a structure or union
   35 | #define CTRLWORD(v) (v).__control
      |                        ^
IX86MACOSX_DPChange.c:52:5: note: in expansion of macro 'CTRLWORD'
   52 |     CTRLWORD(status) = NewDPStatus;
      |     ^~~~~~~~
IX86MACOSX_DPChange.c: In function 'Exit_Lib':
IX86MACOSX_DPChange.c:35:24: error: request for member '__control' in something not a structure or union
   35 | #define CTRLWORD(v) (v).__control
      |                        ^
IX86MACOSX_DPChange.c:80:23: note: in expansion of macro 'CTRLWORD'
   80 |         NewDPStatus = CTRLWORD(cpustatus);
      |                       ^~~~~~~~
IX86MACOSX_DPChange.c:35:24: error: request for member '__control' in something not a structure or union
   35 | #define CTRLWORD(v) (v).__control
      |                        ^
IX86MACOSX_DPChange.c:86:9: note: in expansion of macro 'CTRLWORD'
   86 |         CTRLWORD(cpustatus) = OrgDPStatus;
      |         ^~~~~~~~
make[2]: *** [DPChange.lo] Error 1
make[2]: *** Waiting for unfinished jobs....
make[1]: *** [all] Error 2
make: *** [all-recursive] Error 1

__control is defined here:

ts precision, all exceptions masked, rounding to +oo
// FIXME: Using an hexadecimal constant is not portable!
#define GAOL_FPU_MASK 0x0a3f

#if IX86_LINUX
#   define CTRLWORD(v) (v).__control_word
#elif IX86_MACOSX
#   define CTRLWORD(v) (v).__control
#endif 

Notice the arch. Then, intrinsics headers are used sometimes conditional on SSE2, sometimes unconditionally:

#include <xmmintrin.h>

#include <pmmintrin.h>

So it is completely broken atm.

barracuda156 commented 2 years ago

UPD. No, in fact fenv.h is there for PPC: https://opensource.apple.com/source/Libm/Libm-287.1/Source/PowerPC/fenv.h.auto.html And some implementations: https://opensource.apple.com/source/AppleOnboardAudio/AppleOnboardAudio-200.2.6/AppleOnboardAudio/fp/fenv.c.auto.html