[libcxx-commits] [libcxx] cffc1ac - [libc++] Avoid including <features.h> on arbitrary platforms (#125587)
via libcxx-commits
libcxx-commits at lists.llvm.org
Sat Feb 15 01:54:04 PST 2025
Author: Louis Dionne
Date: 2025-02-15T10:54:00+01:00
New Revision: cffc1ac3491c891ef4f80bcbfa685710e477eeac
URL: https://github.com/llvm/llvm-project/commit/cffc1ac3491c891ef4f80bcbfa685710e477eeac
DIFF: https://github.com/llvm/llvm-project/commit/cffc1ac3491c891ef4f80bcbfa685710e477eeac.diff
LOG: [libc++] Avoid including <features.h> on arbitrary platforms (#125587)
This partially reverts commit 5f2389d4. That commit started checking
whether <features.h> was a valid include unconditionally, however codebases
are free to have such a header on their search path, which breaks compilation.
LLVM libc now provides a more standard way of getting configuration macros
like __LLVM_LIBC__.
After this patch, we only include <features.h> when we're on Linux or
when we're compiling for GPUs.
Added:
Modified:
libcxx/include/__configuration/platform.h
Removed:
################################################################################
diff --git a/libcxx/include/__configuration/platform.h b/libcxx/include/__configuration/platform.h
index 2a92ce209b91f..cff99376ee24b 100644
--- a/libcxx/include/__configuration/platform.h
+++ b/libcxx/include/__configuration/platform.h
@@ -30,12 +30,9 @@
// ... add new file formats here ...
#endif
-// To detect which libc we're using
-#if __has_include(<features.h>)
+// Need to detect which libc we're using if we're on Linux.
+#if defined(__linux__) || defined(__AMDGPU__) || defined(__NVPTX__)
# include <features.h>
-#endif
-
-#if defined(__linux__)
# if defined(__GLIBC_PREREQ)
# define _LIBCPP_GLIBC_PREREQ(a, b) __GLIBC_PREREQ(a, b)
# else
More information about the libcxx-commits
mailing list