|
1 |
| -diff --git a/cmake/modules/AddSwift.cmake b/cmake/modules/AddSwift.cmake |
2 |
| -index 6d93e52f1d5..c4fe5b760a8 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 "@executable_path/../lib") |
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..dcd3e95c5ae 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,13 @@ add_swift_host_library(swiftAST STATIC |
73 |
| - ${SWIFTAST_LLVM_LINK_COMPONENTS} |
74 |
| - ) |
75 |
| - |
76 |
| -+add_swift_host_library(swiftIdentifier SHARED |
77 |
| -+ Identifier.cpp |
78 |
| -+ LLVM_LINK_COMPONENTS |
79 |
| -+ core support) |
80 |
| -+ |
81 |
| -+target_link_libraries(swiftIdentifier PUBLIC clangBasic) |
82 |
| -+ |
83 |
| - if(SWIFT_FORCE_OPTIMIZED_TYPECHECKER) |
84 |
| - if(CMAKE_CXX_COMPILER_ID STREQUAL MSVC OR CMAKE_CXX_SIMULATE_ID STREQUAL MSVC) |
85 |
| - target_compile_options(swiftAST PRIVATE /O2 /Ob2) |
86 |
| -@@ -152,7 +158,7 @@ if(NOT SWIFT_BUILD_ONLY_SYNTAXPARSERLIB) |
87 |
| - endif() |
88 |
| - |
89 |
| - target_link_libraries(swiftAST |
90 |
| -- PUBLIC swiftBasic |
91 |
| -+ PUBLIC swiftBasic swiftIdentifier |
92 |
| - PRIVATE swiftSyntax) |
93 |
| - if(SWIFT_BUILD_ONLY_SYNTAXPARSERLIB) |
94 |
| - # Remove dependencies from clangBasic to avoid bringing along some llvm |
95 |
| -diff --git a/lib/DriverTool/CMakeLists.txt b/lib/DriverTool/CMakeLists.txt |
96 |
| -index 869c00fece9..21610d8eb95 100644 |
97 |
| ---- a/lib/DriverTool/CMakeLists.txt |
98 |
| -+++ b/lib/DriverTool/CMakeLists.txt |
99 |
| -@@ -14,16 +14,24 @@ set(driver_common_libs |
100 |
| - swiftSymbolGraphGen |
101 |
| - LLVMBitstreamReader) |
102 |
| - |
103 |
| -+add_swift_host_library(swiftFrontendObserver SHARED |
104 |
| -+ swift_frontend_observer.cpp) |
105 |
| -+target_link_libraries(swiftFrontendObserver |
106 |
| -+ PUBLIC |
107 |
| -+ swiftFrontendTool) |
108 |
| -+ |
109 |
| - add_swift_host_library(swiftDriverTool STATIC |
110 |
| - ${driver_sources_and_options} |
111 |
| - ) |
112 |
| - target_link_libraries(swiftDriverTool |
113 |
| - PUBLIC |
114 |
| -- ${driver_common_libs}) |
115 |
| -+ ${driver_common_libs} |
116 |
| -+ swiftFrontendObserver) |
117 |
| - |
118 |
| - # If building as part of clang, make sure the headers are installed. |
119 |
| - if(NOT SWIFT_BUILT_STANDALONE) |
120 |
| - add_dependencies(swiftDriverTool clang-resource-headers) |
121 |
| - endif() |
122 |
| - |
123 |
| -+set_swift_llvm_is_available(swiftFrontendObserver) |
124 |
| - set_swift_llvm_is_available(swiftDriverTool) |
125 |
| -diff --git a/lib/DriverTool/driver.cpp b/lib/DriverTool/driver.cpp |
126 |
| -index f71e2de9eae..a500e30827f 100644 |
127 |
| ---- a/lib/DriverTool/driver.cpp |
128 |
| -+++ b/lib/DriverTool/driver.cpp |
129 |
| -@@ -31,6 +31,7 @@ |
130 |
| - #include "swift/Frontend/PrintingDiagnosticConsumer.h" |
131 |
| - #include "swift/FrontendTool/FrontendTool.h" |
132 |
| - #include "swift/DriverTool/DriverTool.h" |
133 |
| -+#include "swift/DriverTool/FrontendObserver.h" |
134 |
| - #include "llvm/ADT/SmallVector.h" |
135 |
| - #include "llvm/Support/CommandLine.h" |
136 |
| - #include "llvm/Support/ConvertUTF.h" |
137 |
| -@@ -197,7 +198,8 @@ static int run_driver(StringRef ExecName, |
138 |
| - if (FirstArg == "-frontend") { |
139 |
| - return performFrontend(llvm::makeArrayRef(argv.data()+2, |
140 |
| - argv.data()+argv.size()), |
141 |
| -- argv[0], (void *)(intptr_t)getExecutablePath); |
142 |
| -+ argv[0], (void *)(intptr_t)getExecutablePath, |
143 |
| -+ getFrontendObserver(argv)); |
144 |
| - } |
145 |
| - if (FirstArg == "-modulewrap") { |
146 |
| - return modulewrap_main(llvm::makeArrayRef(argv.data()+2, |
147 |
| -@@ -211,7 +213,8 @@ static int run_driver(StringRef ExecName, |
148 |
| - && ExecName == "swift-frontend") { |
149 |
| - return performFrontend(llvm::makeArrayRef(argv.data()+1, |
150 |
| - argv.data()+argv.size()), |
151 |
| -- argv[0], (void *)(intptr_t)getExecutablePath); |
152 |
| -+ argv[0], (void *)(intptr_t)getExecutablePath, |
153 |
| -+ getFrontendObserver(argv)); |
154 |
| - } |
155 |
| - |
156 |
| - if (FirstArg == "repl") { |
157 |
| -diff --git a/lib/DriverTool/swift_frontend_observer.cpp b/lib/DriverTool/swift_frontend_observer.cpp |
158 |
| -new file mode 100644 |
159 |
| -index 00000000000..e16b2f970cd |
160 |
| ---- /dev/null |
161 |
| -+++ b/lib/DriverTool/swift_frontend_observer.cpp |
162 |
| -@@ -0,0 +1,9 @@ |
163 |
| -+#include "swift/DriverTool/FrontendObserver.h" |
164 |
| -+ |
165 |
| -+namespace swift { |
166 |
| -+ |
167 |
| -+FrontendObserver* getFrontendObserver(llvm::ArrayRef<const char*>) { |
168 |
| -+ return nullptr; |
169 |
| -+} |
170 |
| -+ |
171 |
| -+} // namespace swift |
172 |
| -diff --git a/lib/FrontendTool/FrontendTool.cpp b/lib/FrontendTool/FrontendTool.cpp |
173 |
| -index 811fb912f8a..afa2034aa71 100644 |
174 |
| ---- a/lib/FrontendTool/FrontendTool.cpp |
175 |
| -+++ b/lib/FrontendTool/FrontendTool.cpp |
176 |
| -@@ -1924,7 +1924,7 @@ public: |
177 |
| - }; |
178 |
| - }; |
179 |
| - |
180 |
| --int swift::performFrontend(ArrayRef<const char *> Args, |
181 |
| -+static int performFrontendImpl(ArrayRef<const char *> Args, |
182 |
| - const char *Argv0, void *MainAddr, |
183 |
| - FrontendObserver *observer) { |
184 |
| - INITIALIZE_LLVM(); |
185 |
| -@@ -2263,8 +2263,19 @@ int swift::performFrontend(ArrayRef<const char *> Args, |
186 |
| - return r; |
187 |
| - } |
188 |
| - |
189 |
| -+int swift::performFrontend(ArrayRef<const char *> Args, |
190 |
| -+ const char *Argv0, void *MainAddr, |
191 |
| -+ FrontendObserver *observer) { |
192 |
| -+ auto ret = performFrontendImpl(Args, Argv0, MainAddr, observer); |
193 |
| -+ if (observer) { |
194 |
| -+ observer->finished(ret); |
195 |
| -+ } |
196 |
| -+ return ret; |
197 |
| -+} |
198 |
| -+ |
199 |
| - void FrontendObserver::parsedArgs(CompilerInvocation &invocation) {} |
200 |
| - void FrontendObserver::configuredCompiler(CompilerInstance &instance) {} |
201 |
| - void FrontendObserver::performedSemanticAnalysis(CompilerInstance &instance) {} |
202 |
| - void FrontendObserver::performedSILGeneration(SILModule &module) {} |
203 |
| - void FrontendObserver::performedSILProcessing(SILModule &module) {} |
204 |
| -+void FrontendObserver::finished(int status) {} |
205 |
| -diff --git a/tools/driver/CMakeLists.txt b/tools/driver/CMakeLists.txt |
206 |
| -index a5dc3ccb845..30667ae51f9 100644 |
207 |
| ---- a/tools/driver/CMakeLists.txt |
208 |
| -+++ b/tools/driver/CMakeLists.txt |
209 |
| -@@ -123,4 +123,3 @@ add_dependencies(editor-integration swift-frontend) |
210 |
| - swift_install_in_component(FILES "${SWIFT_RUNTIME_OUTPUT_INTDIR}/swift-indent${CMAKE_EXECUTABLE_SUFFIX}" |
211 |
| - DESTINATION "bin" |
212 |
| - COMPONENT editor-integration) |
213 |
| -- |
0 commit comments