File tree Expand file tree Collapse file tree 4 files changed +25
-5
lines changed Expand file tree Collapse file tree 4 files changed +25
-5
lines changed Original file line number Diff line number Diff line change @@ -304,7 +304,12 @@ bool ArgsToFrontendOptionsConverter::convert(
304
304
Diags.diagnose (SourceLoc (), diag::error_invalid_arg_value,
305
305
A->getAsString (Args), A->getValue ());
306
306
}
307
- } else {
307
+ // If swiftinterface doesn't have a flag, let's not set the version
308
+ // to the current compiler version here. This helps us to identify
309
+ // swiftmodules built from swiftinterface generated before introduction
310
+ // of `-swift-compiler-version` flag.
311
+ } else if (Opts.InputMode !=
312
+ FrontendOptions::ParseInputMode::SwiftModuleInterface) {
308
313
Opts.SwiftCompilerVersion .tryParse (version::getCompilerVersion ());
309
314
}
310
315
Original file line number Diff line number Diff line change @@ -1489,8 +1489,10 @@ ModuleDecl *CompilerInstance::getMainModule() const {
1489
1489
if (Invocation.getSILOptions ().EnableSerializePackage )
1490
1490
MainModule->setSerializePackageEnabled ();
1491
1491
1492
- MainModule->setSwiftCompilerVersion (
1493
- Invocation.getFrontendOptions ().SwiftCompilerVersion );
1492
+ if (auto compilerVersion =
1493
+ Invocation.getFrontendOptions ().SwiftCompilerVersion ) {
1494
+ MainModule->setSwiftCompilerVersion (compilerVersion);
1495
+ }
1494
1496
1495
1497
// Register the main module with the AST context.
1496
1498
Context->addLoadedModule (MainModule);
Original file line number Diff line number Diff line change @@ -1141,8 +1141,10 @@ void Serializer::writeHeader() {
1141
1141
}
1142
1142
1143
1143
llvm::VersionTuple compilerVersion = M->getSwiftCompilerVersion ();
1144
- options_block::SwiftCompilerVersionLayout SwiftCompilerVersion (Out);
1145
- SwiftCompilerVersion.emit (ScratchRecord, compilerVersion.getAsString ());
1144
+ if (compilerVersion) {
1145
+ options_block::SwiftCompilerVersionLayout SwiftCompilerVersion (Out);
1146
+ SwiftCompilerVersion.emit (ScratchRecord, compilerVersion.getAsString ());
1147
+ }
1146
1148
1147
1149
if (M->isConcurrencyChecked ()) {
1148
1150
options_block::IsConcurrencyCheckedLayout IsConcurrencyChecked (Out);
Original file line number Diff line number Diff line change 2
2
3
3
/// Build the libraries.
4
4
// RUN: %target-swift-frontend %s \
5
+ // RUN: -module-name Lib \
5
6
// RUN: -emit-module-path %t/Lib.swiftmodule \
6
7
// RUN: -emit-module-interface-path %t/Lib.swiftinterface \
7
8
// RUN: -enable-library-evolution \
20
21
// CHECK-MODULE-OPTION: <SWIFT_COMPILER_VERSION abbrevid={{.*}}/> blob data = '{{.*}}'
21
22
// CHECK-MODULE-OPTION: </OPTIONS_BLOCK>
22
23
24
+ // Drop and rebuilt swiftmodule to make sure that the version is inferred from the interface file.
25
+ // RUN: rm %t/Lib.swiftmodule
26
+ // RUN: %target-swift-frontend -compile-module-from-interface %t/Lib.swiftinterface -o %t/Lib.swiftmodule -module-name Lib
27
+
28
+ /// Check option in swiftmodule
29
+ // RUN: llvm-bcanalyzer --dump %t/Lib.swiftmodule | %FileCheck --check-prefix=CHECK-REBUILT-MODULE-OPTION %s
30
+ // CHECK-REBUILT-MODULE-OPTION: <OPTIONS_BLOCK
31
+ // CHECK-REBUILT-MODULE-OPTION: <SWIFT_COMPILER_VERSION abbrevid={{.*}}/> blob data = '{{.*}}'
32
+ // CHECK-REBUILT-MODULE-OPTION: </OPTIONS_BLOCK>
33
+
23
34
public struct S {
24
35
public var test : Int = 42
25
36
}
You can’t perform that action at this time.
0 commit comments