[libcxx-commits] [libcxx] [libcxx] Do not redeclare `lgamma_r` when targeting the LLVM C library (PR #102036)
Joseph Huber via libcxx-commits
libcxx-commits at lists.llvm.org
Mon Aug 5 11:43:41 PDT 2024
https://github.com/jhuber6 created https://github.com/llvm/llvm-project/pull/102036
Summary:
We use `lgamma_r` for the random normal distrubtion support. In this
code we redeclare it, which caused issues with the LLVM C library as
this function has the `noexcept` flag. Also make sure we include
`features.h` when using the GPU so it gets this as well.
>From d84570d4003909a4d0fbc8a2596a8ad691c484a8 Mon Sep 17 00:00:00 2001
From: Joseph Huber <huberjn at outlook.com>
Date: Mon, 5 Aug 2024 13:40:47 -0500
Subject: [PATCH] [libcxx] Do not redeclare `lgamma_r` when targeting the LLVM
C library
Summary:
We use `lgamma_r` for the random normal distrubtion support. In this
code we redeclare it, which caused issues with the LLVM C library as
this function has the `noexcept` flag. Also make sure we include
`features.h` when using the GPU so it gets this as well.
---
libcxx/include/__configuration/platform.h | 4 +++-
libcxx/include/__random/binomial_distribution.h | 3 ++-
2 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/libcxx/include/__configuration/platform.h b/libcxx/include/__configuration/platform.h
index 27f68d04e8a8d..a53ec7d5f7b4a 100644
--- a/libcxx/include/__configuration/platform.h
+++ b/libcxx/include/__configuration/platform.h
@@ -38,7 +38,9 @@
# else
# define _LIBCPP_GLIBC_PREREQ(a, b) 0
# endif // defined(__GLIBC_PREREQ)
-#endif // defined(__linux__)
+#elif defined(__AMDGPU__) || defined(__NVPTX__)
+# include <features.h>
+#endif
#ifndef __BYTE_ORDER__
# error \
diff --git a/libcxx/include/__random/binomial_distribution.h b/libcxx/include/__random/binomial_distribution.h
index e8774bb8d67ee..3f19746bae238 100644
--- a/libcxx/include/__random/binomial_distribution.h
+++ b/libcxx/include/__random/binomial_distribution.h
@@ -97,7 +97,8 @@ class _LIBCPP_TEMPLATE_VIS binomial_distribution {
}
};
-#ifndef _LIBCPP_MSVCRT_LIKE
+// The LLVM C library provides this with conflicting `noexcept` attributes.
+#if !defined(_LIBCPP_MSVCRT_LIKE) && !defined(__LLVM_LIBC__)
extern "C" double lgamma_r(double, int*);
#endif
More information about the libcxx-commits
mailing list