-
Notifications
You must be signed in to change notification settings - Fork 13.5k
[libc++] Guard include of <features.h> with __has_include #127691
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Some configurations define __AMDGPU__ or __NVPTX__ on platforms that don't provide <features.h>, such as CUDA on Mac.
@llvm/pr-subscribers-libcxx Author: Louis Dionne (ldionne) ChangesSome configurations define AMDGPU or NVPTX on platforms that don't provide <features.h>, such as CUDA on Mac. Full diff: https://github.com/llvm/llvm-project/pull/127691.diff 1 Files Affected:
diff --git a/libcxx/include/__configuration/platform.h b/libcxx/include/__configuration/platform.h
index cff99376ee24b..8d0f8f63f5213 100644
--- a/libcxx/include/__configuration/platform.h
+++ b/libcxx/include/__configuration/platform.h
@@ -32,12 +32,14 @@
// Need to detect which libc we're using if we're on Linux.
#if defined(__linux__) || defined(__AMDGPU__) || defined(__NVPTX__)
-# include <features.h>
-# if defined(__GLIBC_PREREQ)
-# define _LIBCPP_GLIBC_PREREQ(a, b) __GLIBC_PREREQ(a, b)
-# else
-# define _LIBCPP_GLIBC_PREREQ(a, b) 0
-# endif // defined(__GLIBC_PREREQ)
+# if __has_include(<features.h>)
+# include <features.h>
+# if defined(__GLIBC_PREREQ)
+# define _LIBCPP_GLIBC_PREREQ(a, b) __GLIBC_PREREQ(a, b)
+# else
+# define _LIBCPP_GLIBC_PREREQ(a, b) 0
+# endif // defined(__GLIBC_PREREQ)
+# endif
#endif
#ifndef __BYTE_ORDER__
|
Yeah, I forgot to mention that offloading compilations are weird. They like to define conflicting macros on both sides of the compilation to make things look the same. |
/cherry-pick 2c8b124 |
Failed to cherry-pick: 2c8b124 https://github.com/llvm/llvm-project/actions/runs/13413622290 Please manually backport the fix and push it to your github fork. Once this is done, please create a pull request |
/cherry-pick 2c8b124 |
/pull-request #127842 |
Some configurations define __AMDGPU__ or __NVPTX__ on platforms that don't provide <features.h>, such as CUDA on Mac. (cherry picked from commit 2c8b124)
Some configurations define AMDGPU or NVPTX on platforms that don't provide <features.h>, such as CUDA on Mac.