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.
5 import("//build/config/chrome_build.gni")
6 import("//build/config/compiler/compiler.gni")
7 import("//build/config/sanitizers/sanitizers.gni")
10 # Generate Syzygy optimized binaries. Syzygy optimize mode is a profile
11 # guided optimization that reorders code for better locality.
13 is_win && is_official_build && !is_clang && symbol_level == 2
16 assert(!syzygy_optimize || !is_syzyasan,
17 "Don't do both syzygy_optimize and is_syzyasan")
19 # Where the output binaries will be placed.
20 syzygy_dest_dir = "$root_out_dir/syzygy"
22 if (syzygy_optimize) {
23 # Generates a Syzygy optimize target.
26 # Name of the DLL to be instrumented, with no extension or path. This
27 # ${dll_name}.dll is assumed to be in the output directory and must be
28 # generated by a dependency of this target.
32 template("syzygy_optimize") {
34 if (defined(invoker.visibility)) {
35 visibility = invoker.visibility
37 script = "//chrome/tools/build/win/syzygy/reorder.py"
39 dll_name = invoker.dll_name
40 input_dll = "$root_out_dir/$dll_name.dll"
41 input_pdb = "$root_out_dir/$dll_name.dll.pdb"
49 "$syzygy_dest_dir/$dll_name.dll",
50 "$syzygy_dest_dir/$dll_name.dll.pdb",
55 rebase_path(input_dll, root_build_dir),
57 rebase_path(input_pdb, root_build_dir),
59 rebase_path(syzygy_dest_dir, root_build_dir),
62 if (defined(invoker.deps)) {
68 syzygy_optimize("chrome_dll_syzygy") {
74 if (is_multi_dll_chrome) {
75 # Also instrument chrome_child.dll.
76 syzygy_optimize("chrome_child_dll_syzygy") {
77 dll_name = "chrome_child"
79 "//chrome:chrome_child",
83 } else if (is_syzyasan) {
84 # Instruments a binary with SyzyAsan.
87 # Name of the DLL to be instrumented, with no extension or path. This
88 # ${dll_name}.dll is assumed to be in the output directory and must be
89 # generated by a dependency of this target.
93 template("syzygy_asan") {
95 if (defined(invoker.visibility)) {
96 visibility = invoker.visibility
98 script = "//chrome/tools/build/win/syzygy/instrument.py"
100 filter = "syzyasan-instrumentation-filter.txt"
101 input_dll = "$root_out_dir/$dll_name.dll"
102 input_pdb = "$root_out_dir/$dll_name.dll.pdb"
111 output_filter = "$syzygy_dest_dir/win-syzyasan-filter-$dll_name.txt.json"
114 "$syzygy_dest_dir/$dll_name.dll",
115 "$syzygy_dest_dir/$dll_name.dll.pdb",
122 "--input_executable",
123 rebase_path(input_dll, root_build_dir),
125 rebase_path(input_pdb, root_build_dir),
127 rebase_path(filter, root_build_dir),
128 "--output-filter-file",
129 rebase_path(output_filter, root_build_dir),
131 rebase_path(syzygy_dest_dir, root_build_dir),
135 "//chrome/tools/build/win/syzygy:copy_syzyasan_binaries",
137 if (defined(invoker.deps)) {
140 if (defined(invoker.public_deps)) {
141 public_deps = invoker.public_deps
146 syzygy_asan("chrome_dll_syzygy") {
153 if (is_multi_dll_chrome) {
154 # Also instrument chrome_child.dll.
156 # For official builds, the instrumented version will be put into an
157 # "instrumented" subdirectory and the regular output will be
158 # uninstrumented. Otherwise, chrome_child is also instrumented to the
160 syzygy_asan("chrome_child_dll_syzygy") {
161 dll_name = "chrome_child"
163 "//chrome:chrome_child",
166 if (is_official_build) {
167 dest_dir = "$syzygy_dest_dir/instrumented"
168 deps += [ ":chrome_child_dll_syzygy_copy" ]
170 dest_dir = syzygy_dest_dir
174 if (is_official_build) {
175 # Copies the uninstrumented chrome_child.dll.
176 # GYP version: chrome/chrome_syzygy.gyp:chrome_child_dll_syzygy_copy
177 copy("chrome_child_dll_syzygy_copy") {
179 "$root_out_dir/chrome_child.dll",
180 "$root_out_dir/chrome_child.dll.pdb",
183 "$syzygy_dest_dir/{{source_file_part}}",
186 "//chrome:chrome_child",
192 # No syzygy. Generate dummy targets so other targets can unconditionally
193 # depend on these without having to duplicate our conditions.
194 group("chrome_dll_syzygy") {
196 if (is_multi_dll_chrome) {
197 group("chrome_child_dll_syzygy") {
202 if (is_syzyasan || syzygy_optimize) {
203 copy("copy_syzyasan_binaries") {
204 visibility = [ "//chrome/*" ]
206 source_dir = "//third_party/syzygy/binaries/exe"
209 "$source_dir/agent_logger.exe",
210 "$source_dir/minidump_symbolizer.py",
211 "$source_dir/syzyasan_rtl.dll",
212 "$source_dir/syzyasan_rtl.dll.pdb",
216 "$syzygy_dest_dir/{{source_file_part}}",
221 # Prevent unused variable warning for code paths where this is unused.
222 assert(syzygy_dest_dir != "")