From df79ba0dcfd933789f407caea977541aa8b4d1ff Mon Sep 17 00:00:00 2001 From: Geoffrey Oxberry Date: Sun, 2 Oct 2016 18:54:43 -0700 Subject: gcc: fix darwin dispatch/object.h header issue (#1518) Fixes #1203. Apple ships headers in Yosemite (and possibly earlier) that are gcc-incompatible, but compile fine with clang. The fix is to copy the offending system header from /usr/include/${REST_OF_HEADER_PATH} to ${GCC_PREFIX}/include/${REST_OF_HEADER_PATH} and replace the non-gcc- compatible features with gcc-compatible equivalents. See https://github.com/hashdist/hashstack/pull/771/files for inspiration, and http://hamelot.io/programming/osx-gcc-dispatch_block_t-has-not-been-declared-invalid-typedef/ for a description of the header issue. --- var/spack/repos/builtin/packages/gcc/package.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/var/spack/repos/builtin/packages/gcc/package.py b/var/spack/repos/builtin/packages/gcc/package.py index 3be3948b59..d152ce61c7 100644 --- a/var/spack/repos/builtin/packages/gcc/package.py +++ b/var/spack/repos/builtin/packages/gcc/package.py @@ -3,6 +3,7 @@ from spack import * from contextlib import closing from glob import glob import sys +from os.path import isfile class Gcc(Package): @@ -68,6 +69,19 @@ class Gcc(Package): if spec.satisfies("@4.7.1:") and sys.platform != 'darwin': enabled_languages.add('go') + # Fix a standard header file for OS X Yosemite that + # is GCC incompatible by replacing non-GCC compliant macros + if 'yosemite' in spec.architecture: + if isfile(r'/usr/include/dispatch/object.h'): + new_dispatch_dir = join_path(prefix, 'include', 'dispatch') + mkdirp(new_dispatch_dir) + cp = which('cp') + new_header = join_path(new_dispatch_dir, 'object.h') + cp(r'/usr/include/dispatch/object.h', new_header) + filter_file(r'typedef void \(\^dispatch_block_t\)\(void\)', + 'typedef void* dispatch_block_t', + new_header) + # Generic options to compile GCC options = ["--prefix=%s" % prefix, "--libdir=%s/lib64" % prefix, "--disable-multilib", -- cgit v1.2.3-70-g09d2