From 063b906966b6439f931734f370fcbd08fe6300af Mon Sep 17 00:00:00 2001 From: Egor Zhdan Date: Thu, 11 Dec 2025 11:39:20 +0000 Subject: [PATCH] [cxx-interop] Handle missing `` Android NDK, as of version 28, does not include the `ptrauth.h` header. This causes CI failures when building the Swift SDK for Android on Windows. rdar://166242941 --- stdlib/public/Cxx/cxxshim/libcxxstdlibshim.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/stdlib/public/Cxx/cxxshim/libcxxstdlibshim.h b/stdlib/public/Cxx/cxxshim/libcxxstdlibshim.h index 01f5d13fd2656..04da6a003e521 100644 --- a/stdlib/public/Cxx/cxxshim/libcxxstdlibshim.h +++ b/stdlib/public/Cxx/cxxshim/libcxxstdlibshim.h @@ -2,7 +2,9 @@ #include #include #include +#if __has_include() #include +#endif /// Used for std::string conformance to Swift.Hashable typedef std::hash __swift_interopHashOfString; @@ -68,10 +70,16 @@ struct __SwiftFunctionWrapper { __swift_interop_closure closure; Result operator()(Args... args) const { +#if __has_include() return ((LoweredFunction *)ptrauth_auth_and_resign( closure.func, ptrauth_key_asia, PtrAuthTypeDiscriminator, ptrauth_key_function_pointer, 0))(std::forward(args)..., closure.context); +#else + // Android NDK 28 does not define the ptrauth macros. + return ((LoweredFunction *)closure.func)(std::forward(args)..., + closure.context); +#endif } // A memberwise constructor is synthesized by Swift.