Skip to content

Commit 876a5c9

Browse files
ldionnetstellar
authored andcommitted
[libc++] Avoid including <features.h> on arbitrary platforms (llvm#125587)
This partially reverts commit 5f2389d. 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 cffc1ac)
1 parent 0429535 commit 876a5c9

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

libcxx/include/__configuration/platform.h

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,9 @@
3030
// ... add new file formats here ...
3131
#endif
3232

33-
// To detect which libc we're using
34-
#if __has_include(<features.h>)
33+
// Need to detect which libc we're using if we're on Linux.
34+
#if defined(__linux__) || defined(__AMDGPU__) || defined(__NVPTX__)
3535
# include <features.h>
36-
#endif
37-
38-
#if defined(__linux__)
3936
# if defined(__GLIBC_PREREQ)
4037
# define _LIBCPP_GLIBC_PREREQ(a, b) __GLIBC_PREREQ(a, b)
4138
# else

0 commit comments

Comments
 (0)