Skip to content

Commit b6ae56b

Browse files
Merge pull request #1861 from swiftwasm/revert-unrelated-changes
Revert unrelated changes
2 parents 9849ea7 + e70e3d1 commit b6ae56b

20 files changed

+116
-96
lines changed

include/swift/AST/DiagnosticsFrontend.def

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ ERROR(error_unsupported_target_arch, none,
3939
ERROR(error_unsupported_opt_for_target, none,
4040
"unsupported option '%0' for target '%1'", (StringRef, StringRef))
4141

42+
WARNING(warning_inferred_simulator_target,none,
43+
"inferring simulator environment for target '%0'; "
44+
"use '-target %1' instead", (StringRef, StringRef))
45+
4246
ERROR(error_argument_not_allowed_with, none,
4347
"argument '%0' is not allowed with '%1'", (StringRef, StringRef))
4448

include/swift/Basic/Platform.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,12 @@ namespace swift {
4444
/// Returns true if the given triple represents watchOS running in a simulator.
4545
bool tripleIsWatchSimulator(const llvm::Triple &triple);
4646

47-
/// Return true if the given triple represents any simulator.
48-
bool tripleIsAnySimulator(const llvm::Triple &triple);
49-
5047
/// Returns true if the given triple represents a macCatalyst environment.
5148
bool tripleIsMacCatalystEnvironment(const llvm::Triple &triple);
5249

50+
/// Determine whether the triple infers the "simulator" environment.
51+
bool tripleInfersSimulatorEnvironment(const llvm::Triple &triple);
52+
5353
/// Returns true if the given -target triple and -target-variant triple
5454
/// can be zippered.
5555
bool triplesAreValidForZippering(const llvm::Triple &target,

lib/Basic/LangOptions.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ std::pair<bool, bool> LangOptions::setTarget(llvm::Triple triple) {
361361
// Set the "targetEnvironment" platform condition if targeting a simulator
362362
// environment. Otherwise _no_ value is present for targetEnvironment; it's
363363
// an optional disambiguating refinement of the triple.
364-
if (swift::tripleIsAnySimulator(Target))
364+
if (Target.isSimulatorEnvironment())
365365
addPlatformConditionValue(PlatformConditionKind::TargetEnvironment,
366366
"simulator");
367367

lib/Basic/Platform.cpp

Lines changed: 18 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -19,47 +19,39 @@
1919
using namespace swift;
2020

2121
bool swift::tripleIsiOSSimulator(const llvm::Triple &triple) {
22-
llvm::Triple::ArchType arch = triple.getArch();
2322
return (triple.isiOS() &&
2423
!tripleIsMacCatalystEnvironment(triple) &&
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));
24+
triple.isSimulatorEnvironment());
2925
}
3026

3127
bool swift::tripleIsAppleTVSimulator(const llvm::Triple &triple) {
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));
28+
return (triple.isTvOS() && triple.isSimulatorEnvironment());
3829
}
3930

4031
bool swift::tripleIsWatchSimulator(const llvm::Triple &triple) {
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);
32+
return (triple.isWatchOS() && triple.isSimulatorEnvironment());
5633
}
5734

5835
bool swift::tripleIsMacCatalystEnvironment(const llvm::Triple &triple) {
5936
return triple.isiOS() && !triple.isTvOS() &&
6037
triple.getEnvironment() == llvm::Triple::MacABI;
6138
}
6239

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+
6355
bool swift::triplesAreValidForZippering(const llvm::Triple &target,
6456
const llvm::Triple &targetVariant) {
6557
// The arch and vendor must match.
@@ -310,14 +302,6 @@ getOSForAppleTargetSpecificModuleTriple(const llvm::Triple &triple) {
310302
static Optional<StringRef>
311303
getEnvironmentForAppleTargetSpecificModuleTriple(const llvm::Triple &triple) {
312304
auto tripleEnvironment = triple.getEnvironmentName();
313-
314-
// If the environment is empty, infer a "simulator" environment based on the
315-
// OS and architecture combination. This feature is deprecated and exists for
316-
// backwards compatibility only; build systems should pass the "simulator"
317-
// environment explicitly if they know they're building for a simulator.
318-
if (tripleEnvironment == "" && swift::tripleIsAnySimulator(triple))
319-
return StringRef("simulator");
320-
321305
return llvm::StringSwitch<Optional<StringRef>>(tripleEnvironment)
322306
.Cases("unknown", "", None)
323307
// These values are also supported, but are handled by the default case below:

lib/Driver/DarwinToolChains.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,7 @@ toolchains::Darwin::addProfileGenerationArgs(ArgStringList &Arguments,
502502
}
503503

504504
StringRef Sim;
505-
if (tripleIsAnySimulator(Triple)) {
505+
if (Triple.isSimulatorEnvironment()) {
506506
Sim = "sim";
507507
}
508508

lib/Driver/Driver.cpp

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -287,17 +287,31 @@ static void validateArgs(DiagnosticEngine &diags, const ArgList &args,
287287
std::unique_ptr<ToolChain>
288288
Driver::buildToolChain(const llvm::opt::InputArgList &ArgList) {
289289

290-
if (const Arg *A = ArgList.getLastArg(options::OPT_target))
290+
if (const Arg *A = ArgList.getLastArg(options::OPT_target)) {
291291
DefaultTargetTriple = llvm::Triple::normalize(A->getValue());
292+
}
293+
294+
llvm::Triple target(DefaultTargetTriple);
292295

293-
const llvm::Triple target(DefaultTargetTriple);
296+
// Backward compatibility hack: infer "simulator" environment for x86
297+
// iOS/tvOS/watchOS.
298+
if (tripleInfersSimulatorEnvironment(target)) {
299+
// Set the simulator environment.
300+
target.setEnvironment(llvm::Triple::EnvironmentType::Simulator);
301+
302+
auto newTargetTriple = target.normalize();
303+
Diags.diagnose(SourceLoc(), diag::warning_inferred_simulator_target,
304+
DefaultTargetTriple, newTargetTriple);
305+
306+
DefaultTargetTriple = newTargetTriple;
307+
}
294308

295309
switch (target.getOS()) {
296-
case llvm::Triple::Darwin:
297-
case llvm::Triple::MacOSX:
298310
case llvm::Triple::IOS:
299311
case llvm::Triple::TvOS:
300-
case llvm::Triple::WatchOS: {
312+
case llvm::Triple::WatchOS:
313+
case llvm::Triple::Darwin:
314+
case llvm::Triple::MacOSX: {
301315
Optional<llvm::Triple> targetVariant;
302316
if (const Arg *A = ArgList.getLastArg(options::OPT_target_variant))
303317
targetVariant = llvm::Triple(llvm::Triple::normalize(A->getValue()));

lib/Frontend/CompilerInvocation.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -572,9 +572,22 @@ static bool ParseLangArgs(LangOptions &Opts, ArgList &Args,
572572

573573
llvm::Triple Target = Opts.Target;
574574
StringRef TargetArg;
575+
std::string TargetArgScratch;
576+
575577
if (const Arg *A = Args.getLastArg(OPT_target)) {
576578
Target = llvm::Triple(A->getValue());
577579
TargetArg = A->getValue();
580+
581+
// Backward compatibility hack: infer "simulator" environment for x86
582+
// iOS/tvOS/watchOS. The driver takes care of this for the frontend
583+
// most of the time, but loading of old .swiftinterface files goes
584+
// directly to the frontend.
585+
if (tripleInfersSimulatorEnvironment(Target)) {
586+
// Set the simulator environment.
587+
Target.setEnvironment(llvm::Triple::EnvironmentType::Simulator);
588+
TargetArgScratch = Target.str();
589+
TargetArg = TargetArgScratch;
590+
}
578591
}
579592

580593
if (const Arg *A = Args.getLastArg(OPT_target_variant)) {

lib/IRGen/SwiftTargetInfo.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ static void configureX86_64(IRGenModule &IGM, const llvm::Triple &triple,
6969
SWIFT_ABI_X86_64_SWIFT_SPARE_BITS_MASK);
7070
setToMask(target.IsObjCPointerBit, 64, SWIFT_ABI_X86_64_IS_OBJC_BIT);
7171

72-
if (tripleIsAnySimulator(triple)) {
72+
if (triple.isSimulatorEnvironment()) {
7373
setToMask(target.ObjCPointerReservedBits, 64,
7474
SWIFT_ABI_X86_64_SIMULATOR_OBJC_RESERVED_BITS_MASK);
7575
} else {

lib/SIL/IR/TypeLowering.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3125,6 +3125,7 @@ TypeConverter::checkFunctionForABIDifferences(SILModule &M,
31253125
return ABIDifference::CompatibleRepresentation_ThinToThick;
31263126
}
31273127
}
3128+
31283129
return ABIDifference::NeedsThunk;
31293130
}
31303131

stdlib/public/Platform/Glibc.swift.gyb

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,3 @@ public let ${prefix}_TRUE_MIN = ${type}.leastNonzeroMagnitude
6969
#endif
7070
% end
7171
%end
72-
73-
#if os(WASI)
74-
// WebAssembly's error.h uses a macro that Swift can't import.
75-
public let EINTR:Int32 = 27
76-
public let EINVAL:Int32 = 28
77-
#endif

0 commit comments

Comments
 (0)