[Explicit Module Builds] Always rebuild the target module in explicit -compile-module-from-interface builds.

We have long switched to delegate the checking of whether a module is up-to-date to the build system (SwiftDriver) and stopped serializing file dependencies for interface-built binary modules.

Resolves rdar://162881032
This commit is contained in:
Artem Chikin
2025-10-20 10:23:02 -07:00
parent 2af325f2ff
commit 4cdbcb8645
6 changed files with 27 additions and 45 deletions

View File

@@ -273,9 +273,6 @@ namespace swift {
/// Emit a remark when indexing a system module.
bool EnableIndexingSystemModuleRemarks = false;
/// Emit a remark on early exit in explicit interface build
bool EnableSkipExplicitInterfaceModuleBuildRemarks = false;
///
/// Support for alternate usage modes
///

View File

@@ -1478,8 +1478,6 @@ static bool ParseLangArgs(LangOptions &Opts, ArgList &Args,
Opts.EnableMacroLoadingRemarks = Args.hasArg(OPT_remark_macro_loading);
Opts.EnableIndexingSystemModuleRemarks = Args.hasArg(OPT_remark_indexing_system_module);
Opts.EnableSkipExplicitInterfaceModuleBuildRemarks = Args.hasArg(OPT_remark_skip_explicit_interface_build);
if (Args.hasArg(OPT_experimental_skip_non_exportable_decls)) {
// Only allow -experimental-skip-non-exportable-decls if either library
// evolution is enabled (in which case the module's ABI is independent of

View File

@@ -1609,27 +1609,6 @@ bool ModuleInterfaceLoader::buildExplicitSwiftModuleFromSwiftInterface(
StringRef outputPath, bool ShouldSerializeDeps,
ArrayRef<std::string> CompiledCandidates,
DependencyTracker *tracker) {
if (!Instance.getInvocation().getIRGenOptions().AlwaysCompile) {
// 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());
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.
llvm::BumpPtrAllocator alloc;
llvm::StringSaver ArgSaver(alloc);

View File

@@ -14,11 +14,9 @@
// RUN: %target-swift-frontend -scan-dependencies -module-name test -o %t/test.json %s -enable-deterministic-check 2>&1 | %FileCheck %s --check-prefix=DEPSCAN_OUTPUT
/// TODO: Implicit module build use a different compiler instance so it doesn't support checking yet.
// RUN: %target-swift-frontend -typecheck -emit-module-interface-path %t/test.swiftinterface %s -O -enable-deterministic-check 2>&1 | %FileCheck %s --check-prefix=INTERFACE_OUTPUT
/// Hit cache and not emit the second time.
// RUN: rm %t/test.swiftmodule
// RUN: not %target-swift-frontend -compile-module-from-interface %t/test.swiftinterface -explicit-interface-module-build -o %t/test.swiftmodule -enable-deterministic-check 2>&1 | %FileCheck --check-prefix=MODULE_MISMATCH %s
/// Force swiftmodule generation.
// RUN: %target-swift-frontend -compile-module-from-interface %t/test.swiftinterface -explicit-interface-module-build -o %t/test.swiftmodule -enable-deterministic-check -always-compile-output-files 2>&1 | %FileCheck --check-prefix=MODULE_OUTPUT %s
// RUN: %target-swift-frontend -compile-module-from-interface %t/test.swiftinterface -explicit-interface-module-build -o %t/test.swiftmodule -enable-deterministic-check 2>&1 | %FileCheck --check-prefix=MODULE_OUTPUT %s
// RUN: %target-swift-frontend -emit-pcm -module-name UserClangModule -o %t/test.pcm %S/Inputs/dependencies/module.modulemap -enable-deterministic-check 2>&1 | %FileCheck %s --check-prefix=PCM_OUTPUT
@@ -34,7 +32,6 @@
// OBJECT_MISMATCH: error: output file '{{.*}}{{/|\\}}test.o' is missing from second compilation for deterministic check
// DEPSCAN_OUTPUT: remark: produced matching output file '{{.*}}{{/|\\}}test.json'
// INTERFACE_OUTPUT: remark: produced matching output file '{{.*}}{{/|\\}}test.swiftinterface'
// MODULE_MISMATCH: error: output file '{{.*}}{{/|\\}}test.swiftmodule' is missing from second compilation for deterministic check
// PCM_OUTPUT: remark: produced matching output file '{{.*}}{{/|\\}}test.pcm'
public var x = 1

View File

@@ -1,14 +0,0 @@
// 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

View File

@@ -0,0 +1,25 @@
// RUN: %empty-directory(%t)
// RUN: %empty-directory(%t/module-cache)
// RUN: %empty-directory(%t/Foo.swiftmodule)
// RUN: split-file %s %t
// Build module from interface
// RUN: %target-swift-frontend -compile-module-from-interface -o %t/Foo.swiftmodule/Foo.swiftmodule -module-name Foo %t/Foo.swiftmodule/Foo.swiftinterface -explicit-interface-module-build
// Add to the textual interface
// RUN: echo "struct GoodBye {}" >> %t/Foo.swiftmodule/Foo.swiftinterface
// Build module from interface
// RUN: %target-swift-frontend -compile-module-from-interface -o %t/Foo.swiftmodule/Foo.swiftmodule -module-name Foo %t/Foo.swiftmodule/Foo.swiftinterface -explicit-interface-module-build
// Get the list of strings and ensure the binary module reflects the new addition
// RUN: %llvm-strings %t/Foo.swiftmodule/Foo.swiftmodule > %t/module_strings.txt
// RUN: cat %t/module_strings.txt | %FileCheck %s
// CHECK-DAG: Hello
// CHECK-DAG: GoodBye
//--- Foo.swiftmodule/Foo.swiftinterface
// swift-interface-format-version: 1.0
// swift-module-flags: -module-name Foo
struct Hello {}