================
@@ -265,3 +345,67 @@ clang::parseDarwinSDKInfo(llvm::vfs::FileSystem &VFS,
StringRef SDKRootPath) {
return llvm::make_error<llvm::StringError>("invalid SDKSettings.json",
llvm::inconvertibleErrorCode());
}
+
+DarwinSDKInfo::DarwinSDKInfo(llvm::Triple::OSType OS,
+ llvm::Triple::EnvironmentType Environment,
+ VersionTuple Version, StringRef DisplayName,
+ VersionTuple MaximumDeploymentTarget)
+ : DarwinSDKInfo("", OS, Environment, Version, DisplayName,
+ MaximumDeploymentTarget,
+ legacyPlatformInfos(OS, Environment)) {}
+
+static DarwinSDKInfo::PlatformInfoStorageType::const_iterator
+findPlatformInfo(const DarwinSDKInfo::PlatformInfoStorageType &PlatformInfos,
+ const llvm::Triple &Triple) {
+ auto PlatformInfoIt = llvm::find_if(
+ PlatformInfos,
+ [&Triple](const DarwinSDKInfo::SDKPlatformInfo &PlatformInfo) {
+ const auto &Triples = PlatformInfo.getTriples();
+ return llvm::find(Triples, Triple) != Triples.end();
+ });
+
+ // The SDK specifies values for Xcode to use for the -target argument. It's
+ // hard to perfectly match the triple passed to this function against those
+ // values though. The passed in triple might have been computed from just
+ // -arch, or it might have been modified by -march and several other
arguments
+ // that can effect any of the triple components. It's not really possible to
+ // account for all of the triple variations, but one common modification is
+ // that "arm" gets changed to "thumb". If the passed in triple is "thumb",
try
+ // mapping it back to an "arm" triple since that's what the SDK will specify.
+ if (PlatformInfoIt == PlatformInfos.end() &&
+ Triple.getArch() == llvm::Triple::thumb) {
+ StringRef ARMArch = llvm::Triple::getArchName(llvm::Triple::arm);
+
+ // Preserve the sub-arch from the triple.
+ llvm::ARM::ArchKind ArchKind = llvm::ARM::parseArch(Triple.getArchName());
+ StringRef SubArch = llvm::ARM::getSubArch(ArchKind);
+
+ llvm::Triple ARMTriple(Triple);
+ ARMTriple.setArchName((ARMArch + SubArch).str());
+ PlatformInfoIt = findPlatformInfo(PlatformInfos, ARMTriple);
+ }
+
+ return PlatformInfoIt;
+}
+
+bool DarwinSDKInfo::supportsTriple(const llvm::Triple &Triple) const {
+ return findPlatformInfo(PlatformInfos, Triple) != PlatformInfos.end();
+}
+
+StringRef DarwinSDKInfo::getPlatformPrefix(const llvm::Triple &Triple) const {
+ auto PlatformInfoIt = findPlatformInfo(PlatformInfos, Triple);
+ if (PlatformInfoIt != PlatformInfos.end())
+ return PlatformInfoIt->getPlatformPrefix();
+
+ // This triple probably isn't supported by the SDK. However, almost every SDK
----------------
ian-twilightcoder wrote:
New code: aggressively return the prefix.
https://github.com/llvm/llvm-project/pull/204061
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits