@@ -1042,20 +1042,36 @@ static bool shouldAdhocSignByDefault(Architecture arch, PlatformType platform) {
10421042         platform == PLATFORM_XROS_SIMULATOR;
10431043}
10441044
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,
10551057                          [&](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 ;
10591075
10601076  switch  (config->outputType ) {
10611077  case  MH_EXECUTE:
@@ -1106,30 +1122,18 @@ static bool shouldEmitChainedFixups(const InputArgList &args) {
11061122  if  (requested)
11071123    return  true ;
11081124
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 );
11331137}
11341138
11351139static  bool  shouldEmitRelativeMethodLists (const  InputArgList &args) {
@@ -1140,12 +1144,20 @@ static bool shouldEmitRelativeMethodLists(const InputArgList &args) {
11401144  if  (arg && arg->getOption ().getID () == OPT_no_objc_relative_method_lists)
11411145    return  false ;
11421146
1143-   //  TODO: If no flag is specified, don't default to false, but instead:
1144-   //    - default false on   <   ios14
1145-   //    - default true  on   >=  ios14
1146-   //  For now, until this feature is confirmed stable, default to false if no
1147-   //  flag is explicitly specified
1148-   return  false ;
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 );
11491161}
11501162
11511163void  SymbolPatterns::clear () {
0 commit comments