Skip to content

Commit fa72680

Browse files
Merge pull request #75926 from ian-twilightcoder/lgamma_r-fix
[Shims] Don't redeclare lgamma_r in macOS 15.0 and associated SDKs
2 parents fd9847e + 07a639c commit fa72680

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

stdlib/public/SwiftShims/swift/shims/LibcShims.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,11 +170,16 @@ long double _stdlib_squareRootl(long double _self) {
170170
// Apple's math.h does not declare lgamma_r() etc by default, but they're
171171
// unconditionally exported by libsystem_m.dylib in all OS versions that
172172
// support Swift development; we simply need to provide declarations here.
173-
#if defined(__APPLE__)
173+
// In the macOS 15.0, iOS 18.0, et al SDKs, math.h unconditionally declares
174+
// lgamma_r() when building for Swift. Detect those SDKs by checking for a
175+
// header which was added in those versions. (Redeclaring the function
176+
// would cause an error where `lgamma_r` is ambiguous between the SDK
177+
// `_math.lgamma_r` and this `SwiftShims.lgamma_r`.)
178+
#if defined(__APPLE__) && !__has_include(<_modules/_math_h.h>)
174179
float lgammaf_r(float x, int *psigngam);
175180
double lgamma_r(double x, int *psigngam);
176181
long double lgammal_r(long double x, int *psigngam);
177-
#endif // defined(__APPLE__)
182+
#endif // defined(__APPLE__) && !__has_include(<_modules/_math_h.h>)
178183

179184
#ifdef __cplusplus
180185
} // extern "C"

0 commit comments

Comments
 (0)