-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path07-introduce-pluggable-frontend-observer.patch
118 lines (110 loc) · 4.45 KB
/
07-introduce-pluggable-frontend-observer.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
Make calls to `performFrontend` use an observer taken from `getFrontendObserver`, which
is provided by a shared library. Substituting the shared library can plug in our
extractor.
diff --git a/cmake/modules/AddSwift.cmake b/cmake/modules/AddSwift.cmake
index 6d93e52f1d5..10225f40fb1 100644
--- a/cmake/modules/AddSwift.cmake
+++ b/cmake/modules/AddSwift.cmake
@@ -715,6 +715,7 @@ function(add_swift_host_tool executable)
# Include the abi stable system stdlib in our rpath.
list(APPEND RPATH_LIST "/usr/lib/swift")
+ list(APPEND RPATH_LIST "@executable_path/../lib")
elseif(BOOTSTRAPPING_MODE STREQUAL "CROSSCOMPILE-WITH-HOSTLIBS")
@@ -798,7 +799,7 @@ function(add_swift_host_tool executable)
if(BOOTSTRAPPING_MODE STREQUAL "HOSTTOOLS")
set_target_properties(${executable} PROPERTIES
BUILD_WITH_INSTALL_RPATH YES
- INSTALL_RPATH "${host_lib_dir}")
+ INSTALL_RPATH "${host_lib_dir};$ORIGIN/../lib")
else()
set_target_properties(${executable} PROPERTIES
BUILD_WITH_INSTALL_RPATH YES
diff --git a/include/swift/DriverTool/FrontendObserver.h b/include/swift/DriverTool/FrontendObserver.h
new file mode 100644
index 00000000000..4ac9b299a13
--- /dev/null
+++ b/include/swift/DriverTool/FrontendObserver.h
@@ -0,0 +1,10 @@
+#pragma once
+
+#include "llvm/ADT/ArrayRef.h"
+#include "swift/FrontendTool/FrontendTool.h"
+
+namespace swift {
+
+FrontendObserver* getFrontendObserver(llvm::ArrayRef<const char*> argv);
+
+} // namespace swift
diff --git a/lib/DriverTool/CMakeLists.txt b/lib/DriverTool/CMakeLists.txt
index 869c00fece9..b1f49a976d5 100644
--- a/lib/DriverTool/CMakeLists.txt
+++ b/lib/DriverTool/CMakeLists.txt
@@ -14,16 +14,24 @@ set(driver_common_libs
swiftSymbolGraphGen
LLVMBitstreamReader)
+add_swift_host_library(swiftFrontendObserver SHARED
+ swift_frontend_observer.cpp)
+target_link_libraries(swiftFrontendObserver
+ PUBLIC
+ swiftFrontendTool)
+
add_swift_host_library(swiftDriverTool STATIC
${driver_sources_and_options}
)
target_link_libraries(swiftDriverTool
PUBLIC
- ${driver_common_libs})
+ ${driver_common_libs}
+ swiftFrontendObserver)
# If building as part of clang, make sure the headers are installed.
if(NOT SWIFT_BUILT_STANDALONE)
add_dependencies(swiftDriverTool clang-resource-headers)
endif()
+set_swift_llvm_is_available(swiftFrontendObserver)
set_swift_llvm_is_available(swiftDriverTool)
diff --git a/lib/DriverTool/driver.cpp b/lib/DriverTool/driver.cpp
index f71e2de9eae..a500e30827f 100644
--- a/lib/DriverTool/driver.cpp
+++ b/lib/DriverTool/driver.cpp
@@ -31,6 +31,7 @@
#include "swift/Frontend/PrintingDiagnosticConsumer.h"
#include "swift/FrontendTool/FrontendTool.h"
#include "swift/DriverTool/DriverTool.h"
+#include "swift/DriverTool/FrontendObserver.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/ConvertUTF.h"
@@ -197,7 +198,8 @@ static int run_driver(StringRef ExecName,
if (FirstArg == "-frontend") {
return performFrontend(llvm::makeArrayRef(argv.data()+2,
argv.data()+argv.size()),
- argv[0], (void *)(intptr_t)getExecutablePath);
+ argv[0], (void *)(intptr_t)getExecutablePath,
+ getFrontendObserver(argv));
}
if (FirstArg == "-modulewrap") {
return modulewrap_main(llvm::makeArrayRef(argv.data()+2,
@@ -211,7 +213,8 @@ static int run_driver(StringRef ExecName,
&& ExecName == "swift-frontend") {
return performFrontend(llvm::makeArrayRef(argv.data()+1,
argv.data()+argv.size()),
- argv[0], (void *)(intptr_t)getExecutablePath);
+ argv[0], (void *)(intptr_t)getExecutablePath,
+ getFrontendObserver(argv));
}
if (FirstArg == "repl") {
diff --git a/lib/DriverTool/swift_frontend_observer.cpp b/lib/DriverTool/swift_frontend_observer.cpp
new file mode 100644
index 00000000000..e16b2f970cd
--- /dev/null
+++ b/lib/DriverTool/swift_frontend_observer.cpp
@@ -0,0 +1,9 @@
+#include "swift/DriverTool/FrontendObserver.h"
+
+namespace swift {
+
+FrontendObserver* getFrontendObserver(llvm::ArrayRef<const char*>) {
+ return nullptr;
+}
+
+} // namespace swift