Skip to content

Commit d420bf8

Browse files
ldionnetstellar
authored andcommitted
[libc++] Guard include of <features.h> with __has_include (llvm#127691)
Some configurations define __AMDGPU__ or __NVPTX__ on platforms that don't provide <features.h>, such as CUDA on Mac. (cherry picked from commit 2c8b124)
1 parent 9189ca8 commit d420bf8

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

libcxx/include/__configuration/platform.h

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,14 @@
3232

3333
// Need to detect which libc we're using if we're on Linux.
3434
#if defined(__linux__) || defined(__AMDGPU__) || defined(__NVPTX__)
35-
# include <features.h>
36-
# if defined(__GLIBC_PREREQ)
37-
# define _LIBCPP_GLIBC_PREREQ(a, b) __GLIBC_PREREQ(a, b)
38-
# else
39-
# define _LIBCPP_GLIBC_PREREQ(a, b) 0
40-
# endif // defined(__GLIBC_PREREQ)
35+
# if __has_include(<features.h>)
36+
# include <features.h>
37+
# if defined(__GLIBC_PREREQ)
38+
# define _LIBCPP_GLIBC_PREREQ(a, b) __GLIBC_PREREQ(a, b)
39+
# else
40+
# define _LIBCPP_GLIBC_PREREQ(a, b) 0
41+
# endif // defined(__GLIBC_PREREQ)
42+
# endif
4143
#endif
4244

4345
#ifndef __BYTE_ORDER__

0 commit comments

Comments
 (0)