Skip to content

Commit d49de1a

Browse files
committed
ModuleInterfaceBuilder: give a more specific error message in case of a compiler mismatch
1 parent 7123d26 commit d49de1a

File tree

4 files changed

+14
-5
lines changed

4 files changed

+14
-5
lines changed

include/swift/AST/DiagnosticsSema.def

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -728,6 +728,10 @@ ERROR(module_interface_build_failed,Fatal,
728728
"the textual interface may be broken by project issues"
729729
"%select{, differences between compilers (the producer '%3' and this compiler '%4')|}2 or a compiler bug",
730730
(bool, StringRef, bool, StringRef, StringRef))
731+
ERROR(module_interface_build_failed_mismatching_compiler,Fatal,
732+
"failed to build module '%0'; this SDK is not supported by the compiler "
733+
"(the SDK is built with '%1', while this compiler is '%2'). Please select a toolchain which matches the SDK.",
734+
(StringRef, StringRef, StringRef))
731735
ERROR(serialization_malformed_module,Fatal,
732736
"malformed compiled module: %0", (StringRef))
733737
ERROR(serialization_module_too_new,Fatal,

lib/Frontend/ModuleInterfaceBuilder.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -203,9 +203,14 @@ bool ModuleInterfaceBuilder::buildSwiftModuleInternal(
203203
getSwiftInterfaceCompilerVersionForCurrentCompiler(
204204
SubInstance.getASTContext());
205205
StringRef emittedByCompiler = info.CompilerVersion;
206-
diagnose(diag::module_interface_build_failed, isTypeChecking,
207-
moduleName, emittedByCompiler == builtByCompiler,
208-
emittedByCompiler, builtByCompiler);
206+
if (!isTypeChecking && emittedByCompiler != builtByCompiler) {
207+
diagnose(diag::module_interface_build_failed_mismatching_compiler,
208+
moduleName, emittedByCompiler, builtByCompiler);
209+
} else {
210+
diagnose(diag::module_interface_build_failed, isTypeChecking,
211+
moduleName, emittedByCompiler == builtByCompiler,
212+
emittedByCompiler, builtByCompiler);
213+
}
209214
}
210215
};
211216

test/ModuleInterface/unbuildable.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import UnbuildableCurrent
2929
// CURRENT: unbuildable.swift:[[@LINE-1]]:8: error: failed to build module 'UnbuildableCurrent' for importation due to the errors above; the textual interface may be broken by project issues or a compiler bug
3030
#else
3131
import UnbuildableFuture
32-
// FUTURE: unbuildable.swift:[[@LINE-1]]:8: error: failed to build module 'UnbuildableFuture' for importation due to the errors above; the textual interface may be broken by project issues, differences between compilers (the producer 'NeoTokyoSwift 2000.42' and this compiler '{{.*Swift version.*}}') or a compiler bug
32+
// FUTURE: unbuildable.swift:[[@LINE-1]]:8: error: failed to build module 'UnbuildableFuture'; this SDK is not supported by the compiler (the SDK is built with 'NeoTokyoSwift 2000.42', while this compiler is '{{.*Swift version.*}}'). Please select a toolchain which matches the SDK.
3333
#endif
3434

3535
// CURRENT-VERIFY: UnbuildableCurrent.swiftinterface:1:1: error: failed to verify module interface of 'UnbuildableCurrent' due to the errors above; the textual interface may be broken by project issues or a compiler bug

validation-test/ParseableInterface/failing-overlay.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33

44
import ImportsOverlay
55

6-
// CHECK: HasOverlay.swiftinterface:1:1: error: failed to build module 'HasOverlay' for importation due to the errors above; the textual interface may be broken by project issues, differences between compilers (the producer '(unspecified, file possibly handwritten)' and this compiler '{{.*Swift version.*}}') or a compiler bug
6+
// CHECK: HasOverlay.swiftinterface:1:1: error: failed to build module 'HasOverlay'; this SDK is not supported by the compiler (the SDK is built with '(unspecified, file possibly handwritten)', while this compiler is '{{.*Swift version.*}}'). Please select a toolchain which matches the SDK.

0 commit comments

Comments
 (0)