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
libc++ fails to compile on systems without posix_memalign #30796
Comments
Can we test for the existence of posix_memalign and disable support for C++17 aligned allocation functions if it doesn't exist? I'm not suggesting we implement that internally to libcxx, but that would obviously be an option as well. |
On Windows, posix_memalign wouldn't be available, but _aligned_malloc would. |
@Jeremy Can you be more specific about the platform causing issues? Is it just an older OS X version? If so do you know how to detect the availability of posix_memalign or Apple's libc version on that platform?
Ack. I'll make that change right away. |
Windows fix made in r290448. |
posix_memalign was added in Snow Leopard, and we've (MacPorts) got some users still on Leopard that we try to support. Yes, that's a bit far back. Something like this should do it in CMakeLists.txt: CHECK_SYMBOL_EXISTS(posix_memalign "stdlib.h" HAVE_POSIX_MEMALIGN) Then something like this in new.cpp: #if defined(HAVE_POSIX_MEMALIGN) || defined(HAVE_ALIGNED_MALLOC) |
Using CMake to detect it doesn't work. We need to be able to detect it inside so we know if we can offer the aligned new/delete overloads. |
Oh, well you could do something like this in : #if defined(APPLE) include <Availability.h>if __MAC_OS_X_VERSION_MIN_REQUIRED < 1060define _LIBCPP_HAS_NO_ALIGNED_ALLOCATIONendif#endif |
Awesome thanks! Can you point to the OS X documentation that specifies the min required version for posix_memalign? I can't seem to find it anywhere. |
It's declared in stdlib.h as: int posix_memalign(void **, size_t, size_t) __OSX_AVAILABLE_STARTING(__MAC_10_6, __IPHONE_3_0); And I've also verified as such through nm. |
Fix up for review in D28931. I'll backport it to Clang 4.0 as well. |
Fixed in r292564 and merged into the 4.0 release branch. |
Patch LGTM. Thanks. |
Extended Description
On older systems without posix_memalign, libcxx now fails to compile with:
new.cpp:73:14: error: no member named 'posix_memalign' in the global namespace
while (::posix_memalign(&p, static_cast<size_t>(alignment), size) != 0)
~~^
1 error generated.
This regressed in 9acbffa370bd03e4e0ed742110e4c780b99c28ac with:
commit 9acbffa370bd03e4e0ed742110e4c780b99c28ac
Author: Eric Fiselier eric@efcs.ca
Date: Fri Oct 14 06:46:30 2016 +0000
Can we test for the existence of posix_memalign
The text was updated successfully, but these errors were encountered: