Skip to content

Commit b696f5a

Browse files
committed
[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.
1 parent db603d8 commit b696f5a

File tree

4 files changed

+14
-11
lines changed

4 files changed

+14
-11
lines changed

include/swift/Option/Options.td

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -304,8 +304,8 @@ def package_description_version: Separate<["-"], "package-description-version">,
304304
MetaVarName<"<vers>">;
305305

306306
def swift_compiler_version : Separate<["-"], "swift-compiler-version">,
307-
Flags<[FrontendOption, HelpHidden, ModuleInterfaceOptionIgnorable]>,
308-
HelpText<"The version of the Swift compiler used to emit swift interface and module">,
307+
Flags<[FrontendOption, HelpHidden]>,
308+
HelpText<"The version of the Swift compiler used to build swift interface and module">,
309309
MetaVarName<"<compvers>">;
310310

311311
def tools_directory : Separate<["-"], "tools-directory">,

lib/Frontend/ModuleInterfaceSupport.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,9 @@ static void printToolVersionAndFlagsComment(raw_ostream &out,
124124
!Opts.PackageFlags.IgnorableFlags.empty())
125125
ignorableFlags.push_back(Opts.PackageFlags.IgnorableFlags);
126126

127+
ignorableFlags.push_back("-swift-compiler-version");
128+
ignorableFlags.push_back(version::getCompilerVersion());
129+
127130
if (!ignorableFlags.empty()) {
128131
out << "// " SWIFT_MODULE_FLAGS_IGNORABLE_KEY ": ";
129132
llvm::interleave(

test/ModuleInterface/ModuleCache/module-cache-diagnostics.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@
6161
// 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
6262
// RUN: %{python} %S/Inputs/check-is-old.py %t/modulecache/OtherModule-*.swiftmodule %t/modulecache/LeafModule-*.swiftmodule
6363
// RUN: %FileCheck %s -check-prefix=CHECK-ERROR <%t/err.txt
64-
// CHECK-ERROR: LeafModule.swiftinterface:7:8: error: no such module 'NotAModule'
65-
// 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
64+
// CHECK-ERROR: LeafModule.swiftinterface:8:8: error: no such module 'NotAModule'
65+
// 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
6666
// 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
6767
//
6868
//
@@ -85,8 +85,8 @@
8585
// 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
8686
// RUN: %{python} %S/Inputs/check-is-old.py %t/modulecache/OtherModule-*.swiftmodule %t/modulecache/LeafModule-*.swiftmodule
8787
// RUN: %FileCheck %s -check-prefix=CHECK-ERROR-INLINE <%t/err-inline.txt
88-
// CHECK-ERROR-INLINE: LeafModule.swiftinterface:6:33: error: cannot find 'unresolved' in scope
89-
// 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
88+
// CHECK-ERROR-INLINE: LeafModule.swiftinterface:7:33: error: cannot find 'unresolved' in scope
89+
// 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
9090
// 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
9191
//
9292
//

test/ModuleInterface/swift-compiler-version-option.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,20 @@
44
// RUN: %target-swift-frontend %s \
55
// RUN: -emit-module-path %t/Lib.swiftmodule \
66
// RUN: -emit-module-interface-path %t/Lib.swiftinterface \
7-
// RUN: -enable-library-evolution -swift-version 6 \
8-
// RUN: -swift-compiler-version 6.0.0.1
7+
// RUN: -enable-library-evolution \
8+
// RUN: -swift-version 6
99

1010
// RUN: %target-swift-typecheck-module-from-interface(%t/Lib.swiftinterface)
1111

1212
/// Check option in swiftinterface
1313
// RUN: cat %t/Lib.swiftinterface | %FileCheck --check-prefix=CHECK-OPTION %s
14-
// CHECK-OPTION: swift-module-flags:
15-
// CHECK-SAME-OPTION: -swift-compiler-version 6.0.0.1
14+
// CHECK-OPTION: swift-module-flags-ignorable:
15+
// CHECK-SAME-OPTION: -swift-compiler-version {{.*}}
1616

1717
/// Check option in swiftmodule
1818
// RUN: llvm-bcanalyzer --dump %t/Lib.swiftmodule | %FileCheck --check-prefix=CHECK-MODULE-OPTION %s
1919
// CHECK-MODULE-OPTION: <OPTIONS_BLOCK
20-
// CHECK-MODULE-OPTION: <SWIFT_COMPILER_VERSION abbrevid={{.*}}/> blob data = '6.0.0.1'
20+
// CHECK-MODULE-OPTION: <SWIFT_COMPILER_VERSION abbrevid={{.*}}/> blob data = '{{.*}}'
2121
// CHECK-MODULE-OPTION: </OPTIONS_BLOCK>
2222

2323
public struct S {

0 commit comments

Comments
 (0)