Skip to content

Commit 0f277ac

Browse files
[Frontend] Avoid crashing in trace emission due to "duplicate" swiftinterfaces.
1 parent 406d03b commit 0f277ac

File tree

2 files changed

+26
-6
lines changed

2 files changed

+26
-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: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// RUN: %empty-directory(%t)
2+
// RUN: mkdir -p %t/Mods/Foo.swiftmodule
3+
// RUN: mkdir -p %t/Mods/Bar.swiftmodule
4+
5+
// 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
6+
// 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
7+
// 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
8+
// RUN: %target-swift-frontend %s -DFooBar -typecheck -emit-loaded-module-trace-path - -I %t/Mods -target armv7s-apple-ios10 -parse-stdlib
9+
10+
#if Foo
11+
#endif
12+
13+
#if Bar
14+
import Foo
15+
#endif
16+
17+
#if FooBar
18+
import Foo
19+
import Bar
20+
#endif

0 commit comments

Comments
 (0)