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
When _XOPEN_SOURCE is set,<cstdlib> and <ctime> started to fail on macOS, missing ::aligned_alloc and ::timespec_get #46552
Comments
assigned to @ldionne |
Thanks a lot for the heads up and the analysis, Stephan. My inclination would be that the SDK headers should provide those declarations regardless of _XOPEN_SOURCE, since otherwise it looks like the implementation is not a valid C99 implementation when _XOPEN_SOURCE is defined. For the sake of keeping things simple, I like to push towards libc++ requiring a valid C99 implementation under it in order to work. I'll ask the libc folks here at Apple what they think -- I'm sure there's a reason for the _XOPEN_SOURCE dance in the SDK. |
So, actually, in the latest SDK, the condition for aligned_alloc is:
But for timespec_get it's still:
So it looks like it was meant to be fixed, since they fixed in for aligned_alloc. I'll report the issue for timespec_get. In the meantime, it does look like we should add a |
I just committed a fix: commit 99f3b23
Can you please let me know if it fixes your issue? It does fix the reproducer I created locally (and checked into the test suite). |
Note that my commit only tackles timespec_get, since aligned_alloc has been fixed already. What SDK are you using? |
I'm using /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk from Xcode Version 11.6 (11E708), which appears to be the latest one publicly available? |
Found Xcode 12 beta 6 now, which has the updated MacOSX11.0.sdk/usr/include/malloc/_malloc.h, and with which my original issue is indeed fixed. Thanks! |
Note that 99f3b23 was reverted because it broke the modules build, but I just checked-in this commit which should fix the bug without breaking modules: commit 5201b96
|
Extended Description
On macOS, with recent LLVM 12 trunk commit 67dfba9 " [libc++] Provide std::aligned_alloc and std::timespec_get on Apple platforms":
...and similarly for other values of _XOPEN_SOURCE, like 700. I noticed that when building ICU 67.1 as part of building recent master LibreOffice, where some place in the ICU sources sets _XOPEN_SOURCE to 600.
Another approach could be to change Apple's SDK headers, so that for C++ ::aligned_alloc and ::timespec_get would get declared regardless of any _XOPEN_SOURCE?
And yet another approach could be to declare that _XOPEN_SOURCE must not be defined when compiling C++ source (after all, at least technically it is an identifier that is reserved to the implementation), and instead fix ICU.
Thoughts how to proceed?
The text was updated successfully, but these errors were encountered: