Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OS X 10.10: /usr/include/dispatch/object.h doesn't work with gcc #742

Closed
certik opened this issue May 1, 2015 · 2 comments · Fixed by #771
Closed

OS X 10.10: /usr/include/dispatch/object.h doesn't work with gcc #742

certik opened this issue May 1, 2015 · 2 comments · Fixed by #771

Comments

@certik
Copy link
Member

certik commented May 1, 2015

This is hit by many packages, and manifests as follows:

[gettext-bootstrap] libtool: compile:  gcc -c -DLOCALEDIR=\"/Users/certik/.hashdist/bld/gettext-bootstrap/spt6nwddjz7d/share/locale\" -DLOCALE_ALIAS_PATH=\"/Users/certik/.hashdist/bld/gettext-bootstrap/spt6nwddjz7d/share/locale\" -DLIBDIR=\"/Users/certik/.hashdist/bld/gettext-bootstrap/spt6nwddjz7d/lib\" -DBUILDING_LIBINTL -DBUILDING_DLL -DIN_LIBINTL -DENABLE_RELOCATABLE=1 -DIN_LIBRARY -DINSTALLDIR=\"/Users/certik/.hashdist/bld/gettext-bootstrap/spt6nwddjz7d/lib\" -DNO_XMALLOC -Dset_relocation_prefix=libintl_set_relocation_prefix -Drelocate=libintl_relocate -DDEPENDS_ON_LIBICONV=1 -DHAVE_CONFIG_H -I. -I. -I.. -I/Users/certik/.hashdist/bld/libiconv-bootstrap/y6dz7hsnygn3/include -g -O2 -fvisibility=hidden ./log.c  -fno-common -DPIC -o .libs/log.o
[gettext-bootstrap] In file included from /usr/include/dispatch/dispatch.h:51:0,
[gettext-bootstrap]                  from /System/Library/Frameworks/CoreFoundation.framework/Headers/CFStream.h:15,
[gettext-bootstrap]                  from /System/Library/Frameworks/CoreFoundation.framework/Headers/CFPropertyList.h:13,
[gettext-bootstrap]                  from ./langprefs.c:29:
[gettext-bootstrap] /usr/include/dispatch/object.h:143:15: error: expected identifier or '(' before '^' token
[gettext-bootstrap]  typedef void (^dispatch_block_t)(void);
[gettext-bootstrap]                ^
[gettext-bootstrap] /usr/include/dispatch/object.h:362:3: error: unknown type name 'dispatch_block_t'
[gettext-bootstrap]    dispatch_block_t notification_block);
[gettext-bootstrap]    ^

E.g. hashdist/hashdist#332 is a duplicate of this bug.

To fix this, we need to ship the fixed header file with our gcc.

@certik
Copy link
Member Author

certik commented May 1, 2015

To test this issue, just do:

$ cat a.c 
#if defined(__APPLE__)
#include <CoreFoundation/CoreFoundation.h>
#endif

int main()
{
    return 0;
}

and use system-wide clang:

$ clang a.c && ./a.out 
Ok!

vs our gcc:

$ ~/repos/hashstack/hd_base/bin/gcc a.c && ./a.out 
In file included from /usr/include/dispatch/dispatch.h:51:0,
                 from /System/Library/Frameworks/CoreFoundation.framework/Headers/CFStream.h:15,
                 from /System/Library/Frameworks/CoreFoundation.framework/Headers/CFPropertyList.h:13,
                 from /System/Library/Frameworks/CoreFoundation.framework/Headers/CoreFoundation.h:55,
                 from a.c:2:
/usr/include/dispatch/object.h:143:15: error: expected identifier or ‘(’ before ‘^’ token
 typedef void (^dispatch_block_t)(void);
               ^
/usr/include/dispatch/object.h:362:3: error: unknown type name ‘dispatch_block_t’
   dispatch_block_t notification_block);
   ^

The fix is to install the fixed dispatch/object.h into the gcc's $ARTIFACT, in fact it doesn't even have to be in the profile, you can put it manually into /Users/certik/.hashdist/bld/gcc/ozg5f7h6k3xv/include/dispatch/object.h and then things work:

$ ~/repos/hashstack/hd_base/bin/gcc a.c && ./a.out 
Ok!

To obtain the fixed object.h, do:

sed 's+typedef void (\^dispatch_block_t)(void)+typedef void* dispatch_block_t+' /usr/include/dispatch/object.h > "object.h"

@certik
Copy link
Member Author

certik commented May 15, 2015

This is fixed by #771.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant