aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/TextAPI
diff options
context:
space:
mode:
authorCyndy Ishida <cyndy_ishida@apple.com>2023-03-23 14:51:37 -0700
committerCyndy Ishida <cyndy_ishida@apple.com>2023-03-23 14:58:41 -0700
commit397486566e995a019c249784b1d07c53b6ac670d (patch)
tree52ee97018e3336daf8299db2c778dc2551090d05 /llvm/lib/TextAPI
parentec2333d88538c1675227a555140a13bc27aafb69 (diff)
downloadllvm-397486566e995a019c249784b1d07c53b6ac670d.zip
llvm-397486566e995a019c249784b1d07c53b6ac670d.tar.gz
llvm-397486566e995a019c249784b1d07c53b6ac670d.tar.bz2
[llvm][TextAPI] Handle implicitly upgraded deployment versions
Sometimes the clang driver will receive a target triple where the deployment version is too low to support the platform + arch. In those cases, the compiler upgrades the final minOS which is what gets recorded ultimately by the linker in LC_BUILD_VERSION. TextAPI should also reuse this logic for capturing minOS in recorded TBDv5 files. Reviewed By: ributzka Differential Revision: https://reviews.llvm.org/D145690
Diffstat (limited to 'llvm/lib/TextAPI')
-rw-r--r--llvm/lib/TextAPI/Platform.cpp7
-rw-r--r--llvm/lib/TextAPI/TextStubV5.cpp6
2 files changed, 11 insertions, 2 deletions
diff --git a/llvm/lib/TextAPI/Platform.cpp b/llvm/lib/TextAPI/Platform.cpp
index 673fcb7..a432462 100644
--- a/llvm/lib/TextAPI/Platform.cpp
+++ b/llvm/lib/TextAPI/Platform.cpp
@@ -132,5 +132,12 @@ std::string getOSAndEnvironmentName(PlatformType Platform,
llvm_unreachable("Unknown llvm::MachO::PlatformType enum");
}
+VersionTuple mapToSupportedOSVersion(const Triple &Triple) {
+ const VersionTuple MinSupportedOS = Triple.getMinimumSupportedOSVersion();
+ if (MinSupportedOS > Triple.getOSVersion())
+ return MinSupportedOS;
+ return Triple.getOSVersion();
+}
+
} // end namespace MachO.
} // end namespace llvm.
diff --git a/llvm/lib/TextAPI/TextStubV5.cpp b/llvm/lib/TextAPI/TextStubV5.cpp
index a9355fab..ade4c86 100644
--- a/llvm/lib/TextAPI/TextStubV5.cpp
+++ b/llvm/lib/TextAPI/TextStubV5.cpp
@@ -293,8 +293,10 @@ Expected<TargetList> getTargetsSection(const Object *Section) {
if (!TargetOrErr)
return make_error<JSONStubError>(getParseErrorMsg(TBDKey::Target));
TargetOrErr->MinDeployment = Version;
-
- IFTargets.push_back(*TargetOrErr);
+ // Convert to LLVM::Triple to accurately compute minOS + platform + arch
+ // pairing.
+ IFTargets.push_back(
+ MachO::Target(Triple(getTargetTripleName(*TargetOrErr))));
}
return std::move(IFTargets);
}