Skip to content

Commit f90f06d

Browse files
authored
Merge pull request #38939 from xymus/emit-module-separately-interface-hash
[Frontend] Generate an interface hash for emit-module-separately jobs
2 parents 8a802bf + fdc7485 commit f90f06d

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

lib/Frontend/Frontend.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1153,10 +1153,10 @@ CompilerInstance::getSourceFileParsingOptions(bool forPrimary) const {
11531153
opts |= SourceFile::ParsingFlags::DisableDelayedBodies;
11541154
}
11551155

1156+
auto typeOpts = getASTContext().TypeCheckerOpts;
11561157
if (forPrimary || isWholeModuleCompilation()) {
11571158
// Disable delayed body parsing for primaries and in WMO, unless
11581159
// forcefully skipping function bodies
1159-
auto typeOpts = getASTContext().TypeCheckerOpts;
11601160
if (typeOpts.SkipFunctionBodies == FunctionBodySkipping::None)
11611161
opts |= SourceFile::ParsingFlags::DisableDelayedBodies;
11621162
} else {
@@ -1165,9 +1165,10 @@ CompilerInstance::getSourceFileParsingOptions(bool forPrimary) const {
11651165
opts |= SourceFile::ParsingFlags::SuppressWarnings;
11661166
}
11671167

1168-
// Enable interface hash computation for primaries, but not in WMO, as it's
1169-
// only currently needed for incremental mode.
1170-
if (forPrimary) {
1168+
// Enable interface hash computation for primaries or emit-module-separately,
1169+
// but not in WMO, as it's only currently needed for incremental mode.
1170+
if (forPrimary ||
1171+
typeOpts.SkipFunctionBodies == FunctionBodySkipping::NonInlinableWithoutTypes) {
11711172
opts |= SourceFile::ParsingFlags::EnableInterfaceHash;
11721173
}
11731174
return opts;

test/InterfaceHash/added_function.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@
44
// RUN: %target-swift-frontend -dump-interface-hash -primary-file %t/b.swift 2> %t/b.hash
55
// RUN: not cmp %t/a.hash %t/b.hash
66

7+
/// We should generate an interface hash for emit-module-separately jobs even
8+
/// with no primaries.
9+
// RUN: %target-swift-frontend -dump-interface-hash %t/b.swift -experimental-skip-non-inlinable-function-bodies-without-types 2> %t/b-emit-module.hash
10+
// RUN: cmp %t/b.hash %t/b-emit-module.hash
11+
712
// BEGIN a.swift
813
func f() {}
914

0 commit comments

Comments
 (0)