mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[Driver] Infer simulator-ness for iOS/tvOS/watchOS.
Localize the hack to infer simulator-ness of the target in the driver itself, when it first processes the target. Emit a warning about the missing "-simulator" and correct the triple immediately. This gives a longer grace period for tools that might still not pass through the simulator environment, while narrowing the hack.
This commit is contained in:
@@ -264,17 +264,35 @@ static void validateArgs(DiagnosticEngine &diags, const ArgList &args,
|
||||
std::unique_ptr<ToolChain>
|
||||
Driver::buildToolChain(const llvm::opt::InputArgList &ArgList) {
|
||||
|
||||
if (const Arg *A = ArgList.getLastArg(options::OPT_target))
|
||||
if (const Arg *A = ArgList.getLastArg(options::OPT_target)) {
|
||||
DefaultTargetTriple = llvm::Triple::normalize(A->getValue());
|
||||
}
|
||||
|
||||
const llvm::Triple target(DefaultTargetTriple);
|
||||
llvm::Triple target(DefaultTargetTriple);
|
||||
|
||||
switch (target.getOS()) {
|
||||
case llvm::Triple::Darwin:
|
||||
case llvm::Triple::MacOSX:
|
||||
case llvm::Triple::IOS:
|
||||
case llvm::Triple::TvOS:
|
||||
case llvm::Triple::WatchOS: {
|
||||
case llvm::Triple::WatchOS:
|
||||
// Backward compatibility hack: infer "simulator" environment for x86
|
||||
// iOS/tvOS/watchOS.
|
||||
if (!target.isSimulatorEnvironment() &&
|
||||
(target.getArch() == llvm::Triple::x86 ||
|
||||
target.getArch() == llvm::Triple::x86_64) &&
|
||||
!tripleIsMacCatalystEnvironment(target)) {
|
||||
// Set the simulator environment.
|
||||
target.setEnvironment(llvm::Triple::EnvironmentType::Simulator);
|
||||
|
||||
auto newTargetTriple = target.normalize();
|
||||
Diags.diagnose(SourceLoc(), diag::warning_inferred_simulator_target,
|
||||
DefaultTargetTriple, newTargetTriple);
|
||||
|
||||
DefaultTargetTriple = newTargetTriple;
|
||||
}
|
||||
LLVM_FALLTHROUGH;
|
||||
|
||||
case llvm::Triple::Darwin:
|
||||
case llvm::Triple::MacOSX: {
|
||||
Optional<llvm::Triple> targetVariant;
|
||||
if (const Arg *A = ArgList.getLastArg(options::OPT_target_variant))
|
||||
targetVariant = llvm::Triple(llvm::Triple::normalize(A->getValue()));
|
||||
|
||||
Reference in New Issue
Block a user