Skip to content

[Experimental Dependencies] Add -enable-experimental-dependencies and push it through. #20078

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 2 commits into from
Oct 30, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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: 4 additions & 0 deletions include/swift/Basic/LangOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,10 @@ namespace swift {
/// Whether to verify the parsed syntax tree and emit related diagnostics.
bool VerifySyntaxTree = false;

/// Scaffolding to permit experimentation with finer-grained dependencies
/// and faster rebuilds.
bool EnableExperimentalDependencies = false;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another option is to put this on a SourceFile's ReferencedNameTracker. I'm not sure if that's better since it means putting this flag in FrontendOptions just to pass it through, but it might be easier for whatever implementation you end up with to have the flag right there. Since that's inside the frontend, though, you can always change it later.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good thought, will keep it in mind.


/// Sets the target we are building for and updates platform conditions
/// to match.
///
Expand Down
11 changes: 10 additions & 1 deletion include/swift/Driver/Compilation.h
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,10 @@ class Compilation {
/// limit filelists will be used.
size_t FilelistThreshold;

/// Scaffolding to permit experimentation with finer-grained dependencies and
/// faster rebuilds.
const bool EnableExperimentalDependencies;

template <typename T>
static T *unwrap(const std::unique_ptr<T> &p) {
return p.get();
Expand Down Expand Up @@ -234,7 +238,8 @@ class Compilation {
Optional<unsigned> BatchSizeLimit = None,
bool SaveTemps = false,
bool ShowDriverTimeCompilation = false,
std::unique_ptr<UnifiedStatsReporter> Stats = nullptr);
std::unique_ptr<UnifiedStatsReporter> Stats = nullptr,
bool EnableExperimentalDependencies = false);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Getting convinced we need a CompilationOptions struct, but that doesn't have to be part of this patch.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, good points.

~Compilation();

ToolChain const &getToolChain() const {
Expand Down Expand Up @@ -289,6 +294,10 @@ class Compilation {
EnableIncrementalBuild = false;
}

bool getEnableExperimentalDependencies() const {
return EnableExperimentalDependencies;
}

bool getBatchModeEnabled() const {
return EnableBatchMode;
}
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 @@ -129,6 +129,10 @@ def driver_always_rebuild_dependents :
Flag<["-"], "driver-always-rebuild-dependents">, InternalDebugOpt,
HelpText<"Always rebuild dependents of files that have been modified">;

def enable_experimental_dependencies :
Flag<["-"], "enable-experimental-dependencies">, Flags<[FrontendOption, HelpHidden]>,
HelpText<"Experimental work-in-progress to be more selective about incremental recompilation">;

def driver_mode : Joined<["--"], "driver-mode=">, Flags<[HelpHidden]>,
HelpText<"Set the driver mode to either 'swift' or 'swiftc'">;

Expand Down
7 changes: 5 additions & 2 deletions lib/Driver/Compilation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,8 @@ Compilation::Compilation(DiagnosticEngine &Diags,
Optional<unsigned> BatchSizeLimit,
bool SaveTemps,
bool ShowDriverTimeCompilation,
std::unique_ptr<UnifiedStatsReporter> StatsReporter)
std::unique_ptr<UnifiedStatsReporter> StatsReporter,
bool EnableExperimentalDependencies)
: Diags(Diags), TheToolChain(TC),
TheOutputInfo(OI),
Level(Level),
Expand All @@ -138,7 +139,9 @@ Compilation::Compilation(DiagnosticEngine &Diags,
SaveTemps(SaveTemps),
ShowDriverTimeCompilation(ShowDriverTimeCompilation),
Stats(std::move(StatsReporter)),
FilelistThreshold(FilelistThreshold) {
FilelistThreshold(FilelistThreshold),
EnableExperimentalDependencies(EnableExperimentalDependencies) {

};

static bool writeFilelistIfNecessary(const Job *job, const ArgList &args,
Expand Down
7 changes: 5 additions & 2 deletions lib/Driver/Driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -920,7 +920,9 @@ Driver::buildCompilation(const ToolChain &TC,
ArgList->hasArg(options::OPT_driver_time_compilation);
std::unique_ptr<UnifiedStatsReporter> StatsReporter =
createStatsReporter(ArgList.get(), Inputs, OI, DefaultTargetTriple);

const bool EnableExperimentalDependencies =
ArgList->hasArg(options::OPT_enable_experimental_dependencies);

C = llvm::make_unique<Compilation>(
Diags, TC, OI, Level,
std::move(ArgList),
Expand All @@ -939,7 +941,8 @@ Driver::buildCompilation(const ToolChain &TC,
DriverBatchSizeLimit,
SaveTemps,
ShowDriverTimeCompilation,
std::move(StatsReporter));
std::move(StatsReporter),
EnableExperimentalDependencies);
}

// Construct the graph of Actions.
Expand Down
2 changes: 2 additions & 0 deletions lib/Driver/ToolChains.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,8 @@ static void addCommonFrontendArgs(const ToolChain &TC, const OutputInfo &OI,
inputArgs.AddLastArg(arguments, options::OPT_O_Group);
inputArgs.AddLastArg(arguments, options::OPT_RemoveRuntimeAsserts);
inputArgs.AddLastArg(arguments, options::OPT_AssumeSingleThreaded);
inputArgs.AddLastArg(arguments,
options::OPT_enable_experimental_dependencies);

// Pass on any build config options
inputArgs.AddAllArgs(arguments, options::OPT_D);
Expand Down
3 changes: 3 additions & 0 deletions lib/Frontend/CompilerInvocation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,9 @@ static bool ParseLangArgs(LangOptions &Opts, ArgList &Args,
Opts.BuildSyntaxTree = true;
Opts.VerifySyntaxTree = true;
}

if (Args.hasArg(OPT_enable_experimental_dependencies))
Opts.EnableExperimentalDependencies = true;

Opts.DebuggerSupport |= Args.hasArg(OPT_debugger_support);
if (Opts.DebuggerSupport)
Expand Down