Skip to content

Commit e32fdd4

Browse files
authored
Merge pull request #6 from dsp-testing/redsun82/split-patches
Fix lazy compilation of standard lib in `-resource-dir`
2 parents 6fa3c81 + c3a3eb7 commit e32fdd4

File tree

4 files changed

+63
-12
lines changed

4 files changed

+63
-12
lines changed

patch.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/bash
2+
3+
PATCH_DIR="$(cd "$(dirname "$0")/patches"; pwd)"
4+
5+
for patch_subdir in "$PATCH_DIR"/*; do
6+
(
7+
repo="$(basename "$patch_subdir")"
8+
cd "$repo" || exit 0
9+
echo "patching $repo"
10+
for patch in "$patch_subdir"/*; do
11+
echo " applying $(basename "$patch")"
12+
git apply "$patch"
13+
done
14+
)
15+
done
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
There are some cases when we extract bad ASTs where we hit this assertion if we compile in debug
2+
mode. This is undesirable.
3+
4+
diff --git a/include/swift/AST/Stmt.h b/include/swift/AST/Stmt.h
5+
index 532e038c386..f013eee2f98 100644
6+
--- a/include/swift/AST/Stmt.h
7+
+++ b/include/swift/AST/Stmt.h
8+
@@ -920,7 +920,6 @@ public:
9+
/// Get the CaseStmt block to which the fallthrough transfers control.
10+
/// Set during Sema.
11+
CaseStmt *getFallthroughDest() const {
12+
- assert(FallthroughDest && "fallthrough dest is not set until Sema");
13+
return FallthroughDest;
14+
}
15+
void setFallthroughDest(CaseStmt *C) {

swift-build-system.patch renamed to patches/swift/02-handle-empty-pattern-list.patch

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,6 @@
1-
diff --git a/include/swift/AST/Stmt.h b/include/swift/AST/Stmt.h
2-
index 532e038c386..f013eee2f98 100644
3-
--- a/include/swift/AST/Stmt.h
4-
+++ b/include/swift/AST/Stmt.h
5-
@@ -920,7 +920,6 @@ public:
6-
/// Get the CaseStmt block to which the fallthrough transfers control.
7-
/// Set during Sema.
8-
CaseStmt *getFallthroughDest() const {
9-
- assert(FallthroughDest && "fallthrough dest is not set until Sema");
10-
return FallthroughDest;
11-
}
12-
void setFallthroughDest(CaseStmt *C) {
1+
`PatternBindingDecl::getPatternList()` can in some cases return an empty list, which causes a
2+
segmentation fault when getting the source range. This case needs to be handled for the extractor.
3+
134
diff --git a/lib/AST/Decl.cpp b/lib/AST/Decl.cpp
145
index 75b99a22e73..09115678a82 100644
156
--- a/lib/AST/Decl.cpp
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
When running the extractor against a different version of the swift compiler, we provide it the
2+
original standard library via `-resource-dir`, and we do want that to be lazily compiled out of the
3+
`.swiftinterface` files. The code removed here explicitly disables that behavior.
4+
5+
diff --git a/lib/Frontend/ModuleInterfaceLoader.cpp b/lib/Frontend/ModuleInterfaceLoader.cpp
6+
index 2a490a680d8..8d8f48aeed0 100644
7+
--- a/lib/Frontend/ModuleInterfaceLoader.cpp
8+
+++ b/lib/Frontend/ModuleInterfaceLoader.cpp
9+
@@ -726,21 +726,6 @@ class ModuleInterfaceLoaderImpl {
10+
<< "; deferring to serialized module loader\n");
11+
UsableModulePath = adjacentMod;
12+
return std::make_error_code(std::errc::not_supported);
13+
- } else if (isInResourceDir(adjacentMod) &&
14+
- loadMode == ModuleLoadingMode::PreferSerialized) {
15+
- // Special-case here: If we're loading a .swiftmodule from the resource
16+
- // dir adjacent to the compiler, defer to the serialized loader instead
17+
- // of falling back. This is mainly to support development of Swift,
18+
- // where one might change the module format version but forget to
19+
- // recompile the standard library. If that happens, don't fall back
20+
- // and silently recompile the standard library -- instead, error like
21+
- // we used to.
22+
- LLVM_DEBUG(llvm::dbgs() << "Found out-of-date module in the "
23+
- "resource-dir at "
24+
- << adjacentMod
25+
- << "; deferring to serialized module loader "
26+
- "to diagnose\n");
27+
- return std::make_error_code(std::errc::not_supported);
28+
} else {
29+
LLVM_DEBUG(llvm::dbgs() << "Found out-of-date module at "
30+
<< adjacentMod << "\n");

0 commit comments

Comments
 (0)