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

Side by Side Diff: build/toolchain/gcc_toolchain.gni

Issue 2175413004: Enable whitelist generation for all builds. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Enable whitelist generation for official builds. Created 4 years, 4 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
OLDNEW
1 # Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 # Copyright (c) 2013 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/clang/clang.gni") 5 import("//build/config/clang/clang.gni")
6 import("//build/config/nacl/config.gni") 6 import("//build/config/nacl/config.gni")
7 import("//build/config/sanitizers/sanitizers.gni") 7 import("//build/config/sanitizers/sanitizers.gni")
8 import("//build/config/v8_target_cpu.gni") 8 import("//build/config/v8_target_cpu.gni")
9 import("//build/toolchain/cc_wrapper.gni") 9 import("//build/toolchain/cc_wrapper.gni")
10 import("//build/toolchain/goma.gni") 10 import("//build/toolchain/goma.gni")
11 import("//build/toolchain/toolchain.gni") 11 import("//build/toolchain/toolchain.gni")
12 import("//build/toolchain/concurrent_links.gni") 12 import("//build/toolchain/concurrent_links.gni")
13 import("//tools/grit/grit_rule.gni")
13 14
14 # This template defines a toolchain for something that works like gcc 15 # This template defines a toolchain for something that works like gcc
15 # (including clang). 16 # (including clang).
16 # 17 #
17 # It requires the following variables specifying the executables to run: 18 # It requires the following variables specifying the executables to run:
18 # - ar 19 # - ar
19 # - cc 20 # - cc
20 # - cxx 21 # - cxx
21 # - ld 22 # - ld
22 # and the following which is used in the toolchain_args 23 # and the following which is used in the toolchain_args
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 } 217 }
217 218
218 # These library switches can apply to all tools below. 219 # These library switches can apply to all tools below.
219 lib_switch = "-l" 220 lib_switch = "-l"
220 lib_dir_switch = "-L" 221 lib_dir_switch = "-L"
221 222
222 # Object files go in this directory. 223 # Object files go in this directory.
223 object_subdir = "{{target_out_dir}}/{{label_name}}" 224 object_subdir = "{{target_out_dir}}/{{label_name}}"
224 225
225 tool("cc") { 226 tool("cc") {
227 whitelist_flag = " "
228 if (enable_resource_whitelist_generation) {
229 whitelist_flag = " --resource-whitelist=\"{{output}}.whitelist\""
230 }
226 depfile = "{{output}}.d" 231 depfile = "{{output}}.d"
227 command = "$cc -MMD -MF $depfile ${rebuild_string}{{defines}} {{include_di rs}} {{cflags}} {{cflags_c}}${extra_cppflags}${extra_cflags} -c {{source}} -o {{ output}}" 232 command = "$cc -MMD -MF $depfile ${rebuild_string}{{defines}} {{include_di rs}} {{cflags}} {{cflags_c}}${extra_cppflags}${extra_cflags} -c {{source}} -o {{ output}}"
228 depsformat = "gcc" 233 depsformat = "gcc"
229 description = "CC {{output}}" 234 description = "CC {{output}}"
230 outputs = [ 235 outputs = [
236 # The whitelist file is also an output, but ninja does not
237 # currently support multiple outputs for tool("cc").
231 "$object_subdir/{{source_name_part}}.o", 238 "$object_subdir/{{source_name_part}}.o",
232 ] 239 ]
240 compile_wrapper = rebase_path("//build/toolchain/gcc_compile_wrapper.py",
241 root_build_dir)
242 command = "$python_path \"$compile_wrapper\"$whitelist_flag $command"
233 } 243 }
234 244
235 tool("cxx") { 245 tool("cxx") {
246 whitelist_flag = " "
247 if (enable_resource_whitelist_generation) {
248 whitelist_flag = " --resource-whitelist=\"{{output}}.whitelist\""
249 }
236 depfile = "{{output}}.d" 250 depfile = "{{output}}.d"
237 command = "$cxx -MMD -MF $depfile ${rebuild_string}{{defines}} {{include_d irs}} {{cflags}} {{cflags_cc}}${extra_cppflags}${extra_cxxflags} -c {{source}} - o {{output}}" 251 command = "$cxx -MMD -MF $depfile ${rebuild_string}{{defines}} {{include_d irs}} {{cflags}} {{cflags_cc}}${extra_cppflags}${extra_cxxflags} -c {{source}} - o {{output}}"
238 depsformat = "gcc" 252 depsformat = "gcc"
239 description = "CXX {{output}}" 253 description = "CXX {{output}}"
240 outputs = [ 254 outputs = [
255 # The whitelist file is also an output, but ninja does not
256 # currently support multiple outputs for tool("cxx").
241 "$object_subdir/{{source_name_part}}.o", 257 "$object_subdir/{{source_name_part}}.o",
242 ] 258 ]
259 compile_wrapper = rebase_path("//build/toolchain/gcc_compile_wrapper.py",
260 root_build_dir)
261 command = "$python_path \"$compile_wrapper\"$whitelist_flag $command"
243 } 262 }
244 263
245 tool("asm") { 264 tool("asm") {
246 # For GCC we can just use the C compiler to compile assembly. 265 # For GCC we can just use the C compiler to compile assembly.
247 depfile = "{{output}}.d" 266 depfile = "{{output}}.d"
248 command = "$cc -MMD -MF $depfile ${rebuild_string}{{defines}} {{include_di rs}} {{asmflags}} -c {{source}} -o {{output}}" 267 command = "$cc -MMD -MF $depfile ${rebuild_string}{{defines}} {{include_di rs}} {{asmflags}} -c {{source}} -o {{output}}"
249 depsformat = "gcc" 268 depsformat = "gcc"
250 description = "ASM {{output}}" 269 description = "ASM {{output}}"
251 outputs = [ 270 outputs = [
252 "$object_subdir/{{source_name_part}}.o", 271 "$object_subdir/{{source_name_part}}.o",
253 ] 272 ]
254 } 273 }
255 274
256 tool("alink") { 275 tool("alink") {
257 rspfile = "{{output}}.rsp" 276 rspfile = "{{output}}.rsp"
277 whitelist_flag = " "
278 if (enable_resource_whitelist_generation) {
279 whitelist_flag = " --resource-whitelist=\"{{output}}.whitelist\""
280 }
258 281
259 # This needs a Python script to avoid using simple sh features in this 282 # This needs a Python script to avoid using simple sh features in this
260 # command, in case the host does not use a POSIX shell (e.g. compiling 283 # command, in case the host does not use a POSIX shell (e.g. compiling
261 # POSIX-like toolchains such as NaCl on Windows). 284 # POSIX-like toolchains such as NaCl on Windows).
262 ar_wrapper = 285 ar_wrapper =
263 rebase_path("//build/toolchain/gcc_ar_wrapper.py", root_build_dir) 286 rebase_path("//build/toolchain/gcc_ar_wrapper.py", root_build_dir)
264 command = "$python_path \"$ar_wrapper\" --output={{output}} --ar=\"$ar\" { {arflags}} rcsD @\"$rspfile\"" 287 command = "$python_path \"$ar_wrapper\"$whitelist_flag --output={{output}} --ar=\"$ar\" {{arflags}} rcsD @\"$rspfile\""
265 description = "AR {{output}}" 288 description = "AR {{output}}"
266 rspfile_content = "{{inputs}}" 289 rspfile_content = "{{inputs}}"
267 outputs = [ 290 outputs = [
268 "{{output_dir}}/{{target_output_name}}{{output_extension}}", 291 "{{output_dir}}/{{target_output_name}}{{output_extension}}",
269 ] 292 ]
270 293
271 # Shared libraries go in the target out directory by default so we can 294 # Shared libraries go in the target out directory by default so we can
272 # generate different targets with the same name and not have them collide. 295 # generate different targets with the same name and not have them collide.
273 default_output_dir = "{{target_out_dir}}" 296 default_output_dir = "{{target_out_dir}}"
274 default_output_extension = ".a" 297 default_output_extension = ".a"
275 output_prefix = "lib" 298 output_prefix = "lib"
276 } 299 }
277 300
278 tool("solink") { 301 tool("solink") {
279 soname = "{{target_output_name}}{{output_extension}}" # e.g. "libfoo.so". 302 soname = "{{target_output_name}}{{output_extension}}" # e.g. "libfoo.so".
280 sofile = "{{output_dir}}/$soname" # Possibly including toolchain dir. 303 sofile = "{{output_dir}}/$soname" # Possibly including toolchain dir.
281 rspfile = sofile + ".rsp" 304 rspfile = sofile + ".rsp"
305 whitelist_flag = " "
306 if (enable_resource_whitelist_generation) {
307 whitelist_file = "$sofile.whitelist"
308 whitelist_flag = " --resource-whitelist=\"$whitelist_file\""
309 }
282 310
283 if (defined(invoker.strip)) { 311 if (defined(invoker.strip)) {
284 unstripped_sofile = "{{root_out_dir}}/lib.unstripped/$soname" 312 unstripped_sofile = "{{root_out_dir}}/lib.unstripped/$soname"
285 } else { 313 } else {
286 unstripped_sofile = sofile 314 unstripped_sofile = sofile
287 } 315 }
288 316
289 # These variables are not built into GN but are helpers that 317 # These variables are not built into GN but are helpers that
290 # implement (1) linking to produce a .so, (2) extracting the symbols 318 # implement (1) linking to produce a .so, (2) extracting the symbols
291 # from that file (3) if the extracted list differs from the existing 319 # from that file (3) if the extracted list differs from the existing
292 # .TOC file, overwrite it, otherwise, don't change it. 320 # .TOC file, overwrite it, otherwise, don't change it.
293 tocfile = sofile + ".TOC" 321 tocfile = sofile + ".TOC"
294 322
295 link_command = "$ld -shared {{ldflags}}${extra_ldflags} -o \"$unstripped_s ofile\" -Wl,-soname=\"$soname\" @\"$rspfile\"" 323 link_command = "$ld -shared {{ldflags}}${extra_ldflags} -o \"$unstripped_s ofile\" -Wl,-soname=\"$soname\" @\"$rspfile\""
296 324
297 assert(defined(readelf), "to solink you must have a readelf") 325 assert(defined(readelf), "to solink you must have a readelf")
298 assert(defined(nm), "to solink you must have an nm") 326 assert(defined(nm), "to solink you must have an nm")
299 strip_switch = "" 327 strip_switch = ""
300 if (defined(invoker.strip)) { 328 if (defined(invoker.strip)) {
301 strip_switch = "--strip=${invoker.strip}" 329 strip_switch = "--strip=${invoker.strip}"
302 } 330 }
303 331
304 # This needs a Python script to avoid using a complex shell command 332 # This needs a Python script to avoid using a complex shell command
305 # requiring sh control structures, pipelines, and POSIX utilities. 333 # requiring sh control structures, pipelines, and POSIX utilities.
306 # The host might not have a POSIX shell and utilities (e.g. Windows). 334 # The host might not have a POSIX shell and utilities (e.g. Windows).
307 solink_wrapper = rebase_path("//build/toolchain/gcc_solink_wrapper.py") 335 solink_wrapper = rebase_path("//build/toolchain/gcc_solink_wrapper.py")
308 command = "$python_path \"$solink_wrapper\" --readelf=\"$readelf\" --nm=\" $nm\" $strip_switch --sofile=\"$unstripped_sofile\" --tocfile=\"$tocfile\" --out put=\"$sofile\" -- $link_command" 336 command = "$python_path \"$solink_wrapper\" --readelf=\"$readelf\" --nm=\" $nm\" $strip_switch --sofile=\"$unstripped_sofile\" --tocfile=\"$tocfile\" --out put=\"$sofile\"$whitelist_flag -- $link_command"
309 337
310 rspfile_content = "-Wl,--whole-archive {{inputs}} {{solibs}} -Wl,--no-whol e-archive $solink_libs_section_prefix {{libs}} $solink_libs_section_postfix" 338 rspfile_content = "-Wl,--whole-archive {{inputs}} {{solibs}} -Wl,--no-whol e-archive $solink_libs_section_prefix {{libs}} $solink_libs_section_postfix"
311 339
312 description = "SOLINK $sofile" 340 description = "SOLINK $sofile"
313 341
314 # Use this for {{output_extension}} expansions unless a target manually 342 # Use this for {{output_extension}} expansions unless a target manually
315 # overrides it (in which case {{output_extension}} will be what the target 343 # overrides it (in which case {{output_extension}} will be what the target
316 # specifies). 344 # specifies).
317 default_output_extension = default_shlib_extension 345 default_output_extension = default_shlib_extension
318 346
319 default_output_dir = "{{root_out_dir}}" 347 default_output_dir = "{{root_out_dir}}"
320 if (shlib_subdir != ".") { 348 if (shlib_subdir != ".") {
321 default_output_dir += "/$shlib_subdir" 349 default_output_dir += "/$shlib_subdir"
322 } 350 }
323 351
324 output_prefix = "lib" 352 output_prefix = "lib"
325 353
326 # Since the above commands only updates the .TOC file when it changes, ask 354 # Since the above commands only updates the .TOC file when it changes, ask
327 # Ninja to check if the timestamp actually changed to know if downstream 355 # Ninja to check if the timestamp actually changed to know if downstream
328 # dependencies should be recompiled. 356 # dependencies should be recompiled.
329 restat = true 357 restat = true
330 358
331 # Tell GN about the output files. It will link to the sofile but use the 359 # Tell GN about the output files. It will link to the sofile but use the
332 # tocfile for dependency management. 360 # tocfile for dependency management.
333 outputs = [ 361 outputs = [
334 sofile, 362 sofile,
335 tocfile, 363 tocfile,
336 ] 364 ]
365 if (enable_resource_whitelist_generation) {
366 outputs += [ whitelist_file ]
367 }
337 if (sofile != unstripped_sofile) { 368 if (sofile != unstripped_sofile) {
338 outputs += [ unstripped_sofile ] 369 outputs += [ unstripped_sofile ]
339 } 370 }
340 link_output = sofile 371 link_output = sofile
341 depend_output = tocfile 372 depend_output = tocfile
342 } 373 }
343 374
344 tool("solink_module") { 375 tool("solink_module") {
345 soname = "{{target_output_name}}{{output_extension}}" # e.g. "libfoo.so". 376 soname = "{{target_output_name}}{{output_extension}}" # e.g. "libfoo.so".
346 sofile = "{{output_dir}}/$soname" 377 sofile = "{{output_dir}}/$soname"
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
538 "toolchain_os", 569 "toolchain_os",
539 "use_gold", 570 "use_gold",
540 "v8_toolchain_cpu", 571 "v8_toolchain_cpu",
541 ]) 572 ])
542 573
543 if (defined(invoker.use_debug_fission)) { 574 if (defined(invoker.use_debug_fission)) {
544 use_debug_fission = invoker.use_debug_fission 575 use_debug_fission = invoker.use_debug_fission
545 } 576 }
546 } 577 }
547 } 578 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698