-
Notifications
You must be signed in to change notification settings - Fork 15.3k
[libc++] Always define _LIBCPP_GLIBC_PREREQ #169405
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
philnik777
merged 1 commit into
llvm:main
from
philnik777:unconditionally_define_glibc_prereq
Nov 25, 2025
Merged
[libc++] Always define _LIBCPP_GLIBC_PREREQ #169405
philnik777
merged 1 commit into
llvm:main
from
philnik777:unconditionally_define_glibc_prereq
Nov 25, 2025
+18
−43
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
e23890a to
6228867
Compare
Member
|
@llvm/pr-subscribers-libcxx Author: Nikolas Klauser (philnik777) ChangesAlways defining the macro allows us to simplify the few places where it's used. Full diff: https://github.com/llvm/llvm-project/pull/169405.diff 4 Files Affected:
diff --git a/libcxx/include/__config b/libcxx/include/__config
index 1b27f28f9ddef..26851aad4ca92 100644
--- a/libcxx/include/__config
+++ b/libcxx/include/__config
@@ -678,18 +678,10 @@ typedef __char32_t char32_t;
# endif // _LIBCPP_HAS_THREAD_API
# endif // _LIBCPP_HAS_THREADS
-# if _LIBCPP_HAS_THREAD_API_PTHREAD
-# if defined(__ANDROID__) && __ANDROID_API__ >= 30
-# define _LIBCPP_HAS_COND_CLOCKWAIT 1
-# elif defined(_LIBCPP_GLIBC_PREREQ)
-# if _LIBCPP_GLIBC_PREREQ(2, 30)
-# define _LIBCPP_HAS_COND_CLOCKWAIT 1
-# else
-# define _LIBCPP_HAS_COND_CLOCKWAIT 0
-# endif
-# else
-# define _LIBCPP_HAS_COND_CLOCKWAIT 0
-# endif
+# if !_LIBCPP_HAS_THREAD_API_PTHREAD
+# define _LIBCPP_HAS_COND_CLOCKWAIT 0
+# elif (defined(__ANDROID__) && __ANDROID_API__ >= 30) || _LIBCPP_GLIBC_PREREQ(2, 30)
+# define _LIBCPP_HAS_COND_CLOCKWAIT 1
# else
# define _LIBCPP_HAS_COND_CLOCKWAIT 0
# endif
@@ -855,12 +847,8 @@ typedef __char32_t char32_t;
// the latter depends on internal GNU libc details that are not appropriate
// to depend on here, so any declarations present when __cpp_char8_t is not
// defined are ignored.
-# if defined(_LIBCPP_GLIBC_PREREQ)
-# if _LIBCPP_GLIBC_PREREQ(2, 36) && defined(__cpp_char8_t)
-# define _LIBCPP_HAS_C8RTOMB_MBRTOC8 1
-# else
-# define _LIBCPP_HAS_C8RTOMB_MBRTOC8 0
-# endif
+# if _LIBCPP_GLIBC_PREREQ(2, 36) && defined(__cpp_char8_t)
+# define _LIBCPP_HAS_C8RTOMB_MBRTOC8 1
# else
# define _LIBCPP_HAS_C8RTOMB_MBRTOC8 0
# endif
diff --git a/libcxx/include/__configuration/platform.h b/libcxx/include/__configuration/platform.h
index f3c199dee172b..88bba5473c608 100644
--- a/libcxx/include/__configuration/platform.h
+++ b/libcxx/include/__configuration/platform.h
@@ -31,15 +31,15 @@
#endif
// Need to detect which libc we're using if we're on Linux.
-#if defined(__linux__) || defined(__AMDGPU__) || defined(__NVPTX__)
-# 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
+#if (defined(__linux__) || defined(__AMDGPU__) || defined(__NVPTX__)) && __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)
+#else
+# define _LIBCPP_GLIBC_PREREQ(a, b) 0
#endif
// This is required in order for _NEWLIB_VERSION to be defined in places where we use it.
diff --git a/libcxx/include/__random/binomial_distribution.h b/libcxx/include/__random/binomial_distribution.h
index bada8cfdd74a3..0712e4ef4a4f6 100644
--- a/libcxx/include/__random/binomial_distribution.h
+++ b/libcxx/include/__random/binomial_distribution.h
@@ -98,13 +98,7 @@ class binomial_distribution {
};
// Some libc declares the math functions to be `noexcept`.
-#if defined(_LIBCPP_GLIBC_PREREQ)
-# if _LIBCPP_GLIBC_PREREQ(2, 8)
-# define _LIBCPP_LGAMMA_R_NOEXCEPT _NOEXCEPT
-# else
-# define _LIBCPP_LGAMMA_R_NOEXCEPT
-# endif
-#elif defined(__LLVM_LIBC__)
+#if _LIBCPP_GLIBC_PREREQ(2, 8) || defined(__LLVM_LIBC__)
# define _LIBCPP_LGAMMA_R_NOEXCEPT _NOEXCEPT
#else
# define _LIBCPP_LGAMMA_R_NOEXCEPT
diff --git a/libcxx/src/filesystem/operations.cpp b/libcxx/src/filesystem/operations.cpp
index b71f94a89d6df..745db87ce3736 100644
--- a/libcxx/src/filesystem/operations.cpp
+++ b/libcxx/src/filesystem/operations.cpp
@@ -41,17 +41,10 @@
#include <time.h>
// since Linux 4.5 and FreeBSD 13, but the Linux libc wrapper is only provided by glibc >= 2.27 and musl
-#if defined(__linux__)
-# if defined(_LIBCPP_GLIBC_PREREQ)
-# if _LIBCPP_GLIBC_PREREQ(2, 27)
-# define _LIBCPP_FILESYSTEM_USE_COPY_FILE_RANGE
-# endif
-# elif _LIBCPP_HAS_MUSL_LIBC
-# define _LIBCPP_FILESYSTEM_USE_COPY_FILE_RANGE
-# endif
-#elif defined(__FreeBSD__)
+#if _LIBCPP_GLIBC_PREREQ(2, 27) || _LIBCPP_HAS_MUSL_LIBC || defined(__FreeBSD__)
# define _LIBCPP_FILESYSTEM_USE_COPY_FILE_RANGE
#endif
+
#if __has_include(<sys/sendfile.h>)
# include <sys/sendfile.h>
# define _LIBCPP_FILESYSTEM_USE_SENDFILE
|
simpal01
added a commit
to simpal01/arm-toolchain
that referenced
this pull request
Nov 26, 2025
…onfig Upstream LLVM introduced changes in libcxx/include/__config that overlap with the area modified by our patch 0001-Define-_LIBCPP_HAS_C8RTOMB_MBRTOC8.patch. As a result, the patch no longer applied cleanly during git am. This PR updates and rebases the patch to reflect the upstream modifications while preserving its original functionality. No functional change beyond re-aligning with upstream is intended. Upstream change: llvm/llvm-project#169405
simpal01
added a commit
to arm/arm-toolchain
that referenced
this pull request
Nov 26, 2025
…onfig (#625) Upstream LLVM introduced changes in libcxx/include/__config that overlap with the area modified by our patch 0001-Define-_LIBCPP_HAS_C8RTOMB_MBRTOC8.patch. As a result, the patch no longer applied cleanly during git am. This PR updates and rebases the patch to reflect the upstream modifications while preserving its original functionality. No functional change beyond re-aligning with upstream is intended. Upstream change: llvm/llvm-project#169405
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Always defining the macro allows us to simplify the few places where it's used.