Skip to content

Resolve conflicts with master #727

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 20 commits into from
Apr 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
f32a6e2
[stdlib] Buildfix differentiation for OpenBSD.
3405691582 Apr 15, 2020
c3b0232
Add compiler option to *disable* warnings-as-errors
artemcm Apr 17, 2020
5fb9d73
Avoid unnecessary performTypeChecking() in REPL
rintaro Nov 13, 2019
446c6e6
[NFC] Refactor validateTBDIfNeeded
CodaFi Apr 19, 2020
fbbf61f
Revert "[Darwin] Further restrict inference of the simulator environm…
compnerd Apr 19, 2020
f0df467
Merge pull request #31144 from apple/revert-30771-stop-inferring-simu…
shahmishal Apr 20, 2020
423713b
Merge pull request #31135 from CodaFi/replete-with-errors
CodaFi Apr 20, 2020
db3e9fc
Merge pull request #31142 from CodaFi/TBD-TBD
CodaFi Apr 20, 2020
7fb81ea
[Gardening] Const-qualify CompilerInstance::getInvocation()
CodaFi Apr 20, 2020
37f016b
[NFC] Formalize isModuleExternallyConsumed
CodaFi Apr 20, 2020
ad967dd
Merge pull request #31145 from CodaFi/all-bran
CodaFi Apr 20, 2020
00b09c7
More StringRef -> std::string conversion fixes.
MForster Apr 20, 2020
87d3b4d
Merge pull request #31148 from MForster/m/string-fixes
swift-ci Apr 20, 2020
131aede
Devirtualizer: fix a miscompile due to handling of cast instructions.
eeckstein Apr 20, 2020
5a2b42d
[NFC] Fix typo in SerializedModuleLoader.cpp
MaxDesiatov Apr 20, 2020
4f4ed60
Merge pull request #31151 from eeckstein/fix-devirtualizer
eeckstein Apr 20, 2020
82cdf91
Merge pull request #31033 from 3405691582/OpenBSD_Port_BuildfixDiffer…
compnerd Apr 20, 2020
f1885df
Merge pull request #31152 from MaxDesiatov/patch-1
swift-ci Apr 20, 2020
c11f013
Merge pull request #31099 from artemcm/NoWarningsAsErrorsOption
artemcm Apr 20, 2020
e344c58
Merge branch 'swiftwasm' into master
MaxDesiatov Apr 20, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions include/swift/AST/DiagnosticsFrontend.def
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,6 @@ ERROR(error_unsupported_target_arch, none,
ERROR(error_unsupported_opt_for_target, none,
"unsupported option '%0' for target '%1'", (StringRef, StringRef))

WARNING(warning_inferred_simulator_target,none,
"inferring simulator environment for target '%0'; "
"use '-target %1' instead", (StringRef, StringRef))

ERROR(error_argument_not_allowed_with, none,
"argument '%0' is not allowed with '%1'", (StringRef, StringRef))

Expand Down
6 changes: 3 additions & 3 deletions include/swift/Basic/Platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,12 @@ namespace swift {
/// Returns true if the given triple represents watchOS running in a simulator.
bool tripleIsWatchSimulator(const llvm::Triple &triple);

/// Return true if the given triple represents any simulator.
bool tripleIsAnySimulator(const llvm::Triple &triple);

/// Returns true if the given triple represents a macCatalyst environment.
bool tripleIsMacCatalystEnvironment(const llvm::Triple &triple);

/// Determine whether the triple infers the "simulator" environment.
bool tripleInfersSimulatorEnvironment(const llvm::Triple &triple);

/// Returns true if the given -target triple and -target-variant triple
/// can be zippered.
bool triplesAreValidForZippering(const llvm::Triple &target,
Expand Down
22 changes: 18 additions & 4 deletions include/swift/Frontend/Frontend.h
Original file line number Diff line number Diff line change
Expand Up @@ -386,9 +386,25 @@ class CompilerInvocation {

std::string getLdAddCFileOutputPathForWholeModule() const;

public:
/// Given the current configuration of this frontend invocation, a set of
/// supplementary output paths, and a module, compute the appropriate set of
/// serialization options.
///
/// FIXME: The \p module parameter supports the
/// \c SerializeOptionsForDebugging hack.
SerializationOptions
computeSerializationOptions(const SupplementaryOutputPaths &outs,
bool moduleIsPublic) const;
const ModuleDecl *module) const;

/// Returns an approximation of whether the given module could be
/// redistributed and consumed by external clients.
///
/// FIXME: The scope of this computation should be limited entirely to
/// PrintAsObjC. Unfortunately, it has been co-opted to support the
/// \c SerializeOptionsForDebugging hack. Once this information can be
/// transferred from module files to the dSYMs, remove this.
bool isModuleExternallyConsumed(const ModuleDecl *mod) const;
};

/// A class which manages the state and execution of the compiler.
Expand Down Expand Up @@ -555,9 +571,7 @@ class CompilerInstance {
/// Returns true if there was an error during setup.
bool setup(const CompilerInvocation &Invocation);

const CompilerInvocation &getInvocation() {
return Invocation;
}
const CompilerInvocation &getInvocation() const { return Invocation; }

/// If a code completion buffer has been set, returns the corresponding source
/// file.
Expand Down
4 changes: 4 additions & 0 deletions include/swift/Option/Options.td
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,10 @@ def warnings_as_errors : Flag<["-"], "warnings-as-errors">,
Flags<[FrontendOption]>,
HelpText<"Treat warnings as errors">;

def no_warnings_as_errors : Flag<["-"], "no-warnings-as-errors">,
Flags<[FrontendOption]>,
HelpText<"Don't treat warnings as errors">;

def continue_building_after_errors : Flag<["-"], "continue-building-after-errors">,
Flags<[FrontendOption, DoesNotAffectIncrementalBuild]>,
HelpText<"Continue building, even after errors are encountered">;
Expand Down
2 changes: 1 addition & 1 deletion lib/Basic/LangOptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ std::pair<bool, bool> LangOptions::setTarget(llvm::Triple triple) {
// Set the "targetEnvironment" platform condition if targeting a simulator
// environment. Otherwise _no_ value is present for targetEnvironment; it's
// an optional disambiguating refinement of the triple.
if (Target.isSimulatorEnvironment())
if (swift::tripleIsAnySimulator(Target))
addPlatformConditionValue(PlatformConditionKind::TargetEnvironment,
"simulator");

Expand Down
52 changes: 34 additions & 18 deletions lib/Basic/Platform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,39 +19,47 @@
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) {
return triple.isiOS() && !triple.isTvOS() &&
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.
Expand Down Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion lib/Driver/DarwinToolChains.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ toolchains::Darwin::addProfileGenerationArgs(ArgStringList &Arguments,
}

StringRef Sim;
if (Triple.isSimulatorEnvironment()) {
if (tripleIsAnySimulator(Triple)) {
Sim = "sim";
}

Expand Down
27 changes: 7 additions & 20 deletions lib/Driver/Driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,8 @@ static void validateBridgingHeaderArgs(DiagnosticEngine &diags,
static void validateWarningControlArgs(DiagnosticEngine &diags,
const ArgList &args) {
if (args.hasArg(options::OPT_suppress_warnings) &&
args.hasArg(options::OPT_warnings_as_errors)) {
args.hasFlag(options::OPT_warnings_as_errors,
options::OPT_no_warnings_as_errors, false)) {
diags.diagnose(SourceLoc(), diag::error_conflicting_options,
"-warnings-as-errors", "-suppress-warnings");
}
Expand Down Expand Up @@ -264,31 +265,17 @@ 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());
}

llvm::Triple target(DefaultTargetTriple);

// Backward compatibility hack: infer "simulator" environment for x86
// iOS/tvOS/watchOS.
if (tripleInfersSimulatorEnvironment(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;
}
const 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::Darwin:
case llvm::Triple::MacOSX: {
case llvm::Triple::WatchOS: {
Optional<llvm::Triple> targetVariant;
if (const Arg *A = ArgList.getLastArg(options::OPT_target_variant))
targetVariant = llvm::Triple(llvm::Triple::normalize(A->getValue()));
Expand Down
3 changes: 2 additions & 1 deletion lib/Driver/ToolChains.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,8 @@ void ToolChain::addCommonFrontendArgs(const OutputInfo &OI,
inputArgs.AddLastArg(arguments, options::OPT_profile_generate);
inputArgs.AddLastArg(arguments, options::OPT_profile_use);
inputArgs.AddLastArg(arguments, options::OPT_profile_coverage_mapping);
inputArgs.AddLastArg(arguments, options::OPT_warnings_as_errors);
inputArgs.AddAllArgs(arguments, options::OPT_warnings_as_errors,
options::OPT_no_warnings_as_errors);
inputArgs.AddLastArg(arguments, options::OPT_sanitize_EQ);
inputArgs.AddLastArg(arguments, options::OPT_sanitize_recover_EQ);
inputArgs.AddLastArg(arguments, options::OPT_sanitize_coverage_EQ);
Expand Down
47 changes: 32 additions & 15 deletions lib/Frontend/CompilerInvocation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -553,22 +553,9 @@ static bool ParseLangArgs(LangOptions &Opts, ArgList &Args,

llvm::Triple Target = Opts.Target;
StringRef TargetArg;
std::string TargetArgScratch;

if (const Arg *A = Args.getLastArg(OPT_target)) {
Target = llvm::Triple(A->getValue());
TargetArg = A->getValue();

// Backward compatibility hack: infer "simulator" environment for x86
// iOS/tvOS/watchOS. The driver takes care of this for the frontend
// most of the time, but loading of old .swiftinterface files goes
// directly to the frontend.
if (tripleInfersSimulatorEnvironment(Target)) {
// Set the simulator environment.
Target.setEnvironment(llvm::Triple::EnvironmentType::Simulator);
TargetArgScratch = Target.str();
TargetArg = TargetArgScratch;
}
}

if (const Arg *A = Args.getLastArg(OPT_target_variant)) {
Expand Down Expand Up @@ -773,7 +760,8 @@ static bool ParseClangImporterArgs(ClangImporterOptions &Opts,
Opts.PCHDisableValidation |= Args.hasArg(OPT_pch_disable_validation);
}

if (Args.hasArg(OPT_warnings_as_errors))
if (Args.hasFlag(options::OPT_warnings_as_errors,
options::OPT_no_warnings_as_errors, false))
Opts.ExtraArgs.push_back("-Werror");

Opts.DebuggerSupport |= Args.hasArg(OPT_debugger_support);
Expand Down Expand Up @@ -858,7 +846,9 @@ static bool ParseDiagnosticArgs(DiagnosticOptions &Opts, ArgList &Args,
/*Default=*/llvm::sys::Process::StandardErrHasColors());
Opts.FixitCodeForAllDiagnostics |= Args.hasArg(OPT_fixit_all);
Opts.SuppressWarnings |= Args.hasArg(OPT_suppress_warnings);
Opts.WarningsAsErrors |= Args.hasArg(OPT_warnings_as_errors);
Opts.WarningsAsErrors = Args.hasFlag(options::OPT_warnings_as_errors,
options::OPT_no_warnings_as_errors,
false);
Opts.PrintDiagnosticNames |= Args.hasArg(OPT_debug_diagnostic_names);
Opts.PrintEducationalNotes |= Args.hasArg(OPT_print_educational_notes);
Opts.EnableExperimentalFormatting |=
Expand Down Expand Up @@ -1714,3 +1704,30 @@ CompilerInvocation::setUpInputForSILTool(
}
return fileBufOrErr;
}

bool CompilerInvocation::isModuleExternallyConsumed(
const ModuleDecl *mod) const {
// Modules for executables aren't expected to be consumed by other modules.
// This picks up all kinds of entrypoints, including script mode,
// @UIApplicationMain and @NSApplicationMain.
if (mod->hasEntryPoint()) {
return false;
}

// If an implicit Objective-C header was needed to construct this module, it
// must be the product of a library target.
if (!getFrontendOptions().ImplicitObjCHeaderPath.empty()) {
return false;
}

// App extensions are special beasts because they build without entrypoints
// like library targets, but they behave like executable targets because
// their associated modules are not suitable for distribution.
if (mod->getASTContext().LangOpts.EnableAppExtensionRestrictions) {
return false;
}

// FIXME: This is still a lousy approximation of whether the module file will
// be externally consumed.
return true;
}
5 changes: 3 additions & 2 deletions lib/Frontend/Frontend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ CompilerInvocation::getPrivateModuleInterfaceOutputPathForWholeModule() const {
}

SerializationOptions CompilerInvocation::computeSerializationOptions(
const SupplementaryOutputPaths &outs, bool moduleIsPublic) const {
const SupplementaryOutputPaths &outs, const ModuleDecl *module) const {
const FrontendOptions &opts = getFrontendOptions();

SerializationOptions serializationOpts;
Expand All @@ -171,7 +171,8 @@ SerializationOptions CompilerInvocation::computeSerializationOptions(
// so only serialize them if the module isn't going to be shipped to
// the public.
serializationOpts.SerializeOptionsForDebugging =
opts.SerializeOptionsForDebugging.getValueOr(!moduleIsPublic);
opts.SerializeOptionsForDebugging.getValueOr(
!isModuleExternallyConsumed(module));

return serializationOpts;
}
Expand Down
Loading