Project

General

Profile

Bug #1743

Darwin (MacOS) build error with Xcode 9

Added by Omri Mor 5 months ago. Updated 5 months ago.

Status:
Merged
Priority:
Normal
Assignee:
Category:
Machine Layers
Target version:
Start date:
11/12/2017
Due date:
% Done:

0%


Description

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 pthread_mach_thread_np().
That function is defined in pthread.h (/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_SOURCE is defined in src/arch/*-darwin-x86_64/conv-mach.h so that the ucontext functions can be used.
A workaround is to also define _POSIX_C_SOURCE or _DARWIN_C_SOURCE. I have no idea why __cplusplus isn't defined.

Another option is to use <sys/ucontext.h> instead of <ucontext.h>, which I don't think has the same requirement for _XOPEN_SOURCE


Related issues

Related to Charm++ - Bug #1728: Darwin clang compilation fails without -D_DARWIN_C_SOURCE on Sierra Rejected 10/30/2017

History

#1 Updated by Sam White 5 months ago

  • Target version set to 6.9.0

#2 Updated by Sam White 5 months ago

  • Assignee set to Evan Ramos
  • Status changed from New to In Progress

#3 Updated by Evan Ramos 5 months ago

My patch uses the _DARWIN_C_SOURCE workaround, which is what I found used by two open source projects that came up in search results for the error message. It mitigates the issue entirely with no side effects I have observed, but it still feels like a hack.

#4 Updated by Evan Ramos 5 months ago

  • Related to Bug #1728: Darwin clang compilation fails without -D_DARWIN_C_SOURCE on Sierra added

#6 Updated by Evan Ramos 5 months ago

  • Status changed from In Progress to Merged

Also available in: Atom PDF