| OLD | NEW |
| 1 # Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 import("//build/config/chrome_build.gni") | 5 import("//build/config/chrome_build.gni") |
| 6 import("//build/config/compiler/compiler.gni") | 6 import("//build/config/compiler/compiler.gni") |
| 7 import("//build/config/sanitizers/sanitizers.gni") | 7 import("//build/config/sanitizers/sanitizers.gni") |
| 8 | 8 |
| 9 declare_args() { | |
| 10 # Generate Syzygy optimized binaries. Syzygy optimize mode is a profile | |
| 11 # guided optimization that reorders code for better locality. | |
| 12 syzygy_optimize = | |
| 13 is_win && is_official_build && !is_clang && symbol_level == 2 | |
| 14 } | |
| 15 | |
| 16 assert(!syzygy_optimize || !is_syzyasan, | 9 assert(!syzygy_optimize || !is_syzyasan, |
| 17 "Don't do both syzygy_optimize and is_syzyasan") | 10 "Don't do both syzygy_optimize and is_syzyasan") |
| 18 | 11 |
| 19 # Where the output binaries will be placed. | 12 # Where the output binaries will be placed. |
| 20 syzygy_dest_dir = "$root_out_dir/syzygy" | 13 syzygy_dest_dir = "$root_out_dir/syzygy" |
| 21 | 14 |
| 22 if (syzygy_optimize) { | 15 if (syzygy_optimize) { |
| 23 # Generates a Syzygy optimize target. | 16 # Generates a Syzygy optimize target. |
| 24 # | 17 # |
| 25 # dll_name (required) | 18 # dll_name (required) |
| 26 # Name of the DLL to be instrumented, with no extension or path. This | 19 # 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 | 20 # ${dll_name}.dll is assumed to be in the output directory and must be |
| 28 # generated by a dependency of this target. | 21 # generated by a dependency of this target. |
| 29 # | 22 # |
| 30 # deps (required) | 23 # deps (required) |
| 31 # Normal meaning. | 24 # Normal meaning. |
| 25 # |
| 26 # data_deps |
| 27 # Normal meaning. |
| 32 template("syzygy_optimize") { | 28 template("syzygy_optimize") { |
| 33 action(target_name) { | 29 action(target_name) { |
| 34 if (defined(invoker.visibility)) { | 30 if (defined(invoker.visibility)) { |
| 35 visibility = invoker.visibility | 31 visibility = invoker.visibility |
| 36 } | 32 } |
| 37 script = "//chrome/tools/build/win/syzygy/reorder.py" | 33 script = "//chrome/tools/build/win/syzygy/reorder.py" |
| 38 | 34 |
| 39 dll_name = invoker.dll_name | 35 dll_name = invoker.dll_name |
| 40 input_dll = "$root_out_dir/$dll_name.dll" | 36 input_dll = "$root_out_dir/$dll_name.dll" |
| 41 input_pdb = "$root_out_dir/$dll_name.dll.pdb" | 37 input_pdb = "$root_out_dir/$dll_name.dll.pdb" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 52 | 48 |
| 53 args = [ | 49 args = [ |
| 54 "--input_executable", | 50 "--input_executable", |
| 55 rebase_path(input_dll, root_build_dir), | 51 rebase_path(input_dll, root_build_dir), |
| 56 "--input_symbol", | 52 "--input_symbol", |
| 57 rebase_path(input_pdb, root_build_dir), | 53 rebase_path(input_pdb, root_build_dir), |
| 58 "--destination_dir", | 54 "--destination_dir", |
| 59 rebase_path(syzygy_dest_dir, root_build_dir), | 55 rebase_path(syzygy_dest_dir, root_build_dir), |
| 60 ] | 56 ] |
| 61 | 57 |
| 62 if (defined(invoker.deps)) { | 58 forward_variables_from(invoker, |
| 63 deps = invoker.deps | 59 [ |
| 64 } | 60 "deps", |
| 61 "data_deps", |
| 62 "public_deps", |
| 63 ]) |
| 65 } | 64 } |
| 66 } | 65 } |
| 67 | 66 |
| 68 syzygy_optimize("chrome_dll_syzygy") { | 67 syzygy_optimize("chrome_dll_syzygy") { |
| 69 dll_name = "chrome" | 68 dll_name = "chrome" |
| 70 deps = [ | 69 deps = [ |
| 71 "//chrome:main_dll", | 70 "//chrome:main_dll", |
| 72 ] | 71 ] |
| 72 if (is_multi_dll_chrome) { |
| 73 data_deps = [ |
| 74 ":chrome_child_dll_syzygy", |
| 75 ] |
| 76 } |
| 73 } | 77 } |
| 74 if (is_multi_dll_chrome) { | 78 if (is_multi_dll_chrome) { |
| 75 # Also instrument chrome_child.dll. | 79 # Also instrument chrome_child.dll. |
| 76 syzygy_optimize("chrome_child_dll_syzygy") { | 80 syzygy_optimize("chrome_child_dll_syzygy") { |
| 77 dll_name = "chrome_child" | 81 dll_name = "chrome_child" |
| 78 deps = [ | 82 deps = [ |
| 79 "//chrome:chrome_child", | 83 "//chrome:chrome_child", |
| 80 ] | 84 ] |
| 81 } | 85 } |
| 82 } | 86 } |
| 83 } else if (is_syzyasan) { | 87 } else if (is_syzyasan) { |
| 84 # Instruments a binary with SyzyAsan. | 88 # Instruments a binary with SyzyAsan. |
| 85 # | 89 # |
| 86 # dll_name (required) | 90 # binary_name (required) |
| 87 # Name of the DLL to be instrumented, with no extension or path. This | 91 # Name of the binary to be instrumented, with no extension or path. This |
| 88 # ${dll_name}.dll is assumed to be in the output directory and must be | 92 # binary_name is assumed to be in the output directory and must be |
| 89 # generated by a dependency of this target. | 93 # generated by a dependency of this target. |
| 90 # | 94 # |
| 95 # dest_dir (required) |
| 96 # The destination directory where the instrumented image should be |
| 97 # written. |
| 98 # |
| 91 # deps (required) | 99 # deps (required) |
| 92 # Normal meaning. | 100 # Normal meaning. |
| 101 # |
| 102 # public_deps |
| 103 # Normal meaning. |
| 104 # |
| 105 # data_deps |
| 106 # Normal meaning. |
| 93 template("syzygy_asan") { | 107 template("syzygy_asan") { |
| 94 action(target_name) { | 108 action(target_name) { |
| 95 if (defined(invoker.visibility)) { | 109 if (defined(invoker.visibility)) { |
| 96 visibility = invoker.visibility | 110 visibility = invoker.visibility |
| 97 } | 111 } |
| 98 script = "//chrome/tools/build/win/syzygy/instrument.py" | 112 script = "//chrome/tools/build/win/syzygy/instrument.py" |
| 99 | 113 |
| 100 filter = "syzyasan-instrumentation-filter.txt" | 114 filter = "syzyasan-instrumentation-filter.txt" |
| 101 | 115 |
| 102 dll_name = invoker.dll_name | 116 binary_name = invoker.binary_name |
| 103 input_dll = "$root_out_dir/$dll_name.dll" | 117 dest_dir = invoker.dest_dir |
| 104 input_pdb = "$root_out_dir/$dll_name.dll.pdb" | 118 input_image = "$root_out_dir/$binary_name" |
| 119 input_pdb = "$root_out_dir/$binary_name.pdb" |
| 105 | 120 |
| 106 inputs = [ | 121 inputs = [ |
| 107 filter, | 122 filter, |
| 108 input_dll, | 123 input_image, |
| 109 | 124 |
| 110 #input_pdb, | 125 #input_pdb, |
| 111 ] | 126 ] |
| 112 | 127 |
| 113 output_filter = "$syzygy_dest_dir/win-syzyasan-filter-$dll_name.txt.json" | 128 output_filter = "$dest_dir/win-syzyasan-filter-$binary_name.txt.json" |
| 114 | 129 |
| 115 outputs = [ | 130 outputs = [ |
| 116 "$syzygy_dest_dir/$dll_name.dll", | 131 "$dest_dir/$input_image", |
| 117 "$syzygy_dest_dir/$dll_name.dll.pdb", | 132 "$dest_dir/$input_image.pdb", |
| 118 output_filter, | 133 output_filter, |
| 119 ] | 134 ] |
| 120 | 135 |
| 121 args = [ | 136 args = [ |
| 122 "--mode", | 137 "--mode", |
| 123 "asan", | 138 "asan", |
| 124 "--input_executable", | 139 "--input_executable", |
| 125 rebase_path(input_dll, root_build_dir), | 140 rebase_path(input_image, root_build_dir), |
| 126 "--input_symbol", | 141 "--input_symbol", |
| 127 rebase_path(input_pdb, root_build_dir), | 142 rebase_path(input_pdb, root_build_dir), |
| 128 "--filter", | 143 "--filter", |
| 129 rebase_path(filter, root_build_dir), | 144 rebase_path(filter, root_build_dir), |
| 130 "--output-filter-file", | 145 "--output-filter-file", |
| 131 rebase_path(output_filter, root_build_dir), | 146 rebase_path(output_filter, root_build_dir), |
| 132 "--destination_dir", | 147 "--destination_dir", |
| 133 rebase_path(syzygy_dest_dir, root_build_dir), | 148 rebase_path(dest_dir, root_build_dir), |
| 134 ] | 149 ] |
| 135 | 150 |
| 136 deps = [ | 151 deps = [ |
| 137 "//chrome/tools/build/win/syzygy:copy_syzyasan_binaries", | 152 "//chrome/tools/build/win/syzygy:copy_syzyasan_binaries", |
| 138 ] | 153 ] |
| 139 if (defined(invoker.deps)) { | 154 if (defined(invoker.deps)) { |
| 140 deps += invoker.deps | 155 deps += invoker.deps |
| 141 } | 156 } |
| 142 if (defined(invoker.public_deps)) { | 157 forward_variables_from(invoker, |
| 143 public_deps = invoker.public_deps | 158 [ |
| 144 } | 159 "data_deps", |
| 160 "public_deps", |
| 161 ]) |
| 145 } | 162 } |
| 146 } | 163 } |
| 147 | 164 |
| 148 syzygy_asan("chrome_dll_syzygy") { | 165 syzygy_asan("chrome_dll_syzygy") { |
| 149 dll_name = "chrome" | 166 binary_name = "chrome.dll" |
| 167 dest_dir = syzygy_dest_dir |
| 150 deps = [ | 168 deps = [ |
| 151 "//chrome:main_dll", | 169 "//chrome:main_dll", |
| 152 ] | 170 ] |
| 153 } | 171 } |
| 154 | 172 |
| 155 if (is_multi_dll_chrome) { | 173 if (is_multi_dll_chrome) { |
| 156 # Also instrument chrome_child.dll. | 174 # Also instrument chrome_child.dll. |
| 157 # | 175 # |
| 158 # For official builds, the instrumented version will be put into an | 176 # For official builds, the instrumented version will be put into an |
| 159 # "instrumented" subdirectory and the regular output will be | 177 # "instrumented" subdirectory and the regular output will be |
| 160 # uninstrumented. Otherwise, chrome_child is also instrumented to the | 178 # uninstrumented. Otherwise, chrome_child is also instrumented to the |
| 161 # normal place. | 179 # normal place. |
| 162 syzygy_asan("chrome_child_dll_syzygy") { | 180 syzygy_asan("chrome_child_dll_syzygy") { |
| 163 dll_name = "chrome_child" | 181 binary_name = "chrome_child.dll" |
| 164 deps = [ | 182 deps = [ |
| 165 "//chrome:chrome_child", | 183 "//chrome:chrome_child", |
| 166 ] | 184 ] |
| 167 | 185 |
| 168 if (is_official_build) { | 186 if (is_official_build) { |
| 169 dest_dir = "$syzygy_dest_dir/instrumented" | 187 dest_dir = "$syzygy_dest_dir/instrumented" |
| 170 deps += [ ":chrome_child_dll_syzygy_copy" ] | 188 deps += [ ":chrome_child_dll_syzygy_copy" ] |
| 171 } else { | 189 } else { |
| 172 dest_dir = syzygy_dest_dir | 190 dest_dir = syzygy_dest_dir |
| 173 } | 191 } |
| 192 |
| 193 data_deps = [ |
| 194 ":chrome_child_dll_syzygy", |
| 195 ] |
| 174 } | 196 } |
| 175 | 197 |
| 176 if (is_official_build) { | 198 if (is_official_build) { |
| 177 # Copies the uninstrumented chrome_child.dll. | 199 # Copies the uninstrumented chrome_child.dll. |
| 178 # GYP version: chrome/chrome_syzygy.gyp:chrome_child_dll_syzygy_copy | 200 # GYP version: chrome/chrome_syzygy.gyp:chrome_child_dll_syzygy_copy |
| 179 copy("chrome_child_dll_syzygy_copy") { | 201 copy("chrome_child_dll_syzygy_copy") { |
| 180 sources = [ | 202 sources = [ |
| 181 "$root_out_dir/chrome_child.dll", | 203 "$root_out_dir/chrome_child.dll", |
| 182 "$root_out_dir/chrome_child.dll.pdb", | 204 "$root_out_dir/chrome_child.dll.pdb", |
| 183 ] | 205 ] |
| 184 outputs = [ | 206 outputs = [ |
| 185 "$syzygy_dest_dir/{{source_file_part}}", | 207 "$dest_dir/{{source_file_part}}", |
| 186 ] | 208 ] |
| 187 deps = [ | 209 deps = [ |
| 188 "//chrome:chrome_child", | 210 "//chrome:chrome_child", |
| 189 ] | 211 ] |
| 190 } | 212 } |
| 191 } | 213 } |
| 192 } | 214 } |
| 193 } else { | 215 } else { |
| 194 # No syzygy. Generate dummy targets so other targets can unconditionally | 216 # No syzygy. Generate dummy targets so other targets can unconditionally |
| 195 # depend on these without having to duplicate our conditions. | 217 # depend on these without having to duplicate our conditions. |
| (...skipping 19 matching lines...) Expand all Loading... |
| 215 ] | 237 ] |
| 216 | 238 |
| 217 outputs = [ | 239 outputs = [ |
| 218 "$syzygy_dest_dir/{{source_file_part}}", | 240 "$syzygy_dest_dir/{{source_file_part}}", |
| 219 ] | 241 ] |
| 220 } | 242 } |
| 221 } | 243 } |
| 222 | 244 |
| 223 # Prevent unused variable warning for code paths where this is unused. | 245 # Prevent unused variable warning for code paths where this is unused. |
| 224 assert(syzygy_dest_dir != "") | 246 assert(syzygy_dest_dir != "") |
| OLD | NEW |