@@ -1042,20 +1042,36 @@ static bool shouldAdhocSignByDefault(Architecture arch, PlatformType platform) {
1042
1042
platform == PLATFORM_XROS_SIMULATOR;
1043
1043
}
1044
1044
1045
- static bool dataConstDefault (const InputArgList &args) {
1046
- static const std::array<std::pair<PlatformType, VersionTuple>, 6 > minVersion =
1047
- {{{PLATFORM_MACOS, VersionTuple (10 , 15 )},
1048
- {PLATFORM_IOS, VersionTuple (13 , 0 )},
1049
- {PLATFORM_TVOS, VersionTuple (13 , 0 )},
1050
- {PLATFORM_WATCHOS, VersionTuple (6 , 0 )},
1051
- {PLATFORM_XROS, VersionTuple (1 , 0 )},
1052
- {PLATFORM_BRIDGEOS, VersionTuple (4 , 0 )}}};
1053
- PlatformType platform = removeSimulator (config->platformInfo .target .Platform );
1054
- auto it = llvm::find_if (minVersion,
1045
+ template <unsigned long N>
1046
+ using MinVersions = std::array<std::pair<PlatformType, VersionTuple>, N>;
1047
+
1048
+ // / Returns true if the platform is greater than the min version.
1049
+ // / Returns false if the platform does not exist.
1050
+ template <unsigned long N>
1051
+ static bool greaterEqMinVersion (const MinVersions<N> &minVersions,
1052
+ bool ignoreSimulator) {
1053
+ PlatformType platform = config->platformInfo .target .Platform ;
1054
+ if (ignoreSimulator)
1055
+ platform = removeSimulator (platform);
1056
+ auto it = llvm::find_if (minVersions,
1055
1057
[&](const auto &p) { return p.first == platform; });
1056
- if (it != minVersion.end ())
1057
- if (config->platformInfo .target .MinDeployment < it->second )
1058
- return false ;
1058
+ if (it != minVersions.end ())
1059
+ if (config->platformInfo .target .MinDeployment >= it->second )
1060
+ return true ;
1061
+ return false ;
1062
+ }
1063
+
1064
+ static bool dataConstDefault (const InputArgList &args) {
1065
+ static const MinVersions<6 > minVersion = {{
1066
+ {PLATFORM_MACOS, VersionTuple (10 , 15 )},
1067
+ {PLATFORM_IOS, VersionTuple (13 , 0 )},
1068
+ {PLATFORM_TVOS, VersionTuple (13 , 0 )},
1069
+ {PLATFORM_WATCHOS, VersionTuple (6 , 0 )},
1070
+ {PLATFORM_XROS, VersionTuple (1 , 0 )},
1071
+ {PLATFORM_BRIDGEOS, VersionTuple (4 , 0 )},
1072
+ }};
1073
+ if (!greaterEqMinVersion (minVersion, true ))
1074
+ return false ;
1059
1075
1060
1076
switch (config->outputType ) {
1061
1077
case MH_EXECUTE:
@@ -1106,30 +1122,18 @@ static bool shouldEmitChainedFixups(const InputArgList &args) {
1106
1122
if (requested)
1107
1123
return true ;
1108
1124
1109
- static const std::array<std::pair<PlatformType, VersionTuple>, 9 > minVersion =
1110
- {{
1111
- {PLATFORM_IOS, VersionTuple (13 , 4 )},
1112
- {PLATFORM_IOSSIMULATOR, VersionTuple (16 , 0 )},
1113
- {PLATFORM_MACOS, VersionTuple (13 , 0 )},
1114
- {PLATFORM_TVOS, VersionTuple (14 , 0 )},
1115
- {PLATFORM_TVOSSIMULATOR, VersionTuple (15 , 0 )},
1116
- {PLATFORM_WATCHOS, VersionTuple (7 , 0 )},
1117
- {PLATFORM_WATCHOSSIMULATOR, VersionTuple (8 , 0 )},
1118
- {PLATFORM_XROS, VersionTuple (1 , 0 )},
1119
- {PLATFORM_XROS_SIMULATOR, VersionTuple (1 , 0 )},
1120
- }};
1121
- PlatformType platform = config->platformInfo .target .Platform ;
1122
- auto it = llvm::find_if (minVersion,
1123
- [&](const auto &p) { return p.first == platform; });
1124
-
1125
- // We don't know the versions for other platforms, so default to disabled.
1126
- if (it == minVersion.end ())
1127
- return false ;
1128
-
1129
- if (it->second > config->platformInfo .target .MinDeployment )
1130
- return false ;
1131
-
1132
- return true ;
1125
+ static const MinVersions<9 > minVersion = {{
1126
+ {PLATFORM_IOS, VersionTuple (13 , 4 )},
1127
+ {PLATFORM_IOSSIMULATOR, VersionTuple (16 , 0 )},
1128
+ {PLATFORM_MACOS, VersionTuple (13 , 0 )},
1129
+ {PLATFORM_TVOS, VersionTuple (14 , 0 )},
1130
+ {PLATFORM_TVOSSIMULATOR, VersionTuple (15 , 0 )},
1131
+ {PLATFORM_WATCHOS, VersionTuple (7 , 0 )},
1132
+ {PLATFORM_WATCHOSSIMULATOR, VersionTuple (8 , 0 )},
1133
+ {PLATFORM_XROS, VersionTuple (1 , 0 )},
1134
+ {PLATFORM_XROS_SIMULATOR, VersionTuple (1 , 0 )},
1135
+ }};
1136
+ return greaterEqMinVersion (minVersion, false );
1133
1137
}
1134
1138
1135
1139
static bool shouldEmitRelativeMethodLists (const InputArgList &args) {
@@ -1140,20 +1144,20 @@ static bool shouldEmitRelativeMethodLists(const InputArgList &args) {
1140
1144
if (arg && arg->getOption ().getID () == OPT_no_objc_relative_method_lists)
1141
1145
return false ;
1142
1146
1143
- // If no flag is specified:
1144
- // - default true on >= ios14/macos11
1145
- // - default false on everything else
1146
- switch (config-> platformInfo . target . Platform ) {
1147
- case PLATFORM_IOS:
1148
- case PLATFORM_IOSSIMULATOR:
1149
- return config-> platformInfo . target . MinDeployment >= VersionTuple (14 , 0 );
1150
- case PLATFORM_MACOS:
1151
- return config-> platformInfo . target . MinDeployment >= VersionTuple (11 , 0 );
1152
- default :
1153
- return false ;
1154
- };
1155
- llvm_unreachable ( " RelativeMethodList should default to false, control flow "
1156
- " should not reach here " );
1147
+ // If no flag is specified, enable this on newer versions by default.
1148
+ // The min versions is taken from
1149
+ // ld64(https://github.com/apple-oss-distributions/ld64/blob/47f477cb721755419018f7530038b272e9d0cdea/src/ld/ld.hpp#L310)
1150
+ // to mimic to operation of ld64
1151
+ // [here](https://github.com/apple-oss-distributions/ld64/blob/47f477cb721755419018f7530038b272e9d0cdea/src/ld/Options.cpp#L6085-L6101)
1152
+ static const MinVersions< 6 > minVersion = {{
1153
+ {PLATFORM_MACOS, VersionTuple (10 , 16 )},
1154
+ {PLATFORM_IOS, VersionTuple ( 14 , 0 )},
1155
+ {PLATFORM_WATCHOS, VersionTuple (7 , 0 )},
1156
+ {PLATFORM_TVOS, VersionTuple ( 14 , 0 )},
1157
+ {PLATFORM_BRIDGEOS, VersionTuple ( 5 , 0 )},
1158
+ {PLATFORM_XROS, VersionTuple ( 1 , 0 )},
1159
+ }};
1160
+ return greaterEqMinVersion (minVersion, true );
1157
1161
}
1158
1162
1159
1163
void SymbolPatterns::clear () {
0 commit comments