@@ -1960,7 +1960,8 @@ struct DarwinPlatform {
19601960 assert (IsValid && " invalid SDK version" );
19611961 return DarwinSDKInfo (
19621962 Version,
1963- /* MaximumDeploymentTarget=*/ VersionTuple (Version.getMajor (), 0 , 99 ));
1963+ /* MaximumDeploymentTarget=*/ VersionTuple (Version.getMajor (), 0 , 99 ),
1964+ getOSFromPlatform (Platform));
19641965 }
19651966
19661967private:
@@ -1990,6 +1991,23 @@ struct DarwinPlatform {
19901991 }
19911992 }
19921993
1994+ static llvm::Triple::OSType getOSFromPlatform (DarwinPlatformKind Platform) {
1995+ switch (Platform) {
1996+ case DarwinPlatformKind::MacOS:
1997+ return llvm::Triple::MacOSX;
1998+ case DarwinPlatformKind::IPhoneOS:
1999+ return llvm::Triple::IOS;
2000+ case DarwinPlatformKind::TvOS:
2001+ return llvm::Triple::TvOS;
2002+ case DarwinPlatformKind::WatchOS:
2003+ return llvm::Triple::WatchOS;
2004+ case DarwinPlatformKind::DriverKit:
2005+ return llvm::Triple::DriverKit;
2006+ case DarwinPlatformKind::XROS:
2007+ return llvm::Triple::XROS;
2008+ }
2009+ }
2010+
19932011 SourceKind Kind;
19942012 DarwinPlatformKind Platform;
19952013 DarwinEnvironmentKind Environment = DarwinEnvironmentKind::NativeEnvironment;
@@ -3063,20 +3081,8 @@ bool Darwin::isAlignedAllocationUnavailable() const {
30633081 return TargetVersion < alignedAllocMinVersion (OS);
30643082}
30653083
3066- static bool sdkSupportsBuiltinModules (
3067- const Darwin::DarwinPlatformKind &TargetPlatform,
3068- const Darwin::DarwinEnvironmentKind &TargetEnvironment,
3069- const std::optional<DarwinSDKInfo> &SDKInfo) {
3070- if (TargetEnvironment == Darwin::NativeEnvironment ||
3071- TargetEnvironment == Darwin::Simulator ||
3072- TargetEnvironment == Darwin::MacCatalyst) {
3073- // Standard xnu/Mach/Darwin based environments
3074- // depend on the SDK version.
3075- } else {
3076- // All other environments support builtin modules from the start.
3077- return true ;
3078- }
3079-
3084+ static bool
3085+ sdkSupportsBuiltinModules (const std::optional<DarwinSDKInfo> &SDKInfo) {
30803086 if (!SDKInfo)
30813087 // If there is no SDK info, assume this is building against a
30823088 // pre-SDK version of macOS (i.e. before Mac OS X 10.4). Those
@@ -3087,26 +3093,18 @@ static bool sdkSupportsBuiltinModules(
30873093 return false ;
30883094
30893095 VersionTuple SDKVersion = SDKInfo->getVersion ();
3090- switch (TargetPlatform ) {
3096+ switch (SDKInfo-> getOS () ) {
30913097 // Existing SDKs added support for builtin modules in the fall
30923098 // 2024 major releases.
3093- case Darwin::MacOS :
3099+ case llvm::Triple::MacOSX :
30943100 return SDKVersion >= VersionTuple (15U );
3095- case Darwin::IPhoneOS:
3096- switch (TargetEnvironment) {
3097- case Darwin::MacCatalyst:
3098- // Mac Catalyst uses `-target arm64-apple-ios18.0-macabi` so the platform
3099- // is iOS, but it builds with the macOS SDK, so it's the macOS SDK version
3100- // that's relevant.
3101- return SDKVersion >= VersionTuple (15U );
3102- default :
3103- return SDKVersion >= VersionTuple (18U );
3104- }
3105- case Darwin::TvOS:
3101+ case llvm::Triple::IOS:
31063102 return SDKVersion >= VersionTuple (18U );
3107- case Darwin::WatchOS:
3103+ case llvm::Triple::TvOS:
3104+ return SDKVersion >= VersionTuple (18U );
3105+ case llvm::Triple::WatchOS:
31083106 return SDKVersion >= VersionTuple (11U );
3109- case Darwin ::XROS:
3107+ case llvm::Triple ::XROS:
31103108 return SDKVersion >= VersionTuple (2U );
31113109
31123110 // New SDKs support builtin modules from the start.
@@ -3267,7 +3265,7 @@ void Darwin::addClangTargetOptions(
32673265 // i.e. when the builtin stdint.h is in the Darwin module too, the cycle
32683266 // goes away. Note that -fbuiltin-headers-in-system-modules does nothing
32693267 // to fix the same problem with C++ headers, and is generally fragile.
3270- if (!sdkSupportsBuiltinModules (TargetPlatform, TargetEnvironment, SDKInfo))
3268+ if (!sdkSupportsBuiltinModules (SDKInfo))
32713269 CC1Args.push_back (" -fbuiltin-headers-in-system-modules" );
32723270}
32733271
0 commit comments