Revert "[Darwin] Further restrict inference of the simulator environment"

This commit is contained in:
Saleem Abdulrasool
2020-04-19 16:43:22 -07:00
committed by GitHub
parent ea142dba02
commit fbbf61f297
18 changed files with 87 additions and 119 deletions

View File

@@ -19,17 +19,40 @@
using namespace swift;
bool swift::tripleIsiOSSimulator(const llvm::Triple &triple) {
llvm::Triple::ArchType arch = triple.getArch();
return (triple.isiOS() &&
!tripleIsMacCatalystEnvironment(triple) &&
triple.isSimulatorEnvironment());
// FIXME: transitional, this should eventually stop testing arch, and
// switch to only checking the -environment field.
(triple.isSimulatorEnvironment() ||
arch == llvm::Triple::x86 || arch == llvm::Triple::x86_64));
}
bool swift::tripleIsAppleTVSimulator(const llvm::Triple &triple) {
return (triple.isTvOS() && triple.isSimulatorEnvironment());
llvm::Triple::ArchType arch = triple.getArch();
return (triple.isTvOS() &&
// FIXME: transitional, this should eventually stop testing arch, and
// switch to only checking the -environment field.
(triple.isSimulatorEnvironment() ||
arch == llvm::Triple::x86 || arch == llvm::Triple::x86_64));
}
bool swift::tripleIsWatchSimulator(const llvm::Triple &triple) {
return (triple.isWatchOS() && triple.isSimulatorEnvironment());
llvm::Triple::ArchType arch = triple.getArch();
return (triple.isWatchOS() &&
// FIXME: transitional, this should eventually stop testing arch, and
// switch to only checking the -environment field.
(triple.isSimulatorEnvironment() ||
arch == llvm::Triple::x86 || arch == llvm::Triple::x86_64));
}
bool swift::tripleIsAnySimulator(const llvm::Triple &triple) {
// FIXME: transitional, this should eventually just use the -environment
// field.
return triple.isSimulatorEnvironment() ||
tripleIsiOSSimulator(triple) ||
tripleIsWatchSimulator(triple) ||
tripleIsAppleTVSimulator(triple);
}
bool swift::tripleIsMacCatalystEnvironment(const llvm::Triple &triple) {
@@ -37,21 +60,6 @@ bool swift::tripleIsMacCatalystEnvironment(const llvm::Triple &triple) {
triple.getEnvironment() == llvm::Triple::MacABI;
}
bool swift::tripleInfersSimulatorEnvironment(const llvm::Triple &triple) {
switch (triple.getOS()) {
case llvm::Triple::IOS:
case llvm::Triple::TvOS:
case llvm::Triple::WatchOS:
return !triple.hasEnvironment() &&
(triple.getArch() == llvm::Triple::x86 ||
triple.getArch() == llvm::Triple::x86_64) &&
!tripleIsMacCatalystEnvironment(triple);
default:
return false;
}
}
bool swift::triplesAreValidForZippering(const llvm::Triple &target,
const llvm::Triple &targetVariant) {
// The arch and vendor must match.
@@ -319,6 +327,14 @@ getOSForAppleTargetSpecificModuleTriple(const llvm::Triple &triple) {
static Optional<StringRef>
getEnvironmentForAppleTargetSpecificModuleTriple(const llvm::Triple &triple) {
auto tripleEnvironment = triple.getEnvironmentName();
// If the environment is empty, infer a "simulator" environment based on the
// OS and architecture combination. This feature is deprecated and exists for
// backwards compatibility only; build systems should pass the "simulator"
// environment explicitly if they know they're building for a simulator.
if (tripleEnvironment == "" && swift::tripleIsAnySimulator(triple))
return StringRef("simulator");
return llvm::StringSwitch<Optional<StringRef>>(tripleEnvironment)
.Cases("unknown", "", None)
// These values are also supported, but are handled by the default case below: