@@ -1960,7 +1960,8 @@ struct DarwinPlatform {
1960
1960
assert (IsValid && " invalid SDK version" );
1961
1961
return DarwinSDKInfo (
1962
1962
Version,
1963
- /* MaximumDeploymentTarget=*/ VersionTuple (Version.getMajor (), 0 , 99 ));
1963
+ /* MaximumDeploymentTarget=*/ VersionTuple (Version.getMajor (), 0 , 99 ),
1964
+ getOSFromPlatform (Platform));
1964
1965
}
1965
1966
1966
1967
private:
@@ -1990,6 +1991,23 @@ struct DarwinPlatform {
1990
1991
}
1991
1992
}
1992
1993
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
+
1993
2011
SourceKind Kind;
1994
2012
DarwinPlatformKind Platform;
1995
2013
DarwinEnvironmentKind Environment = DarwinEnvironmentKind::NativeEnvironment;
@@ -3063,20 +3081,8 @@ bool Darwin::isAlignedAllocationUnavailable() const {
3063
3081
return TargetVersion < alignedAllocMinVersion (OS);
3064
3082
}
3065
3083
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) {
3080
3086
if (!SDKInfo)
3081
3087
// If there is no SDK info, assume this is building against a
3082
3088
// pre-SDK version of macOS (i.e. before Mac OS X 10.4). Those
@@ -3087,26 +3093,18 @@ static bool sdkSupportsBuiltinModules(
3087
3093
return false ;
3088
3094
3089
3095
VersionTuple SDKVersion = SDKInfo->getVersion ();
3090
- switch (TargetPlatform ) {
3096
+ switch (SDKInfo-> getOS () ) {
3091
3097
// Existing SDKs added support for builtin modules in the fall
3092
3098
// 2024 major releases.
3093
- case Darwin::MacOS :
3099
+ case llvm::Triple::MacOSX :
3094
3100
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:
3106
3102
return SDKVersion >= VersionTuple (18U );
3107
- case Darwin::WatchOS:
3103
+ case llvm::Triple::TvOS:
3104
+ return SDKVersion >= VersionTuple (18U );
3105
+ case llvm::Triple::WatchOS:
3108
3106
return SDKVersion >= VersionTuple (11U );
3109
- case Darwin ::XROS:
3107
+ case llvm::Triple ::XROS:
3110
3108
return SDKVersion >= VersionTuple (2U );
3111
3109
3112
3110
// New SDKs support builtin modules from the start.
@@ -3267,7 +3265,7 @@ void Darwin::addClangTargetOptions(
3267
3265
// i.e. when the builtin stdint.h is in the Darwin module too, the cycle
3268
3266
// goes away. Note that -fbuiltin-headers-in-system-modules does nothing
3269
3267
// to fix the same problem with C++ headers, and is generally fragile.
3270
- if (!sdkSupportsBuiltinModules (TargetPlatform, TargetEnvironment, SDKInfo))
3268
+ if (!sdkSupportsBuiltinModules (SDKInfo))
3271
3269
CC1Args.push_back (" -fbuiltin-headers-in-system-modules" );
3272
3270
}
3273
3271
0 commit comments