@@ -51,220 +51,6 @@ index 184e6196918..ef5c3eafe69 100644
5151 /// The frontend has executed the SIL optimization and diagnostics pipelines.
5252 virtual void performedSILProcessing(SILModule &module);
5353
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- -
215- diff --git a/cmake/modules/AddSwift.cmake b/cmake/modules/AddSwift.cmake
216- index 6d93e52f1d5..9ab79aeb9d6 100644
217- --- a/cmake/modules/AddSwift.cmake
218- +++ b/cmake/modules/AddSwift.cmake
219- @@ -715,6 +715,7 @@ function(add_swift_host_tool executable)
220-
221- # Include the abi stable system stdlib in our rpath.
222- list(APPEND RPATH_LIST "/usr/lib/swift")
223- + list(APPEND RPATH_LIST "${SWIFTLIB_DIR}")
224-
225- elseif(BOOTSTRAPPING_MODE STREQUAL "CROSSCOMPILE-WITH-HOSTLIBS")
226-
227- @@ -731,6 +732,7 @@ function(add_swift_host_tool executable)
228-
229- # Include the abi stable system stdlib in our rpath.
230- list(APPEND RPATH_LIST "/usr/lib/swift")
231- + list(APPEND RPATH_LIST "@executable_path/../lib")
232-
233- elseif(BOOTSTRAPPING_MODE STREQUAL "BOOTSTRAPPING-WITH-HOSTLIBS")
234- # Add the SDK directory for the host platform.
235- @@ -798,7 +800,7 @@ function(add_swift_host_tool executable)
236- if(BOOTSTRAPPING_MODE STREQUAL "HOSTTOOLS")
237- set_target_properties(${executable} PROPERTIES
238- BUILD_WITH_INSTALL_RPATH YES
239- - INSTALL_RPATH "${host_lib_dir}")
240- + INSTALL_RPATH "${host_lib_dir};$ORIGIN/../lib")
241- else()
242- set_target_properties(${executable} PROPERTIES
243- BUILD_WITH_INSTALL_RPATH YES
244- diff --git a/include/swift/DriverTool/FrontendObserver.h b/include/swift/DriverTool/FrontendObserver.h
245- new file mode 100644
246- index 00000000000..4ac9b299a13
247- --- /dev/null
248- +++ b/include/swift/DriverTool/FrontendObserver.h
249- @@ -0,0 +1,10 @@
250- + #pragma once
251- +
252- + #include "llvm/ADT/ArrayRef.h"
253- + #include "swift/FrontendTool/FrontendTool.h"
254- +
255- + namespace swift {
256- +
257- + FrontendObserver* getFrontendObserver(llvm::ArrayRef<const char*> argv);
258- +
259- + } // namespace swift
260- diff --git a/include/swift/FrontendTool/FrontendTool.h b/include/swift/FrontendTool/FrontendTool.h
261- index 184e6196918..ef5c3eafe69 100644
262- --- a/include/swift/FrontendTool/FrontendTool.h
263- +++ b/include/swift/FrontendTool/FrontendTool.h
264- @@ -53,6 +53,9 @@ public:
265- /// The frontend has executed the SIL optimization and diagnostics pipelines.
266- virtual void performedSILProcessing(SILModule &module);
267-
26854+ /// The frontend has finished executing with the given return value
26955+ virtual void finished(int status);
27056+
0 commit comments