mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[Explicit Modules] On an explicit interface build, early exit if the expected output is up-to-date.
This commit is contained in:
@@ -979,6 +979,10 @@ REMARK(cross_import_added,none,
|
|||||||
REMARK(module_loaded,none,
|
REMARK(module_loaded,none,
|
||||||
"loaded module at %0",
|
"loaded module at %0",
|
||||||
(StringRef))
|
(StringRef))
|
||||||
|
|
||||||
|
REMARK(explicit_interface_build_skipped,none,
|
||||||
|
"Skipped rebuilding module at %0 - up-to-date",
|
||||||
|
(StringRef))
|
||||||
|
|
||||||
WARNING(cannot_find_project_version,none,
|
WARNING(cannot_find_project_version,none,
|
||||||
"cannot find user version number for %0 module '%1'; version number ignored", (StringRef, StringRef))
|
"cannot find user version number for %0 module '%1'; version number ignored", (StringRef, StringRef))
|
||||||
|
|||||||
@@ -215,6 +215,9 @@ namespace swift {
|
|||||||
|
|
||||||
/// Emit a remark after loading a module.
|
/// Emit a remark after loading a module.
|
||||||
bool EnableModuleLoadingRemarks = false;
|
bool EnableModuleLoadingRemarks = false;
|
||||||
|
|
||||||
|
/// Emit a remark on early exit in explicit interface build
|
||||||
|
bool EnableSkipExplicitInterfaceModuleBuildRemarks = false;
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Support for alternate usage modes
|
/// Support for alternate usage modes
|
||||||
|
|||||||
@@ -340,6 +340,10 @@ def remark_loading_module : Flag<["-"], "Rmodule-loading">,
|
|||||||
Flags<[FrontendOption, DoesNotAffectIncrementalBuild]>,
|
Flags<[FrontendOption, DoesNotAffectIncrementalBuild]>,
|
||||||
HelpText<"Emit a remark and file path of each loaded module">;
|
HelpText<"Emit a remark and file path of each loaded module">;
|
||||||
|
|
||||||
|
def remark_skip_explicit_interface_build : Flag<["-"], "Rskip-explicit-interface-build">,
|
||||||
|
Flags<[FrontendOption, DoesNotAffectIncrementalBuild]>,
|
||||||
|
HelpText<"Emit a remark if an explicit module interface invocation has an early exit because the expected output is up-to-date">;
|
||||||
|
|
||||||
def emit_tbd : Flag<["-"], "emit-tbd">,
|
def emit_tbd : Flag<["-"], "emit-tbd">,
|
||||||
HelpText<"Emit a TBD file">,
|
HelpText<"Emit a TBD file">,
|
||||||
Flags<[FrontendOption, NoInteractiveOption, SupplementaryOutput]>;
|
Flags<[FrontendOption, NoInteractiveOption, SupplementaryOutput]>;
|
||||||
|
|||||||
@@ -797,6 +797,8 @@ static bool ParseLangArgs(LangOptions &Opts, ArgList &Args,
|
|||||||
|
|
||||||
Opts.EnableModuleLoadingRemarks = Args.hasArg(OPT_remark_loading_module);
|
Opts.EnableModuleLoadingRemarks = Args.hasArg(OPT_remark_loading_module);
|
||||||
|
|
||||||
|
Opts.EnableSkipExplicitInterfaceModuleBuildRemarks = Args.hasArg(OPT_remark_skip_explicit_interface_build);
|
||||||
|
|
||||||
llvm::Triple Target = Opts.Target;
|
llvm::Triple Target = Opts.Target;
|
||||||
StringRef TargetArg;
|
StringRef TargetArg;
|
||||||
std::string TargetArgScratch;
|
std::string TargetArgScratch;
|
||||||
|
|||||||
@@ -1345,6 +1345,21 @@ bool ModuleInterfaceLoader::buildExplicitSwiftModuleFromSwiftInterface(
|
|||||||
ArrayRef<std::string> CompiledCandidates,
|
ArrayRef<std::string> CompiledCandidates,
|
||||||
DependencyTracker *tracker) {
|
DependencyTracker *tracker) {
|
||||||
|
|
||||||
|
// First, check if the expected output already exists and possibly up-to-date w.r.t.
|
||||||
|
// all of the dependencies it was built with. If so, early exit.
|
||||||
|
UpToDateModuleCheker checker(Instance.getASTContext(),
|
||||||
|
RequireOSSAModules_t(Instance.getSILOptions()));
|
||||||
|
ModuleRebuildInfo rebuildInfo;
|
||||||
|
SmallVector<FileDependency, 3> allDeps;
|
||||||
|
std::unique_ptr<llvm::MemoryBuffer> moduleBuffer;
|
||||||
|
if (checker.swiftModuleIsUpToDate(outputPath, rebuildInfo, allDeps, moduleBuffer)) {
|
||||||
|
if (Instance.getASTContext().LangOpts.EnableSkipExplicitInterfaceModuleBuildRemarks) {
|
||||||
|
Instance.getDiags().diagnose(SourceLoc(),
|
||||||
|
diag::explicit_interface_build_skipped, outputPath);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// Read out the compiler version.
|
// Read out the compiler version.
|
||||||
llvm::BumpPtrAllocator alloc;
|
llvm::BumpPtrAllocator alloc;
|
||||||
llvm::StringSaver ArgSaver(alloc);
|
llvm::StringSaver ArgSaver(alloc);
|
||||||
|
|||||||
@@ -0,0 +1,14 @@
|
|||||||
|
// swift-interface-format-version: 1.0
|
||||||
|
// swift-module-flags: -parse-stdlib
|
||||||
|
|
||||||
|
// RUN: %empty-directory(%t)
|
||||||
|
// RUN: %target-swift-frontend -compile-module-from-interface -module-name ExplicitModule -explicit-interface-module-build -o %/t/ExplicitModule.swiftmodule %s
|
||||||
|
|
||||||
|
// RUN: %target-swift-frontend -compile-module-from-interface -module-name ExplicitModule -explicit-interface-module-build -o %/t/ExplicitModule.swiftmodule %s -Rskip-explicit-interface-build 2>&1 | %FileCheck %s
|
||||||
|
|
||||||
|
import Swift
|
||||||
|
extension Int {
|
||||||
|
public static var fortytwo: Int = 42
|
||||||
|
}
|
||||||
|
|
||||||
|
// CHECK: <unknown>:0: remark: Skipped rebuilding module at {{.*}}ExplicitModule.swiftmodule - up-to-date
|
||||||
Reference in New Issue
Block a user