[llvm-branch-commits] [libcxx] release/20.x: [libc++] Avoid including <features.h> on arbitrary platforms (#125587) (PR #127310)
via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Sat Feb 15 01:59:47 PST 2025
https://github.com/llvmbot created https://github.com/llvm/llvm-project/pull/127310
Backport cffc1ac3491c891ef4f80bcbfa685710e477eeac
Requested by: @ldionne
>From 49edc61061abd15b7b6a240463c3a296e4286569 Mon Sep 17 00:00:00 2001
From: Louis Dionne <ldionne.2 at gmail.com>
Date: Sat, 15 Feb 2025 10:54:00 +0100
Subject: [PATCH] [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.
(cherry picked from commit cffc1ac3491c891ef4f80bcbfa685710e477eeac)
---
libcxx/include/__configuration/platform.h | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
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 llvm-branch-commits
mailing list