Skip to content

Commit 4293772

Browse files
Merge pull request swiftlang#28011 from varungandhi-apple/vg-account-for-duplicate-module-names-in-trace
[Frontend] Avoid crashing in trace emission due to "duplicate" swiftinterfaces
2 parents 2dddfcb + 5771ecb commit 4293772

File tree

2 files changed

+28
-6
lines changed

2 files changed

+28
-6
lines changed

lib/FrontendTool/FrontendTool.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -359,15 +359,15 @@ static void computeSwiftModuleTraceInfo(
359359
// FIXME: The behavior of fs::exists for relative paths is undocumented.
360360
// Use something else instead?
361361
if (fs::exists(moduleAdjacentInterfacePath)) {
362-
err << "Found swiftinterface at\n" << moduleAdjacentInterfacePath
363-
<< "\nbut it was not recorded\n";
364-
errorUnexpectedPath(err);
362+
// This should be an error but it is not because of funkiness around
363+
// compatible modules such as us having both armv7s.swiftinterface
364+
// and armv7.swiftinterface in the dependency tracker.
365+
continue;
365366
}
366367
buffer.clear();
367368

368-
err << "Don't know how to handle the dependency at:\n" << depPath
369-
<< "\nfor module trace emission.\n";
370-
errorUnexpectedPath(err);
369+
// We might land here when we have a arm.swiftmodule in the cache path
370+
// which added a dependency on a arm.swiftinterface (which was not loaded).
371371
}
372372

373373
// Almost a re-implementation of reversePathSortedFilenames :(.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// UNSUPPORTED: -windows-msvc
2+
3+
// RUN: %empty-directory(%t)
4+
// RUN: mkdir -p %t/Mods/Foo.swiftmodule
5+
// RUN: mkdir -p %t/Mods/Bar.swiftmodule
6+
7+
// RUN: %target-swift-frontend %s -DFoo -emit-module -o %t/Mods/Foo.swiftmodule/armv7s-apple-ios.swiftmodule -emit-module-interface-path %t/Mods/Foo.swiftmodule/armv7s-apple-ios.swiftinterface -target armv7s-apple-ios10 -module-name Foo -enable-library-evolution -parse-stdlib
8+
// RUN: %target-swift-frontend %s -DFoo -emit-module -o %t/Mods/Foo.swiftmodule/arm.swiftmodule -emit-module-interface-path %t/Mods/Foo.swiftmodule/arm.swiftinterface -target arm-apple-ios10 -module-name Foo -enable-library-evolution -parse-stdlib
9+
// RUN: %target-swift-frontend %s -DBar -typecheck -emit-module-interface-path %t/Mods/Bar.swiftmodule/arm.swiftinterface -I %t/Mods -target arm-apple-ios10 -module-name Bar -enable-library-evolution -parse-stdlib
10+
// RUN: %target-swift-frontend %s -DFooBar -typecheck -emit-loaded-module-trace-path - -I %t/Mods -target armv7s-apple-ios10 -parse-stdlib
11+
12+
#if Foo
13+
#endif
14+
15+
#if Bar
16+
import Foo
17+
#endif
18+
19+
#if FooBar
20+
import Foo
21+
import Bar
22+
#endif

0 commit comments

Comments
 (0)