Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(315)

Side by Side Diff: chrome/tools/build/win/syzygy/BUILD.gn

Issue 1234033005: Add Syzygy support to Windows GN build. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/chrome_syzygy.gyp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 # Copyright 2015 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
4
5 import("//build/config/chrome_build.gni")
6 import("//build/config/sanitizers/sanitizers.gni")
7
8 declare_args() {
9 # Generate Syzygy optimized binaries. Syzygy optimize mode is a profile
10 # guided optimization that reorders code for better locality.
11 syzygy_optimize =
12 is_win && is_official_build && !is_clang && symbol_level == 2
13 }
14
15 assert(!syzygy_optimize || !is_syzyasan,
16 "Don't do both syzygy_optimize and is_syzyasan")
17
18 # Where the output binaries will be placed.
19 syzygy_dest_dir = "$root_out_dir/syzygy"
20
21 if (syzygy_optimize) {
22 # Generates a Syzygy optimize target.
23 #
24 # dll_name (required)
25 # Name of the DLL to be instrumented, with no extension or path. This
26 # ${dll_name}.dll is assumed to be in the output directory and must be
27 # generated by a dependency of this target.
28 #
29 # deps (required)
30 # Normal meaning.
31 template("syzygy_optimize") {
32 action(target_name) {
33 if (defined(invoker.visibility)) {
34 visibility = invoker.visibility
35 }
36 script = "//chrome/tools/build/win/syzygy/reorder.py"
37
38 dll_name = invoker.dll_name
39 input_dll = "$root_out_dir/$dll_name.dll"
40 input_pdb = "$root_out_dir/$dll_name.dll.pdb"
41
42 inputs = [
43 input_dll,
44 #input_pdb,
45 ]
46
47 outputs = [
48 "$syzygy_dest_dir/$dll_name.dll",
49 "$syzygy_dest_dir/$dll_name.dll.pdb",
50 ]
51
52 args = [
53 "--input_executable",
54 rebase_path(input_dll, root_build_dir),
55 "--input_symbol",
56 rebase_path(input_pdb, root_build_dir),
57 "--destination_dir",
58 rebase_path(syzygy_dest_dir, root_build_dir),
59 ]
60
61 if (defined(invoker.deps)) {
62 deps = invoker.deps
63 }
64 }
65 }
66
67 syzygy_optimize("chrome_dll_syzygy") {
68 dll_name = "chrome"
69 deps = [
70 "//chrome:main_dll",
71 ]
72 }
73 if (is_multi_dll_chrome) {
74 # Also instrument chrome_child.dll.
75 syzygy_optimize("chrome_child_dll_syzygy") {
76 dll_name = "chrome_child"
77 deps = [
78 "//chrome:chrome_child",
79 ]
80 }
81 }
82 } else if (is_syzyasan) {
83 # Instruments a binary with SyzyAsan.
84 #
85 # dll_name (required)
86 # Name of the DLL to be instrumented, with no extension or path. This
87 # ${dll_name}.dll is assumed to be in the output directory and must be
88 # generated by a dependency of this target.
89 #
90 # deps (required)
91 # Normal meaning.
92 template("syzygy_asan") {
93 action(target_name) {
94 if (defined(invoker.visibility)) {
95 visibility = invoker.visibility
96 }
97 script = "//chrome/tools/build/win/syzygy/instrument.py"
98
99 filter = "syzyasan-instrumentation-filter.txt"
100 input_dll = "$root_out_dir/$dll_name.dll"
101 input_pdb = "$root_out_dir/$dll_name.dll.pdb"
102
103 inputs = [
104 filter,
105 input_dll,
106
107 #input_pdb,
108 ]
109
110 output_filter = "$syzygy_dest_dir/win-syzyasan-filter-$dll_name.txt.json"
111
112 outputs = [
113 "$syzygy_dest_dir/$dll_name.dll",
114 "$syzygy_dest_dir/$dll_name.dll.pdb",
115 output_filter,
116 ]
117
118 args = [
119 "--mode",
120 "asan",
121 "--input_executable",
122 rebase_path(input_dll, root_build_dir),
123 "--input_symbol",
124 rebase_path(input_pdb, root_build_dir),
125 "--filter",
126 rebase_path(filter, root_build_dir),
127 "--output-filter-file",
128 rebase_path(output_filter, root_build_dir),
129 "--destination_dir",
130 rebase_path(syzygy_dest_dir, root_build_dir),
131 ]
132
133 deps = [
134 "//chrome/tools/build/win/syzygy:copy_syzyasan_binaries",
135 ]
136 if (defined(invoker.deps)) {
137 deps += invoker.deps
138 }
139 if (defined(invoker.public_deps)) {
140 public_deps = invoker.public_deps
141 }
142 }
143 }
144
145 syzygy_asan("chrome_dll_syzygy") {
146 dll_name = "chrome"
147 deps = [
148 "//chrome:main_dll",
149 ]
150 }
151
152 if (is_multi_dll_chrome) {
153 # Also instrument chrome_child.dll.
154 #
155 # For official builds, the instrumented version will be put into an
156 # "instrumented" subdirectory and the regular output will be
157 # uninstrumented. Otherwise, chrome_child is also instrumented to the
158 # normal place.
159 syzygy_asan("chrome_child_dll_syzygy") {
160 dll_name = "chrome_child"
161 deps = [
162 "//chrome:chrome_child",
163 ]
164
165 if (is_official_build) {
166 dest_dir = "$syzygy_dest_dir/instrumented"
167 deps += [ ":chrome_child_dll_syzygy_copy" ]
168 } else {
169 dest_dir = syzygy_dest_dir
170 }
171 }
172
173 if (is_official_build) {
174 # Copies the uninstrumented chrome_child.dll.
175 # GYP version: chrome/chrome_syzygy.gyp:chrome_child_dll_syzygy_copy
176 copy("chrome_child_dll_syzygy_copy") {
177 sources = [
178 "$root_out_dir/chrome_child.dll",
179 "$root_out_dir/chrome_child.dll.pdb",
180 ]
181 outputs = [
182 "$syzygy_dest_dir/{{source_file_part}}",
183 ]
184 deps = [
185 "//chrome:chrome_child",
186 ]
187 }
188 }
189 }
190 } else {
191 # No syzygy. Generate dummy targets so other targets can unconditionally
192 # depend on these without having to duplicate our conditions.
193 group("chrome_dll_syzygy") {
194 }
195 if (is_multi_dll_chrome) {
196 group("chrome_child_dll_syzygy") {
197 }
198 }
199 }
200
201 if (is_syzyasan || syzygy_optimize) {
202 copy("copy_syzyasan_binaries") {
203 visibility = [ "//chrome/*" ]
204
205 source_dir = "//third_party/syzygy/binaries/exe"
206
207 sources = [
208 "$source_dir/agent_logger.exe",
209 "$source_dir/minidump_symbolizer.py",
210 "$source_dir/syzyasan_rtl.dll",
211 "$source_dir/syzyasan_rtl.dll.pdb",
212 ]
213
214 outputs = [
215 "$syzygy_dest_dir/{{source_file_part}}",
216 ]
217 }
218 }
219
220 # Prevent unused variable warning for code paths where this is unused.
221 assert(syzygy_dest_dir != "")
OLDNEW
« no previous file with comments | « chrome/chrome_syzygy.gyp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698