[libc++] Do not redeclare lgamma_r when targeting the LLVM C library (#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.
This commit is contained in:
Joseph Huber 2024-08-27 16:46:03 -05:00 committed by GitHub
parent ff2baf0360
commit 5f2389d49f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 8 additions and 4 deletions

View File

@ -30,15 +30,18 @@
// ... add new file formats here ...
#endif
// Need to detect which libc we're using if we're on Linux.
#if defined(__linux__)
// To detect which libc we're using
#if __has_include(<features.h>)
# include <features.h>
#endif
#if defined(__linux__)
# 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 // defined(__linux__)
#endif
#ifndef __BYTE_ORDER__
# error \

View File

@ -97,7 +97,8 @@ public:
}
};
#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