Skip to content

ModuleInterfaceBuilder: give a more specific error message in case of a compiler mismatch #36928

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 1 commit into from
Apr 16, 2021
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/AST/DiagnosticsSema.def
Original file line number Diff line number Diff line change
Expand Up @@ -728,6 +728,10 @@ ERROR(module_interface_build_failed,Fatal,
"the textual interface may be broken by project issues"
"%select{, differences between compilers (the producer '%3' and this compiler '%4')|}2 or a compiler bug",
(bool, StringRef, bool, StringRef, StringRef))
ERROR(module_interface_build_failed_mismatching_compiler,Fatal,
"failed to build module '%0'; this SDK is not supported by the compiler "
"(the SDK is built with '%1', while this compiler is '%2'). Please select a toolchain which matches the SDK.",
(StringRef, StringRef, StringRef))
ERROR(serialization_malformed_module,Fatal,
"malformed compiled module: %0", (StringRef))
ERROR(serialization_module_too_new,Fatal,
Expand Down
11 changes: 8 additions & 3 deletions lib/Frontend/ModuleInterfaceBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,9 +203,14 @@ bool ModuleInterfaceBuilder::buildSwiftModuleInternal(
getSwiftInterfaceCompilerVersionForCurrentCompiler(
SubInstance.getASTContext());
StringRef emittedByCompiler = info.CompilerVersion;
diagnose(diag::module_interface_build_failed, isTypeChecking,
moduleName, emittedByCompiler == builtByCompiler,
emittedByCompiler, builtByCompiler);
if (!isTypeChecking && emittedByCompiler != builtByCompiler) {
diagnose(diag::module_interface_build_failed_mismatching_compiler,
moduleName, emittedByCompiler, builtByCompiler);
} else {
diagnose(diag::module_interface_build_failed, isTypeChecking,
moduleName, emittedByCompiler == builtByCompiler,
emittedByCompiler, builtByCompiler);
}
}
};

Expand Down
2 changes: 1 addition & 1 deletion test/ModuleInterface/unbuildable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import UnbuildableCurrent
// 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
#else
import UnbuildableFuture
// 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
// 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.
#endif

// 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
Expand Down
2 changes: 1 addition & 1 deletion validation-test/ParseableInterface/failing-overlay.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@

import ImportsOverlay

// 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
// 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.