[Frontend] Always print current compiler version in swiftinterface flags

Swiftinterface files are always built with "current" compiler version,
which means that `-swift-compiler-version` has no effect in this context.
This commit is contained in:
Pavel Yaskevich
2024-10-24 16:59:42 -07:00
parent ab4d8f61eb
commit 2d8751badf
4 changed files with 14 additions and 11 deletions

View File

@@ -304,8 +304,8 @@ def package_description_version: Separate<["-"], "package-description-version">,
MetaVarName<"<vers>">; MetaVarName<"<vers>">;
def swift_compiler_version : Separate<["-"], "swift-compiler-version">, def swift_compiler_version : Separate<["-"], "swift-compiler-version">,
Flags<[FrontendOption, HelpHidden, ModuleInterfaceOptionIgnorable]>, Flags<[FrontendOption, HelpHidden]>,
HelpText<"The version of the Swift compiler used to emit swift interface and module">, HelpText<"The version of the Swift compiler used to build swift interface and module">,
MetaVarName<"<compvers>">; MetaVarName<"<compvers>">;
def tools_directory : Separate<["-"], "tools-directory">, def tools_directory : Separate<["-"], "tools-directory">,

View File

@@ -124,6 +124,9 @@ static void printToolVersionAndFlagsComment(raw_ostream &out,
!Opts.PackageFlags.IgnorableFlags.empty()) !Opts.PackageFlags.IgnorableFlags.empty())
ignorableFlags.push_back(Opts.PackageFlags.IgnorableFlags); ignorableFlags.push_back(Opts.PackageFlags.IgnorableFlags);
ignorableFlags.push_back("-swift-compiler-version");
ignorableFlags.push_back(version::getCompilerVersion());
if (!ignorableFlags.empty()) { if (!ignorableFlags.empty()) {
out << "// " SWIFT_MODULE_FLAGS_IGNORABLE_KEY ": "; out << "// " SWIFT_MODULE_FLAGS_IGNORABLE_KEY ": ";
llvm::interleave( llvm::interleave(

View File

@@ -61,8 +61,8 @@
// RUN: not %target-swift-frontend -disable-implicit-concurrency-module-import -disable-implicit-string-processing-module-import -I %t -module-cache-path %t/modulecache -emit-module -o %t/TestModule.swiftmodule -module-name TestModule %s >%t/err.txt 2>&1 // RUN: not %target-swift-frontend -disable-implicit-concurrency-module-import -disable-implicit-string-processing-module-import -I %t -module-cache-path %t/modulecache -emit-module -o %t/TestModule.swiftmodule -module-name TestModule %s >%t/err.txt 2>&1
// RUN: %{python} %S/Inputs/check-is-old.py %t/modulecache/OtherModule-*.swiftmodule %t/modulecache/LeafModule-*.swiftmodule // RUN: %{python} %S/Inputs/check-is-old.py %t/modulecache/OtherModule-*.swiftmodule %t/modulecache/LeafModule-*.swiftmodule
// RUN: %FileCheck %s -check-prefix=CHECK-ERROR <%t/err.txt // RUN: %FileCheck %s -check-prefix=CHECK-ERROR <%t/err.txt
// CHECK-ERROR: LeafModule.swiftinterface:7:8: error: no such module 'NotAModule' // CHECK-ERROR: LeafModule.swiftinterface:8:8: error: no such module 'NotAModule'
// CHECK-ERROR: OtherModule.swiftinterface:4:8: error: failed to build module 'LeafModule' for importation due to the errors above; the textual interface may be broken by project issues or a compiler bug // CHECK-ERROR: OtherModule.swiftinterface:5:8: error: failed to build module 'LeafModule' for importation due to the errors above; the textual interface may be broken by project issues or a compiler bug
// CHECK-ERROR: module-cache-diagnostics.swift:{{[0-9]+}}:8: error: failed to build module 'OtherModule' for importation due to the errors above; the textual interface may be broken by project issues or a compiler bug // CHECK-ERROR: module-cache-diagnostics.swift:{{[0-9]+}}:8: error: failed to build module 'OtherModule' for importation due to the errors above; the textual interface may be broken by project issues or a compiler bug
// //
// //
@@ -85,8 +85,8 @@
// RUN: not %target-swift-frontend -disable-implicit-concurrency-module-import -disable-implicit-string-processing-module-import -I %t -module-cache-path %t/modulecache -emit-module -o %t/TestModule.swiftmodule -module-name TestModule %s >%t/err-inline.txt 2>&1 // RUN: not %target-swift-frontend -disable-implicit-concurrency-module-import -disable-implicit-string-processing-module-import -I %t -module-cache-path %t/modulecache -emit-module -o %t/TestModule.swiftmodule -module-name TestModule %s >%t/err-inline.txt 2>&1
// RUN: %{python} %S/Inputs/check-is-old.py %t/modulecache/OtherModule-*.swiftmodule %t/modulecache/LeafModule-*.swiftmodule // RUN: %{python} %S/Inputs/check-is-old.py %t/modulecache/OtherModule-*.swiftmodule %t/modulecache/LeafModule-*.swiftmodule
// RUN: %FileCheck %s -check-prefix=CHECK-ERROR-INLINE <%t/err-inline.txt // RUN: %FileCheck %s -check-prefix=CHECK-ERROR-INLINE <%t/err-inline.txt
// CHECK-ERROR-INLINE: LeafModule.swiftinterface:6:33: error: cannot find 'unresolved' in scope // CHECK-ERROR-INLINE: LeafModule.swiftinterface:7:33: error: cannot find 'unresolved' in scope
// CHECK-ERROR-INLINE: OtherModule.swiftinterface:4:8: error: failed to build module 'LeafModule' for importation due to the errors above; the textual interface may be broken by project issues or a compiler bug // CHECK-ERROR-INLINE: OtherModule.swiftinterface:5:8: error: failed to build module 'LeafModule' for importation due to the errors above; the textual interface may be broken by project issues or a compiler bug
// CHECK-ERROR-INLINE: module-cache-diagnostics.swift:{{[0-9]+}}:8: error: failed to build module 'OtherModule' for importation due to the errors above; the textual interface may be broken by project issues or a compiler bug // CHECK-ERROR-INLINE: module-cache-diagnostics.swift:{{[0-9]+}}:8: error: failed to build module 'OtherModule' for importation due to the errors above; the textual interface may be broken by project issues or a compiler bug
// //
// //

View File

@@ -4,20 +4,20 @@
// RUN: %target-swift-frontend %s \ // RUN: %target-swift-frontend %s \
// RUN: -emit-module-path %t/Lib.swiftmodule \ // RUN: -emit-module-path %t/Lib.swiftmodule \
// RUN: -emit-module-interface-path %t/Lib.swiftinterface \ // RUN: -emit-module-interface-path %t/Lib.swiftinterface \
// RUN: -enable-library-evolution -swift-version 6 \ // RUN: -enable-library-evolution \
// RUN: -swift-compiler-version 6.0.0.1 // RUN: -swift-version 6
// RUN: %target-swift-typecheck-module-from-interface(%t/Lib.swiftinterface) // RUN: %target-swift-typecheck-module-from-interface(%t/Lib.swiftinterface)
/// Check option in swiftinterface /// Check option in swiftinterface
// RUN: cat %t/Lib.swiftinterface | %FileCheck --check-prefix=CHECK-OPTION %s // RUN: cat %t/Lib.swiftinterface | %FileCheck --check-prefix=CHECK-OPTION %s
// CHECK-OPTION: swift-module-flags: // CHECK-OPTION: swift-module-flags-ignorable:
// CHECK-SAME-OPTION: -swift-compiler-version 6.0.0.1 // CHECK-SAME-OPTION: -swift-compiler-version {{.*}}
/// Check option in swiftmodule /// Check option in swiftmodule
// RUN: llvm-bcanalyzer --dump %t/Lib.swiftmodule | %FileCheck --check-prefix=CHECK-MODULE-OPTION %s // RUN: llvm-bcanalyzer --dump %t/Lib.swiftmodule | %FileCheck --check-prefix=CHECK-MODULE-OPTION %s
// CHECK-MODULE-OPTION: <OPTIONS_BLOCK // CHECK-MODULE-OPTION: <OPTIONS_BLOCK
// CHECK-MODULE-OPTION: <SWIFT_COMPILER_VERSION abbrevid={{.*}}/> blob data = '6.0.0.1' // CHECK-MODULE-OPTION: <SWIFT_COMPILER_VERSION abbrevid={{.*}}/> blob data = '{{.*}}'
// CHECK-MODULE-OPTION: </OPTIONS_BLOCK> // CHECK-MODULE-OPTION: </OPTIONS_BLOCK>
public struct S { public struct S {