@@ -2984,20 +2984,45 @@ bool Darwin::isAlignedAllocationUnavailable() const {
2984
2984
return TargetVersion < alignedAllocMinVersion (OS);
2985
2985
}
2986
2986
2987
- static bool sdkSupportsBuiltinModules (const Darwin::DarwinPlatformKind &TargetPlatform, const Optional<DarwinSDKInfo> &SDKInfo) {
2987
+ static bool sdkSupportsBuiltinModules (
2988
+ const Darwin::DarwinPlatformKind &TargetPlatform,
2989
+ const Darwin::DarwinEnvironmentKind &TargetEnvironment,
2990
+ const Optional<DarwinSDKInfo> &SDKInfo) {
2991
+ switch (TargetEnvironment) {
2992
+ case Darwin::NativeEnvironment:
2993
+ case Darwin::Simulator:
2994
+ case Darwin::MacCatalyst:
2995
+ // Standard xnu/Mach/Darwin based environments
2996
+ // depend on the SDK version.
2997
+ break ;
2998
+ default :
2999
+ // All other environments support builtin modules from the start.
3000
+ return true ;
3001
+ }
3002
+
2988
3003
if (!SDKInfo)
3004
+ // If there is no SDK info, assume this is building against a
3005
+ // pre-SDK version of macOS (i.e. before Mac OS X 10.4). Those
3006
+ // don't support modules anyway, but the headers definitely
3007
+ // don't support builtin modules either. It might also be some
3008
+ // kind of degenerate build environment, err on the side of
3009
+ // the old behavior which is to not use builtin modules.
2989
3010
return false ;
2990
3011
2991
3012
VersionTuple SDKVersion = SDKInfo->getVersion ();
2992
3013
switch (TargetPlatform) {
3014
+ // Existing SDKs added support for builtin modules in the fall
3015
+ // 2024 major releases.
2993
3016
case Darwin::MacOS:
2994
- return SDKVersion >= VersionTuple (99U );
3017
+ return SDKVersion >= VersionTuple (15U );
2995
3018
case Darwin::IPhoneOS:
2996
- return SDKVersion >= VersionTuple (99U );
3019
+ return SDKVersion >= VersionTuple (18U );
2997
3020
case Darwin::TvOS:
2998
- return SDKVersion >= VersionTuple (99U );
3021
+ return SDKVersion >= VersionTuple (18U );
2999
3022
case Darwin::WatchOS:
3000
- return SDKVersion >= VersionTuple (99U );
3023
+ return SDKVersion >= VersionTuple (11U );
3024
+
3025
+ // New SDKs support builtin modules from the start.
3001
3026
default :
3002
3027
return true ;
3003
3028
}
@@ -3086,7 +3111,7 @@ void Darwin::addClangTargetOptions(const llvm::opt::ArgList &DriverArgs,
3086
3111
// i.e. when the builtin stdint.h is in the Darwin module too, the cycle
3087
3112
// goes away. Note that -fbuiltin-headers-in-system-modules does nothing
3088
3113
// to fix the same problem with C++ headers, and is generally fragile.
3089
- if (!sdkSupportsBuiltinModules (TargetPlatform, SDKInfo))
3114
+ if (!sdkSupportsBuiltinModules (TargetPlatform, TargetEnvironment, SDKInfo))
3090
3115
CC1Args.push_back (" -fbuiltin-headers-in-system-modules" );
3091
3116
}
3092
3117
0 commit comments