Sunday, June 10, 2012

CGAL Build Issues Under OS-X 10.7

Update, Oct. 9, 2013: XCode 4 seems to fix the problems from this post, I have successfully built code using CGAL for tetrahedralization using Apple's distribution of LLVM and CLANG as of OS-X 10.8. I'm leaving this post up for users of 10.7 who might wonder what is the problem is.

There's recently been a bunch of trouble using CGAL (among other packages) under OS-X 10.7 Lion.  The issue appears to be that the strict rounding modes (-frounding-math in GCC) required by CGAL and other libraries that use exact geometric predicates are no longer available in the compilers shipped with Lion.

Between OS-X 10.6 and 10.7, Apple switched from using GCC to LLVM/Clang, providing a wrapper that translates GCC command-line arguments to their LLVM equivalents.  LLVM and Clang do not support correct rounding modes, so exact geometric predicates currently operate incorrectly in release builds.  The result is programs that operate correctly (at least sometimes) when in debug mode, but which crash inexplicably in optimized builds.

To the best of my knowledge, the only workaround is to install your own copy of GCC and build the relevant libraries using it.  This means you can't use XCode, since the correct options are not available, and I've heard nasty stories of the Apple compilers behaving poorly when there's another GCC installed.  I originally bought a Mac in order to have a nice development environment with the ability to run Linux/Unix software, so I'm finding this development rather irritating.

The ideal fix for this would be for LLVM and/or Clang to actually implement these rounding modes, but after a year since the first bug reports showed up, this doesn't seem to be fixed.  I find this incredible, since you would think that compliance with the floating point specification (IEEE 754) would be a fundamental priority for any serious compiler project.

No comments: