[libcxx-commits] [libcxx] [libcxx] Do not redeclare `lgamma_r` when targeting the LLVM C library (PR #102036)
via libcxx-commits
libcxx-commits at lists.llvm.org
Mon Aug 5 11:44:09 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-libcxx
Author: Joseph Huber (jhuber6)
<details>
<summary>Changes</summary>
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.
---
Full diff: https://github.com/llvm/llvm-project/pull/102036.diff
2 Files Affected:
- (modified) libcxx/include/__configuration/platform.h (+3-1)
- (modified) libcxx/include/__random/binomial_distribution.h (+2-1)
``````````diff
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
``````````
</details>
https://github.com/llvm/llvm-project/pull/102036
More information about the libcxx-commits
mailing list