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/sanitizers/sanitizers.gni")
9 # Generate Syzygy optimized binaries. Syzygy optimize mode is a profile
10 # guided optimization that reorders code for better locality.
12 is_win && is_official_build && !is_clang && symbol_level == 2
15 assert(!syzygy_optimize || !is_syzyasan,
16 "Don't do both syzygy_optimize and is_syzyasan")
18 # Where the output binaries will be placed.
19 syzygy_dest_dir = "$root_out_dir/syzygy"
21 if (syzygy_optimize) {
22 # Generates a Syzygy optimize target.
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.
31 template("syzygy_optimize") {
33 if (defined(invoker.visibility)) {
34 visibility = invoker.visibility
36 script = "//chrome/tools/build/win/syzygy/reorder.py"
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"
48 "$syzygy_dest_dir/$dll_name.dll",
49 "$syzygy_dest_dir/$dll_name.dll.pdb",
54 rebase_path(input_dll, root_build_dir),
56 rebase_path(input_pdb, root_build_dir),
58 rebase_path(syzygy_dest_dir, root_build_dir),
61 if (defined(invoker.deps)) {
67 syzygy_optimize("chrome_dll_syzygy") {
73 if (is_multi_dll_chrome) {
74 # Also instrument chrome_child.dll.
75 syzygy_optimize("chrome_child_dll_syzygy") {
76 dll_name = "chrome_child"
78 "//chrome:chrome_child",
82 } else if (is_syzyasan) {
83 # Instruments a binary with SyzyAsan.
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.
92 template("syzygy_asan") {
94 if (defined(invoker.visibility)) {
95 visibility = invoker.visibility
97 script = "//chrome/tools/build/win/syzygy/instrument.py"
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"
110 output_filter = "$syzygy_dest_dir/win-syzyasan-filter-$dll_name.txt.json"
113 "$syzygy_dest_dir/$dll_name.dll",
114 "$syzygy_dest_dir/$dll_name.dll.pdb",
121 "--input_executable",
122 rebase_path(input_dll, root_build_dir),
124 rebase_path(input_pdb, root_build_dir),
126 rebase_path(filter, root_build_dir),
127 "--output-filter-file",
128 rebase_path(output_filter, root_build_dir),
130 rebase_path(syzygy_dest_dir, root_build_dir),
134 "//chrome/tools/build/win/syzygy:copy_syzyasan_binaries",
136 if (defined(invoker.deps)) {
139 if (defined(invoker.public_deps)) {
140 public_deps = invoker.public_deps
145 syzygy_asan("chrome_dll_syzygy") {
152 if (is_multi_dll_chrome) {
153 # Also instrument chrome_child.dll.
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
159 syzygy_asan("chrome_child_dll_syzygy") {
160 dll_name = "chrome_child"
162 "//chrome:chrome_child",
165 if (is_official_build) {
166 dest_dir = "$syzygy_dest_dir/instrumented"
167 deps += [ ":chrome_child_dll_syzygy_copy" ]
169 dest_dir = syzygy_dest_dir
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") {
178 "$root_out_dir/chrome_child.dll",
179 "$root_out_dir/chrome_child.dll.pdb",
182 "$syzygy_dest_dir/{{source_file_part}}",
185 "//chrome:chrome_child",
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") {
195 if (is_multi_dll_chrome) {
196 group("chrome_child_dll_syzygy") {
201 if (is_syzyasan || syzygy_optimize) {
202 copy("copy_syzyasan_binaries") {
203 visibility = [ "//chrome/*" ]
205 source_dir = "//third_party/syzygy/binaries/exe"
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",
215 "$syzygy_dest_dir/{{source_file_part}}",
220 # Prevent unused variable warning for code paths where this is unused.
221 assert(syzygy_dest_dir != "")