Skip to content

Commit 5f2389d

Browse files
authored
[libc++] Do not redeclare lgamma_r when targeting the LLVM C library (llvm#102036)
We use lgamma_r for the random normal distribution support. In this code we redeclare it, which causes issues with the LLVM C library as this function is marked noexcept in LLVM libc. This patch ensures that we don't redeclare that function when targeting LLVM libc.
1 parent ff2baf0 commit 5f2389d

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

libcxx/include/__configuration/platform.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,18 @@
3030
// ... add new file formats here ...
3131
#endif
3232

33-
// Need to detect which libc we're using if we're on Linux.
34-
#if defined(__linux__)
33+
// To detect which libc we're using
34+
#if __has_include(<features.h>)
3535
# include <features.h>
36+
#endif
37+
38+
#if defined(__linux__)
3639
# if defined(__GLIBC_PREREQ)
3740
# define _LIBCPP_GLIBC_PREREQ(a, b) __GLIBC_PREREQ(a, b)
3841
# else
3942
# define _LIBCPP_GLIBC_PREREQ(a, b) 0
4043
# endif // defined(__GLIBC_PREREQ)
41-
#endif // defined(__linux__)
44+
#endif
4245

4346
#ifndef __BYTE_ORDER__
4447
# error \

libcxx/include/__random/binomial_distribution.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,8 @@ class _LIBCPP_TEMPLATE_VIS binomial_distribution {
9797
}
9898
};
9999

100-
#ifndef _LIBCPP_MSVCRT_LIKE
100+
// The LLVM C library provides this with conflicting `noexcept` attributes.
101+
#if !defined(_LIBCPP_MSVCRT_LIKE) && !defined(__LLVM_LIBC__)
101102
extern "C" double lgamma_r(double, int*);
102103
#endif
103104

0 commit comments

Comments
 (0)