Darwin (MacOS) build error with Xcode 9
Compiling Charm++ with Xcode 9 results in a build failure, due to changes in header files.
Other projects (example from TensorFlow: https://github.com/tensorflow/tensorflow/issues/13220#issuecomment-331579775) have had the same issue.
The internal C++
__threading_support header (
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/__threading_support) defines the
__libcpp_thread_get_port() function, which internally uses
That function is defined in
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/pthread.h), but the function is hidden behind preprocessor conditions:
#if (!defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE)) || defined(_DARWIN_C_SOURCE) || defined(__cplusplus)
_XOPEN_SOURCEis defined in
src/arch/*-darwin-x86_64/conv-mach.hso that the
ucontextfunctions can be used.
A workaround is to also define
_DARWIN_C_SOURCE. I have no idea why
Another option is to use
<sys/ucontext.h> instead of
<ucontext.h>, which I don't think has the same requirement for