@@ -1886,7 +1886,8 @@ struct DarwinPlatform {
18861886 assert (IsValid && " invalid SDK version" );
18871887 return DarwinSDKInfo (
18881888 Version,
1889- /* MaximumDeploymentTarget=*/ VersionTuple (Version.getMajor (), 0 , 99 ));
1889+ /* MaximumDeploymentTarget=*/ VersionTuple (Version.getMajor (), 0 , 99 ),
1890+ getOSFromPlatform (Platform));
18901891 }
18911892
18921893private:
@@ -1916,6 +1917,23 @@ struct DarwinPlatform {
19161917 }
19171918 }
19181919
1920+ static llvm::Triple::OSType getOSFromPlatform (DarwinPlatformKind Platform) {
1921+ switch (Platform) {
1922+ case DarwinPlatformKind::MacOS:
1923+ return llvm::Triple::MacOSX;
1924+ case DarwinPlatformKind::IPhoneOS:
1925+ return llvm::Triple::IOS;
1926+ case DarwinPlatformKind::TvOS:
1927+ return llvm::Triple::TvOS;
1928+ case DarwinPlatformKind::WatchOS:
1929+ return llvm::Triple::WatchOS;
1930+ case DarwinPlatformKind::DriverKit:
1931+ return llvm::Triple::DriverKit;
1932+ case DarwinPlatformKind::XROS:
1933+ return llvm::Triple::XROS;
1934+ }
1935+ }
1936+
19191937 SourceKind Kind;
19201938 DarwinPlatformKind Platform;
19211939 DarwinEnvironmentKind Environment = DarwinEnvironmentKind::NativeEnvironment;
@@ -2966,20 +2984,8 @@ bool Darwin::isAlignedAllocationUnavailable() const {
29662984 return TargetVersion < alignedAllocMinVersion (OS);
29672985}
29682986
2969- static bool sdkSupportsBuiltinModules (
2970- const Darwin::DarwinPlatformKind &TargetPlatform,
2971- const Darwin::DarwinEnvironmentKind &TargetEnvironment,
2972- const std::optional<DarwinSDKInfo> &SDKInfo) {
2973- if (TargetEnvironment == Darwin::NativeEnvironment ||
2974- TargetEnvironment == Darwin::Simulator ||
2975- TargetEnvironment == Darwin::MacCatalyst) {
2976- // Standard xnu/Mach/Darwin based environments
2977- // depend on the SDK version.
2978- } else {
2979- // All other environments support builtin modules from the start.
2980- return true ;
2981- }
2982-
2987+ static bool
2988+ sdkSupportsBuiltinModules (const std::optional<DarwinSDKInfo> &SDKInfo) {
29832989 if (!SDKInfo)
29842990 // If there is no SDK info, assume this is building against a
29852991 // pre-SDK version of macOS (i.e. before Mac OS X 10.4). Those
@@ -2990,26 +2996,18 @@ static bool sdkSupportsBuiltinModules(
29902996 return false ;
29912997
29922998 VersionTuple SDKVersion = SDKInfo->getVersion ();
2993- switch (TargetPlatform ) {
2999+ switch (SDKInfo-> getOS () ) {
29943000 // Existing SDKs added support for builtin modules in the fall
29953001 // 2024 major releases.
2996- case Darwin::MacOS :
3002+ case llvm::Triple::MacOSX :
29973003 return SDKVersion >= VersionTuple (15U );
2998- case Darwin::IPhoneOS:
2999- switch (TargetEnvironment) {
3000- case Darwin::MacCatalyst:
3001- // Mac Catalyst uses `-target arm64-apple-ios18.0-macabi` so the platform
3002- // is iOS, but it builds with the macOS SDK, so it's the macOS SDK version
3003- // that's relevant.
3004- return SDKVersion >= VersionTuple (15U );
3005- default :
3006- return SDKVersion >= VersionTuple (18U );
3007- }
3008- case Darwin::TvOS:
3004+ case llvm::Triple::IOS:
30093005 return SDKVersion >= VersionTuple (18U );
3010- case Darwin::WatchOS:
3006+ case llvm::Triple::TvOS:
3007+ return SDKVersion >= VersionTuple (18U );
3008+ case llvm::Triple::WatchOS:
30113009 return SDKVersion >= VersionTuple (11U );
3012- case Darwin ::XROS:
3010+ case llvm::Triple ::XROS:
30133011 return SDKVersion >= VersionTuple (2U );
30143012
30153013 // New SDKs support builtin modules from the start.
@@ -3138,7 +3136,7 @@ void Darwin::addClangTargetOptions(
31383136 // i.e. when the builtin stdint.h is in the Darwin module too, the cycle
31393137 // goes away. Note that -fbuiltin-headers-in-system-modules does nothing
31403138 // to fix the same problem with C++ headers, and is generally fragile.
3141- if (!sdkSupportsBuiltinModules (TargetPlatform, TargetEnvironment, SDKInfo))
3139+ if (!sdkSupportsBuiltinModules (SDKInfo))
31423140 CC1Args.push_back (" -fbuiltin-headers-in-system-modules" );
31433141
31443142 if (!DriverArgs.hasArgNoClaim (options::OPT_fdefine_target_os_macros,
0 commit comments