|
49 | 49 | #include "llvm/Support/TargetSelect.h" |
50 | 50 | #include "llvm/Support/TimeProfiler.h" |
51 | 51 | #include "llvm/TargetParser/Host.h" |
| 52 | +#include "llvm/TextAPI/Architecture.h" |
52 | 53 | #include "llvm/TextAPI/PackedVersion.h" |
53 | 54 |
|
54 | 55 | #include <algorithm> |
@@ -1048,42 +1049,55 @@ static bool shouldEmitChainedFixups(const InputArgList &args) { |
1048 | 1049 | if (arg && arg->getOption().matches(OPT_no_fixup_chains)) |
1049 | 1050 | return false; |
1050 | 1051 |
|
1051 | | - bool isRequested = arg != nullptr; |
1052 | | - |
1053 | | - // Version numbers taken from the Xcode 13.3 release notes. |
1054 | | - static const std::array<std::pair<PlatformType, VersionTuple>, 5> minVersion = |
1055 | | - {{{PLATFORM_MACOS, VersionTuple(11, 0)}, |
1056 | | - {PLATFORM_IOS, VersionTuple(13, 4)}, |
1057 | | - {PLATFORM_TVOS, VersionTuple(14, 0)}, |
1058 | | - {PLATFORM_WATCHOS, VersionTuple(7, 0)}, |
1059 | | - {PLATFORM_XROS, VersionTuple(1, 0)}}}; |
1060 | | - PlatformType platform = removeSimulator(config->platformInfo.target.Platform); |
1061 | | - auto it = llvm::find_if(minVersion, |
1062 | | - [&](const auto &p) { return p.first == platform; }); |
1063 | | - if (it != minVersion.end() && |
1064 | | - it->second > config->platformInfo.target.MinDeployment) { |
1065 | | - if (!isRequested) |
1066 | | - return false; |
| 1052 | + bool requested = arg && arg->getOption().matches(OPT_fixup_chains); |
| 1053 | + if (!config->isPic) { |
| 1054 | + if (requested) |
| 1055 | + error("-fixup_chains is incompatible with -no_pie"); |
1067 | 1056 |
|
1068 | | - warn("-fixup_chains requires " + getPlatformName(config->platform()) + " " + |
1069 | | - it->second.getAsString() + ", which is newer than target minimum of " + |
1070 | | - config->platformInfo.target.MinDeployment.getAsString()); |
| 1057 | + return false; |
1071 | 1058 | } |
1072 | 1059 |
|
1073 | 1060 | if (!is_contained({AK_x86_64, AK_x86_64h, AK_arm64}, config->arch())) { |
1074 | | - if (isRequested) |
| 1061 | + if (requested) |
1075 | 1062 | error("-fixup_chains is only supported on x86_64 and arm64 targets"); |
| 1063 | + |
1076 | 1064 | return false; |
1077 | 1065 | } |
1078 | 1066 |
|
1079 | | - if (!config->isPic) { |
1080 | | - if (isRequested) |
1081 | | - error("-fixup_chains is incompatible with -no_pie"); |
| 1067 | + if (args.hasArg(OPT_preload)) { |
| 1068 | + if (requested) |
| 1069 | + error("-fixup_chains is incompatible with -preload"); |
| 1070 | + |
1082 | 1071 | return false; |
1083 | 1072 | } |
1084 | 1073 |
|
1085 | | - // TODO: Enable by default once stable. |
1086 | | - return isRequested; |
| 1074 | + if (requested) |
| 1075 | + return true; |
| 1076 | + |
| 1077 | + static const std::array<std::pair<PlatformType, VersionTuple>, 9> minVersion = |
| 1078 | + {{ |
| 1079 | + {PLATFORM_IOS, VersionTuple(13, 4)}, |
| 1080 | + {PLATFORM_IOSSIMULATOR, VersionTuple(16, 0)}, |
| 1081 | + {PLATFORM_MACOS, VersionTuple(13, 0)}, |
| 1082 | + {PLATFORM_TVOS, VersionTuple(14, 0)}, |
| 1083 | + {PLATFORM_TVOSSIMULATOR, VersionTuple(15, 0)}, |
| 1084 | + {PLATFORM_WATCHOS, VersionTuple(7, 0)}, |
| 1085 | + {PLATFORM_WATCHOSSIMULATOR, VersionTuple(8, 0)}, |
| 1086 | + {PLATFORM_XROS, VersionTuple(1, 0)}, |
| 1087 | + {PLATFORM_XROS_SIMULATOR, VersionTuple(1, 0)}, |
| 1088 | + }}; |
| 1089 | + PlatformType platform = config->platformInfo.target.Platform; |
| 1090 | + auto it = llvm::find_if(minVersion, |
| 1091 | + [&](const auto &p) { return p.first == platform; }); |
| 1092 | + |
| 1093 | + // We don't know the versions for other platforms, so default to disabled. |
| 1094 | + if (it == minVersion.end()) |
| 1095 | + return false; |
| 1096 | + |
| 1097 | + if (it->second > config->platformInfo.target.MinDeployment) |
| 1098 | + return false; |
| 1099 | + |
| 1100 | + return true; |
1087 | 1101 | } |
1088 | 1102 |
|
1089 | 1103 | static bool shouldEmitRelativeMethodLists(const InputArgList &args) { |
|
0 commit comments