[libcxx-commits] [libcxx] [libc++] Avoid including <features.h> on arbitrary platforms (PR #125587)
Louis Dionne via libcxx-commits
libcxx-commits at lists.llvm.org
Wed Feb 5 06:21:25 PST 2025
https://github.com/ldionne updated https://github.com/llvm/llvm-project/pull/125587
>From 21ff2ef0cab9edc79ac01a128998aa0c0bce8f83 Mon Sep 17 00:00:00 2001
From: Louis Dionne <ldionne.2 at gmail.com>
Date: Mon, 3 Feb 2025 16:23:12 -0500
Subject: [PATCH 1/2] [libc++] Avoid including <features.h> on arbitrary
platforms
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 should instead provide 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.
---
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 2a92ce209b91f8b..cff99376ee24b12 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
>From 832ff608e9e0623785afa6cb6f61cb292fb86213 Mon Sep 17 00:00:00 2001
From: Louis Dionne <ldionne.2 at gmail.com>
Date: Wed, 5 Feb 2025 09:21:14 -0500
Subject: [PATCH 2/2] Poke CI
More information about the libcxx-commits
mailing list