[libcxx-commits] [libcxx] [libc++] Revert "Do not redeclare lgamma_r when targeting the LLVM C library (#102036) (PR #125587)

Louis Dionne via libcxx-commits libcxx-commits at lists.llvm.org
Mon Feb 3 13:26:29 PST 2025


https://github.com/ldionne created https://github.com/llvm/llvm-project/pull/125587

This reverts commit 5f2389d4. That commit started checking whether <features.h> was a valid include, however codebases are free to have such a header on their search path, which breaks compilation. LLVM libc should instead provide a more standard way of getting configuration macros like __LLVM_LIBC__.

>From f27c95a4c4429e3fe8efbff210fdd52847b23db4 Mon Sep 17 00:00:00 2001
From: Louis Dionne <ldionne.2 at gmail.com>
Date: Mon, 3 Feb 2025 16:23:12 -0500
Subject: [PATCH] [libc++] Revert "Do not redeclare lgamma_r when targeting the
 LLVM C library (#102036)"

This reverts commit 5f2389d4. That commit started checking whether
<features.h> was a valid include, however codebases are free to have
such a header on their search path, which breaks compilation. LLVM libc
should instead provide a more standard way of getting configuration macros
like __LLVM_LIBC__.
---
 libcxx/include/__configuration/platform.h       | 9 +++------
 libcxx/include/__random/binomial_distribution.h | 3 +--
 2 files changed, 4 insertions(+), 8 deletions(-)

diff --git a/libcxx/include/__configuration/platform.h b/libcxx/include/__configuration/platform.h
index 2a92ce209b91f8..27f68d04e8a8d9 100644
--- a/libcxx/include/__configuration/platform.h
+++ b/libcxx/include/__configuration/platform.h
@@ -30,18 +30,15 @@
 // ... add new file formats here ...
 #endif
 
-// To detect which libc we're using
-#if __has_include(<features.h>)
-#  include <features.h>
-#endif
-
+// Need to detect which libc we're using if we're on Linux.
 #if defined(__linux__)
+#  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   // defined(__linux__)
 
 #ifndef __BYTE_ORDER__
 #  error                                                                                                               \
diff --git a/libcxx/include/__random/binomial_distribution.h b/libcxx/include/__random/binomial_distribution.h
index 9538c15e2dc97b..47790b674db588 100644
--- a/libcxx/include/__random/binomial_distribution.h
+++ b/libcxx/include/__random/binomial_distribution.h
@@ -97,8 +97,7 @@ class _LIBCPP_TEMPLATE_VIS binomial_distribution {
   }
 };
 
-// The LLVM C library provides this with conflicting `noexcept` attributes.
-#if !defined(_LIBCPP_MSVCRT_LIKE) && !defined(__LLVM_LIBC__)
+#ifndef _LIBCPP_MSVCRT_LIKE
 extern "C" double lgamma_r(double, int*);
 #endif
 



More information about the libcxx-commits mailing list