Skip to content

Commit 60c68f2

Browse files
committed
Fix patches
1 parent 7862148 commit 60c68f2

File tree

2 files changed

+240
-0
lines changed

2 files changed

+240
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,214 @@
1+
diff --git a/cmake/modules/AddSwift.cmake b/cmake/modules/AddSwift.cmake
2+
index 6d93e52f1d5..9ab79aeb9d6 100644
3+
--- a/cmake/modules/AddSwift.cmake
4+
+++ b/cmake/modules/AddSwift.cmake
5+
@@ -715,6 +715,7 @@ function(add_swift_host_tool executable)
6+
7+
# Include the abi stable system stdlib in our rpath.
8+
list(APPEND RPATH_LIST "/usr/lib/swift")
9+
+ list(APPEND RPATH_LIST "${SWIFTLIB_DIR}")
10+
11+
elseif(BOOTSTRAPPING_MODE STREQUAL "CROSSCOMPILE-WITH-HOSTLIBS")
12+
13+
@@ -731,6 +732,7 @@ function(add_swift_host_tool executable)
14+
15+
# Include the abi stable system stdlib in our rpath.
16+
list(APPEND RPATH_LIST "/usr/lib/swift")
17+
+ list(APPEND RPATH_LIST "@executable_path/../lib")
18+
19+
elseif(BOOTSTRAPPING_MODE STREQUAL "BOOTSTRAPPING-WITH-HOSTLIBS")
20+
# Add the SDK directory for the host platform.
21+
@@ -798,7 +800,7 @@ function(add_swift_host_tool executable)
22+
if(BOOTSTRAPPING_MODE STREQUAL "HOSTTOOLS")
23+
set_target_properties(${executable} PROPERTIES
24+
BUILD_WITH_INSTALL_RPATH YES
25+
- INSTALL_RPATH "${host_lib_dir}")
26+
+ INSTALL_RPATH "${host_lib_dir};$ORIGIN/../lib")
27+
else()
28+
set_target_properties(${executable} PROPERTIES
29+
BUILD_WITH_INSTALL_RPATH YES
30+
diff --git a/include/swift/DriverTool/FrontendObserver.h b/include/swift/DriverTool/FrontendObserver.h
31+
new file mode 100644
32+
index 00000000000..4ac9b299a13
33+
--- /dev/null
34+
+++ b/include/swift/DriverTool/FrontendObserver.h
35+
@@ -0,0 +1,10 @@
36+
+#pragma once
37+
+
38+
+#include "llvm/ADT/ArrayRef.h"
39+
+#include "swift/FrontendTool/FrontendTool.h"
40+
+
41+
+namespace swift {
42+
+
43+
+FrontendObserver* getFrontendObserver(llvm::ArrayRef<const char*> argv);
44+
+
45+
+} // namespace swift
46+
diff --git a/include/swift/FrontendTool/FrontendTool.h b/include/swift/FrontendTool/FrontendTool.h
47+
index 184e6196918..ef5c3eafe69 100644
48+
--- a/include/swift/FrontendTool/FrontendTool.h
49+
+++ b/include/swift/FrontendTool/FrontendTool.h
50+
@@ -53,6 +53,9 @@ public:
51+
/// The frontend has executed the SIL optimization and diagnostics pipelines.
52+
virtual void performedSILProcessing(SILModule &module);
53+
54+
+ /// The frontend has finished executing with the given return value
55+
+ virtual void finished(int status);
56+
+
57+
// TODO: maybe enhance this interface to hear about IRGen and LLVM
58+
// progress.
59+
};
60+
diff --git a/lib/AST/CMakeLists.txt b/lib/AST/CMakeLists.txt
61+
index ec3fa2c853b..34fb6790a60 100644
62+
--- a/lib/AST/CMakeLists.txt
63+
+++ b/lib/AST/CMakeLists.txt
64+
@@ -58,7 +58,6 @@ add_swift_host_library(swiftAST STATIC
65+
GenericParamList.cpp
66+
GenericSignature.cpp
67+
GenericSignatureBuilder.cpp
68+
- Identifier.cpp
69+
ImportCache.cpp
70+
IndexSubset.cpp
71+
InlinableText.cpp
72+
@@ -122,6 +121,14 @@ add_swift_host_library(swiftAST STATIC
73+
${SWIFTAST_LLVM_LINK_COMPONENTS}
74+
)
75+
76+
+add_swift_host_library(swiftIdentifier SHARED
77+
+ Identifier.cpp
78+
+ )
79+
+
80+
+if(${SWIFT_HOST_VARIANT_SDK} IN_LIST SWIFT_DARWIN_PLATFORMS)
81+
+ target_link_options(swiftIdentifier PRIVATE "-undefined dynamic_load")
82+
+endif()
83+
+
84+
if(SWIFT_FORCE_OPTIMIZED_TYPECHECKER)
85+
if(CMAKE_CXX_COMPILER_ID STREQUAL MSVC OR CMAKE_CXX_SIMULATE_ID STREQUAL MSVC)
86+
target_compile_options(swiftAST PRIVATE /O2 /Ob2)
87+
@@ -152,7 +159,7 @@ if(NOT SWIFT_BUILD_ONLY_SYNTAXPARSERLIB)
88+
endif()
89+
90+
target_link_libraries(swiftAST
91+
- PUBLIC swiftBasic
92+
+ PUBLIC swiftBasic swiftIdentifier
93+
PRIVATE swiftSyntax)
94+
if(SWIFT_BUILD_ONLY_SYNTAXPARSERLIB)
95+
# Remove dependencies from clangBasic to avoid bringing along some llvm
96+
diff --git a/lib/DriverTool/CMakeLists.txt b/lib/DriverTool/CMakeLists.txt
97+
index 869c00fece9..21610d8eb95 100644
98+
--- a/lib/DriverTool/CMakeLists.txt
99+
+++ b/lib/DriverTool/CMakeLists.txt
100+
@@ -14,16 +14,24 @@ set(driver_common_libs
101+
swiftSymbolGraphGen
102+
LLVMBitstreamReader)
103+
104+
+add_swift_host_library(swiftFrontendObserver SHARED
105+
+ swift_frontend_observer.cpp)
106+
+target_link_libraries(swiftFrontendObserver
107+
+ PUBLIC
108+
+ swiftFrontendTool)
109+
+
110+
add_swift_host_library(swiftDriverTool STATIC
111+
${driver_sources_and_options}
112+
)
113+
target_link_libraries(swiftDriverTool
114+
PUBLIC
115+
- ${driver_common_libs})
116+
+ ${driver_common_libs}
117+
+ swiftFrontendObserver)
118+
119+
# If building as part of clang, make sure the headers are installed.
120+
if(NOT SWIFT_BUILT_STANDALONE)
121+
add_dependencies(swiftDriverTool clang-resource-headers)
122+
endif()
123+
124+
+set_swift_llvm_is_available(swiftFrontendObserver)
125+
set_swift_llvm_is_available(swiftDriverTool)
126+
diff --git a/lib/DriverTool/driver.cpp b/lib/DriverTool/driver.cpp
127+
index f71e2de9eae..a500e30827f 100644
128+
--- a/lib/DriverTool/driver.cpp
129+
+++ b/lib/DriverTool/driver.cpp
130+
@@ -31,6 +31,7 @@
131+
#include "swift/Frontend/PrintingDiagnosticConsumer.h"
132+
#include "swift/FrontendTool/FrontendTool.h"
133+
#include "swift/DriverTool/DriverTool.h"
134+
+#include "swift/DriverTool/FrontendObserver.h"
135+
#include "llvm/ADT/SmallVector.h"
136+
#include "llvm/Support/CommandLine.h"
137+
#include "llvm/Support/ConvertUTF.h"
138+
@@ -197,7 +198,8 @@ static int run_driver(StringRef ExecName,
139+
if (FirstArg == "-frontend") {
140+
return performFrontend(llvm::makeArrayRef(argv.data()+2,
141+
argv.data()+argv.size()),
142+
- argv[0], (void *)(intptr_t)getExecutablePath);
143+
+ argv[0], (void *)(intptr_t)getExecutablePath,
144+
+ getFrontendObserver(argv));
145+
}
146+
if (FirstArg == "-modulewrap") {
147+
return modulewrap_main(llvm::makeArrayRef(argv.data()+2,
148+
@@ -211,7 +213,8 @@ static int run_driver(StringRef ExecName,
149+
&& ExecName == "swift-frontend") {
150+
return performFrontend(llvm::makeArrayRef(argv.data()+1,
151+
argv.data()+argv.size()),
152+
- argv[0], (void *)(intptr_t)getExecutablePath);
153+
+ argv[0], (void *)(intptr_t)getExecutablePath,
154+
+ getFrontendObserver(argv));
155+
}
156+
157+
if (FirstArg == "repl") {
158+
diff --git a/lib/DriverTool/swift_frontend_observer.cpp b/lib/DriverTool/swift_frontend_observer.cpp
159+
new file mode 100644
160+
index 00000000000..e16b2f970cd
161+
--- /dev/null
162+
+++ b/lib/DriverTool/swift_frontend_observer.cpp
163+
@@ -0,0 +1,9 @@
164+
+#include "swift/DriverTool/FrontendObserver.h"
165+
+
166+
+namespace swift {
167+
+
168+
+FrontendObserver* getFrontendObserver(llvm::ArrayRef<const char*>) {
169+
+ return nullptr;
170+
+}
171+
+
172+
+} // namespace swift
173+
diff --git a/lib/FrontendTool/FrontendTool.cpp b/lib/FrontendTool/FrontendTool.cpp
174+
index 811fb912f8a..afa2034aa71 100644
175+
--- a/lib/FrontendTool/FrontendTool.cpp
176+
+++ b/lib/FrontendTool/FrontendTool.cpp
177+
@@ -1924,7 +1924,7 @@ public:
178+
};
179+
};
180+
181+
-int swift::performFrontend(ArrayRef<const char *> Args,
182+
+static int performFrontendImpl(ArrayRef<const char *> Args,
183+
const char *Argv0, void *MainAddr,
184+
FrontendObserver *observer) {
185+
INITIALIZE_LLVM();
186+
@@ -2263,8 +2263,19 @@ int swift::performFrontend(ArrayRef<const char *> Args,
187+
return r;
188+
}
189+
190+
+int swift::performFrontend(ArrayRef<const char *> Args,
191+
+ const char *Argv0, void *MainAddr,
192+
+ FrontendObserver *observer) {
193+
+ auto ret = performFrontendImpl(Args, Argv0, MainAddr, observer);
194+
+ if (observer) {
195+
+ observer->finished(ret);
196+
+ }
197+
+ return ret;
198+
+}
199+
+
200+
void FrontendObserver::parsedArgs(CompilerInvocation &invocation) {}
201+
void FrontendObserver::configuredCompiler(CompilerInstance &instance) {}
202+
void FrontendObserver::performedSemanticAnalysis(CompilerInstance &instance) {}
203+
void FrontendObserver::performedSILGeneration(SILModule &module) {}
204+
void FrontendObserver::performedSILProcessing(SILModule &module) {}
205+
+void FrontendObserver::finished(int status) {}
206+
diff --git a/tools/driver/CMakeLists.txt b/tools/driver/CMakeLists.txt
207+
index a5dc3ccb845..30667ae51f9 100644
208+
--- a/tools/driver/CMakeLists.txt
209+
+++ b/tools/driver/CMakeLists.txt
210+
@@ -123,4 +123,3 @@ add_dependencies(editor-integration swift-frontend)
211+
swift_install_in_component(FILES "${SWIFT_RUNTIME_OUTPUT_INTDIR}/swift-indent${CMAKE_EXECUTABLE_SUFFIX}"
212+
DESTINATION "bin"
213+
COMPONENT editor-integration)
214+
-
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
diff --git a/lib/Frontend/ModuleInterfaceLoader.cpp b/lib/Frontend/ModuleInterfaceLoader.cpp
2+
index 2a490a680d8..8d8f48aeed0 100644
3+
--- a/lib/Frontend/ModuleInterfaceLoader.cpp
4+
+++ b/lib/Frontend/ModuleInterfaceLoader.cpp
5+
@@ -726,21 +726,6 @@ class ModuleInterfaceLoaderImpl {
6+
<< "; deferring to serialized module loader\n");
7+
UsableModulePath = adjacentMod;
8+
return std::make_error_code(std::errc::not_supported);
9+
- } else if (isInResourceDir(adjacentMod) &&
10+
- loadMode == ModuleLoadingMode::PreferSerialized) {
11+
- // Special-case here: If we're loading a .swiftmodule from the resource
12+
- // dir adjacent to the compiler, defer to the serialized loader instead
13+
- // of falling back. This is mainly to support development of Swift,
14+
- // where one might change the module format version but forget to
15+
- // recompile the standard library. If that happens, don't fall back
16+
- // and silently recompile the standard library -- instead, error like
17+
- // we used to.
18+
- LLVM_DEBUG(llvm::dbgs() << "Found out-of-date module in the "
19+
- "resource-dir at "
20+
- << adjacentMod
21+
- << "; deferring to serialized module loader "
22+
- "to diagnose\n");
23+
- return std::make_error_code(std::errc::not_supported);
24+
} else {
25+
LLVM_DEBUG(llvm::dbgs() << "Found out-of-date module at "
26+
<< adjacentMod << "\n");

0 commit comments

Comments
 (0)