|
19 | 19 | using namespace swift; |
20 | 20 |
|
21 | 21 | bool swift::tripleIsiOSSimulator(const llvm::Triple &triple) { |
| 22 | + llvm::Triple::ArchType arch = triple.getArch(); |
22 | 23 | return (triple.isiOS() && |
23 | 24 | !tripleIsMacCatalystEnvironment(triple) && |
24 | | - triple.isSimulatorEnvironment()); |
| 25 | + // FIXME: transitional, this should eventually stop testing arch, and |
| 26 | + // switch to only checking the -environment field. |
| 27 | + (triple.isSimulatorEnvironment() || |
| 28 | + arch == llvm::Triple::x86 || arch == llvm::Triple::x86_64)); |
25 | 29 | } |
26 | 30 |
|
27 | 31 | bool swift::tripleIsAppleTVSimulator(const llvm::Triple &triple) { |
28 | | - return (triple.isTvOS() && triple.isSimulatorEnvironment()); |
| 32 | + llvm::Triple::ArchType arch = triple.getArch(); |
| 33 | + return (triple.isTvOS() && |
| 34 | + // FIXME: transitional, this should eventually stop testing arch, and |
| 35 | + // switch to only checking the -environment field. |
| 36 | + (triple.isSimulatorEnvironment() || |
| 37 | + arch == llvm::Triple::x86 || arch == llvm::Triple::x86_64)); |
29 | 38 | } |
30 | 39 |
|
31 | 40 | bool swift::tripleIsWatchSimulator(const llvm::Triple &triple) { |
32 | | - return (triple.isWatchOS() && triple.isSimulatorEnvironment()); |
| 41 | + llvm::Triple::ArchType arch = triple.getArch(); |
| 42 | + return (triple.isWatchOS() && |
| 43 | + // FIXME: transitional, this should eventually stop testing arch, and |
| 44 | + // switch to only checking the -environment field. |
| 45 | + (triple.isSimulatorEnvironment() || |
| 46 | + arch == llvm::Triple::x86 || arch == llvm::Triple::x86_64)); |
| 47 | +} |
| 48 | + |
| 49 | +bool swift::tripleIsAnySimulator(const llvm::Triple &triple) { |
| 50 | + // FIXME: transitional, this should eventually just use the -environment |
| 51 | + // field. |
| 52 | + return triple.isSimulatorEnvironment() || |
| 53 | + tripleIsiOSSimulator(triple) || |
| 54 | + tripleIsWatchSimulator(triple) || |
| 55 | + tripleIsAppleTVSimulator(triple); |
33 | 56 | } |
34 | 57 |
|
35 | 58 | bool swift::tripleIsMacCatalystEnvironment(const llvm::Triple &triple) { |
36 | 59 | return triple.isiOS() && !triple.isTvOS() && |
37 | 60 | triple.getEnvironment() == llvm::Triple::MacABI; |
38 | 61 | } |
39 | 62 |
|
40 | | -bool swift::tripleInfersSimulatorEnvironment(const llvm::Triple &triple) { |
41 | | - switch (triple.getOS()) { |
42 | | - case llvm::Triple::IOS: |
43 | | - case llvm::Triple::TvOS: |
44 | | - case llvm::Triple::WatchOS: |
45 | | - return !triple.hasEnvironment() && |
46 | | - (triple.getArch() == llvm::Triple::x86 || |
47 | | - triple.getArch() == llvm::Triple::x86_64) && |
48 | | - !tripleIsMacCatalystEnvironment(triple); |
49 | | - |
50 | | - default: |
51 | | - return false; |
52 | | - } |
53 | | -} |
54 | | - |
55 | 63 | bool swift::triplesAreValidForZippering(const llvm::Triple &target, |
56 | 64 | const llvm::Triple &targetVariant) { |
57 | 65 | // The arch and vendor must match. |
@@ -319,6 +327,14 @@ getOSForAppleTargetSpecificModuleTriple(const llvm::Triple &triple) { |
319 | 327 | static Optional<StringRef> |
320 | 328 | getEnvironmentForAppleTargetSpecificModuleTriple(const llvm::Triple &triple) { |
321 | 329 | auto tripleEnvironment = triple.getEnvironmentName(); |
| 330 | + |
| 331 | + // If the environment is empty, infer a "simulator" environment based on the |
| 332 | + // OS and architecture combination. This feature is deprecated and exists for |
| 333 | + // backwards compatibility only; build systems should pass the "simulator" |
| 334 | + // environment explicitly if they know they're building for a simulator. |
| 335 | + if (tripleEnvironment == "" && swift::tripleIsAnySimulator(triple)) |
| 336 | + return StringRef("simulator"); |
| 337 | + |
322 | 338 | return llvm::StringSwitch<Optional<StringRef>>(tripleEnvironment) |
323 | 339 | .Cases("unknown", "", None) |
324 | 340 | // These values are also supported, but are handled by the default case below: |
|
0 commit comments