Skip to content

release/20.x: [libc++] Guard include of <features.h> with __has_include (#127691) #127842

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

Merged
merged 1 commit into from
Feb 20, 2025

Conversation

llvmbot
Copy link
Member

@llvmbot llvmbot commented Feb 19, 2025

Backport 2c8b124

Requested by: @ldionne

@llvmbot llvmbot requested a review from a team as a code owner February 19, 2025 18:23
@llvmbot llvmbot added this to the LLVM 20.X Release milestone Feb 19, 2025
@llvmbot
Copy link
Member Author

llvmbot commented Feb 19, 2025

@jhuber6 What do you think about merging this PR to the release branch?

@llvmbot llvmbot requested a review from jhuber6 February 19, 2025 18:24
@llvmbot llvmbot added the libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi. label Feb 19, 2025
@llvmbot
Copy link
Member Author

llvmbot commented Feb 19, 2025

@llvm/pr-subscribers-libcxx

Author: None (llvmbot)

Changes

Backport 2c8b124

Requested by: @ldionne


Full diff: https://github.com/llvm/llvm-project/pull/127842.diff

1 Files Affected:

  • (modified) libcxx/include/__configuration/platform.h (+8-6)
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__

Some configurations define __AMDGPU__ or __NVPTX__ on platforms that
don't provide <features.h>, such as CUDA on Mac.

(cherry picked from commit 2c8b124)
@tstellar tstellar merged commit d420bf8 into llvm:release/20.x Feb 20, 2025
11 of 15 checks passed
Copy link

@ldionne (or anyone else). If you would like to add a note about this fix in the release notes (completely optional). Please reply to this comment with a one or two sentence description of the fix. When you are done, please add the release:note label to this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.
Projects
Development

Successfully merging this pull request may close these issues.

4 participants