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

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

Issue 2219953002: Use new toolchain_args variable in GN (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@toolchain_args
Patch Set: v8 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")
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 # to the toolchain. It can be used to force recompiles whenever a 65 # to the toolchain. It can be used to force recompiles whenever a
66 # toolchain is updated. 66 # toolchain is updated.
67 # - shlib_extension 67 # - shlib_extension
68 # If this string is specified it will be used for the file extension 68 # If this string is specified it will be used for the file extension
69 # for a shared library, rather than default value specified in 69 # for a shared library, rather than default value specified in
70 # toolchain.gni 70 # toolchain.gni
71 # - strip 71 # - strip
72 # Location of the strip executable. When specified, strip will be run on 72 # Location of the strip executable. When specified, strip will be run on
73 # all shared libraries and executables as they are built. The pre-stripped 73 # all shared libraries and executables as they are built. The pre-stripped
74 # artifacts will be put in lib.unstripped/ and exe.unstripped/. 74 # artifacts will be put in lib.unstripped/ and exe.unstripped/.
75 #
76 # Optional build argument controls.
77 #
78 # - clear_sanitizers
79 # When set to true, is_asan, is_msan, etc.will all be set to false. Often
80 # secondary toolchains do not want to run with sanitizers.
81 # - is_clang
82 # Whether to use clang instead of gcc.
83 # - is_component_build
84 # Whether to forcibly enable or disable component builds for this
85 # toolchain; if not specified, the toolchain will inherit the
86 # default setting.
87 # - is_nacl_glibc
88 # Whether NaCl code is built using Glibc instead of Newlib.
89 # - cc_wrapper
90 # Override the global cc_wrapper setting. e.g. "ccache" or "icecc".
91 # useful to opt-out of cc_wrapper in a particular toolchain by setting
92 # cc_wrapper = "" in it.
93 # - use_debug_fission
94 # Override the global use_debug_fission setting, useful if the particular
95 # toolchain should not be generating split-dwarf code.
96 # - use_goma
97 # Override the global use_goma setting, useful to opt-out of goma in a
98 # particular toolchain by setting use_gome = false in it.
99 # - use_gold
100 # Override the global use_gold setting, useful if the particular
101 # toolchain has a custom link step that is not actually using Gold.
102 # - v8_toolchain_cpu
103 # If defined, set v8_current_cpu to this, else set v8_current_cpu
104 # to current_cpu.
105 template("gcc_toolchain") { 75 template("gcc_toolchain") {
106 toolchain(target_name) { 76 toolchain(target_name) {
107 assert(defined(invoker.ar), "gcc_toolchain() must specify a \"ar\" value") 77 assert(defined(invoker.ar), "gcc_toolchain() must specify a \"ar\" value")
108 assert(defined(invoker.cc), "gcc_toolchain() must specify a \"cc\" value") 78 assert(defined(invoker.cc), "gcc_toolchain() must specify a \"cc\" value")
109 assert(defined(invoker.cxx), "gcc_toolchain() must specify a \"cxx\" value") 79 assert(defined(invoker.cxx), "gcc_toolchain() must specify a \"cxx\" value")
110 assert(defined(invoker.ld), "gcc_toolchain() must specify a \"ld\" value") 80 assert(defined(invoker.ld), "gcc_toolchain() must specify a \"ld\" value")
111 assert(defined(invoker.toolchain_cpu),
112 "gcc_toolchain() must specify a \"toolchain_cpu\"")
113 assert(defined(invoker.toolchain_os),
114 "gcc_toolchain() must specify a \"toolchain_os\"")
115
116 if (defined(invoker.cc_wrapper)) {
117 cc_wrapper = invoker.cc_wrapper
118 }
119 if (defined(invoker.use_goma)) {
120 use_goma = invoker.use_goma
121 }
122 if (use_goma) {
123 assert(cc_wrapper == "", "Goma and cc_wrapper can't be used together.")
124 compiler_prefix = "$goma_dir/gomacc "
125 } else if (cc_wrapper != "") {
126 compiler_prefix = cc_wrapper + " "
127 } else {
128 compiler_prefix = ""
129 }
130 81
131 # This define changes when the toolchain changes, forcing a rebuild. 82 # This define changes when the toolchain changes, forcing a rebuild.
132 # Nothing should ever use this define. 83 # Nothing should ever use this define.
133 if (defined(invoker.rebuild_define)) { 84 if (defined(invoker.rebuild_define)) {
134 rebuild_string = "-D" + invoker.rebuild_define + " " 85 rebuild_string = "-D" + invoker.rebuild_define + " "
135 } else { 86 } else {
136 rebuild_string = "" 87 rebuild_string = ""
137 } 88 }
138 89
90 # GN's syntax can't handle more than one scope dereference at once, like
91 # "invoker.toolchain_args.foo", so make a temporary to hold the toolchain
92 # args so we can do "invoker_toolchain_args.foo".
93 if (defined(invoker.toolchain_args)) {
94 invoker_toolchain_args = invoker.toolchain_args
95 } else {
96 invoker_toolchain_args = {
97 }
98 }
99
100 # When invoking this toolchain not as the default one, these args will be
101 # passed to the build. They are ignored when this is the default toolchain.
102 toolchain_args = {
103 # Populate toolchain args from the invoker.
104 forward_variables_from(invoker_toolchain_args, "*")
105
106 # These values need to be passed through unchanged to all secondary
107 # toolchains. BUILDCONFIG.gn sets some defaults based on the values of
108 # the operating system and compiler, and we want to force the values to
109 # be consistent if re-running the computation in another context leads
110 # to different defaults.
111 host_toolchain = host_toolchain
112 target_os = target_os
113 target_cpu = target_cpu
Dirk Pranke 2016/08/08 23:28:39 host_toolchain is derived from host_os, host_cpu,
brettw 2016/08/09 17:26:29 This logic isn't changing from the old build, this
brettw 2016/08/09 17:28:31 If you're curious why this forwarding was added in
brettw 2016/08/09 18:14:01 Dependent patch to remove these: https://coderevie
Dirk Pranke 2016/08/09 19:18:18 Right, forwarding host_toolchain still makes sense
114
115 if (!defined(invoker_toolchain_args.v8_current_cpu)) {
116 v8_current_cpu = invoker_toolchain_args.current_cpu
117 }
118 }
119
120 # When the invoker has explicitly overridden use_goma or cc_wrapper in the
121 # toolchain args, use those values, otherwise default to the global one.
122 # This works because the only reasonable override that toolchains might
123 # supply for these values are to force-disable them.
124 if (defined(toolchain_args.use_goma)) {
125 toolchain_uses_goma = toolchain_args.use_goma
126 } else {
127 toolchain_uses_goma = use_goma
128 }
129 if (defined(toolchain_args.cc_wrapper)) {
130 toolchain_cc_wrapper = toolchain_args.cc_wrapper
131 } else {
132 toolchain_cc_wrapper = cc_wrapper
133 }
134
135 # Compute the compiler prefix.
136 if (toolchain_uses_goma) {
137 assert(toolchain_cc_wrapper == "",
138 "Goma and cc_wrapper can't be used together.")
139 compiler_prefix = "$goma_dir/gomacc "
140 } else if (toolchain_cc_wrapper != "") {
141 compiler_prefix = toolchain_cc_wrapper + " "
142 } else {
143 compiler_prefix = ""
144 }
145
139 cc = compiler_prefix + invoker.cc 146 cc = compiler_prefix + invoker.cc
140 cxx = compiler_prefix + invoker.cxx 147 cxx = compiler_prefix + invoker.cxx
141 ar = invoker.ar 148 ar = invoker.ar
142 ld = invoker.ld 149 ld = invoker.ld
143 if (defined(invoker.readelf)) { 150 if (defined(invoker.readelf)) {
144 readelf = invoker.readelf 151 readelf = invoker.readelf
145 } else { 152 } else {
146 readelf = "readelf" 153 readelf = "readelf"
147 } 154 }
148 if (defined(invoker.nm)) { 155 if (defined(invoker.nm)) {
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
427 # See //build/toolchain/toolchain.gni for details. 434 # See //build/toolchain/toolchain.gni for details.
428 tool("stamp") { 435 tool("stamp") {
429 command = stamp_command 436 command = stamp_command
430 description = stamp_description 437 description = stamp_description
431 } 438 }
432 tool("copy") { 439 tool("copy") {
433 command = copy_command 440 command = copy_command
434 description = copy_description 441 description = copy_description
435 } 442 }
436 443
437 # When invoking this toolchain not as the default one, these args will be
438 # passed to the build. They are ignored when this is the default toolchain.
439 toolchain_args() {
440 current_cpu = invoker.toolchain_cpu
441 current_os = invoker.toolchain_os
442
443 # These values need to be passed through unchanged.
444 host_toolchain = host_toolchain
445 target_os = target_os
446 target_cpu = target_cpu
447
448 if (defined(invoker.is_clang)) {
449 is_clang = invoker.is_clang
450 }
451 if (defined(invoker.is_component_build)) {
452 is_component_build = invoker.is_component_build
453 }
454 if (defined(invoker.is_nacl_glibc)) {
455 is_nacl_glibc = invoker.is_nacl_glibc
456 }
457 if (defined(invoker.symbol_level)) {
458 symbol_level = invoker.symbol_level
459 }
460 if (defined(invoker.use_allocator)) {
461 use_allocator = invoker.use_allocator
462 }
463 if (defined(invoker.use_debug_fission)) {
464 use_debug_fission = invoker.use_debug_fission
465 }
466 if (defined(invoker.use_gold)) {
467 use_gold = invoker.use_gold
468 }
469 if (defined(invoker.use_sysroot)) {
470 use_sysroot = invoker.use_sysroot
471 }
472 if (defined(invoker.v8_toolchain_cpu)) {
473 v8_current_cpu = invoker.v8_toolchain_cpu
474 } else {
475 v8_current_cpu = current_cpu
476 }
477 }
478
479 forward_variables_from(invoker, [ "deps" ]) 444 forward_variables_from(invoker, [ "deps" ])
480 } 445 }
481 } 446 }
482 447
483 # This is a shorthand for gcc_toolchain instances based on the 448 # This is a shorthand for gcc_toolchain instances based on the Chromium-built
484 # Chromium-built version of Clang. Only the toolchain_cpu and 449 # version of Clang. Only the toolchain_cpu and toolchain_os variables need to
485 # toolchain_os variables need to be specified by the invoker, and 450 # be specified by the invoker, and optionally toolprefix if it's a
486 # optionally toolprefix if it's a cross-compile case. Note that for 451 # cross-compile case. Note that for a cross-compile case this toolchain
487 # a cross-compile case this toolchain requires a config to pass the 452 # requires a config to pass the appropriate -target option, or else it will
488 # appropriate -target option, or else it will actually just be doing 453 # actually just be doing a native compile. The invoker can optionally override
489 # a native compile. The invoker can optionally override use_gold too. 454 # use_gold too.
490 template("clang_toolchain") { 455 template("clang_toolchain") {
491 assert(defined(invoker.toolchain_cpu),
492 "clang_toolchain() must specify a \"toolchain_cpu\"")
493 assert(defined(invoker.toolchain_os),
494 "clang_toolchain() must specify a \"toolchain_os\"")
495 if (defined(invoker.toolprefix)) { 456 if (defined(invoker.toolprefix)) {
496 toolprefix = invoker.toolprefix 457 toolprefix = invoker.toolprefix
497 } else { 458 } else {
498 toolprefix = "" 459 toolprefix = ""
499 } 460 }
500 461
501 gcc_toolchain(target_name) { 462 gcc_toolchain(target_name) {
502 prefix = rebase_path("$clang_base_path/bin", root_build_dir) 463 prefix = rebase_path("$clang_base_path/bin", root_build_dir)
503 cc = "$prefix/clang" 464 cc = "$prefix/clang"
504 cxx = "$prefix/clang++" 465 cxx = "$prefix/clang++"
505 ld = cxx 466 ld = cxx
506 is_clang = true
507 467
508 readelf = "${toolprefix}readelf" 468 readelf = "${toolprefix}readelf"
509 ar = "${toolprefix}ar" 469 ar = "${toolprefix}ar"
510 nm = "${toolprefix}nm" 470 nm = "${toolprefix}nm"
511 471
512 forward_variables_from(invoker, 472 forward_variables_from(invoker, [ "strip" ])
513 [
514 "strip",
515 "toolchain_cpu",
516 "toolchain_os",
517 "use_gold",
518 "v8_toolchain_cpu",
519 ])
520 473
474 toolchain_args = {
475 if (defined(invoker.toolchain_args)) {
476 forward_variables_from(invoker.toolchain_args, "*")
477 }
478 is_clang = true
479 }
480
481 # Backwards-compatible handling for toolchain definitions in the Native
482 # Client repo.
483 #
484 # TODO(brettw) bug 634446 remove this when
485 # //native_client/src/trusted/service_runtime/linux/BUILD.gn is updated to
486 # use the new-style toolchain_args.
487 if (defined(invoker.toolchain_cpu)) {
488 assert(!defined(toolchain_args.current_cpu))
489 toolchain_args.current_cpu = invoker.toolchain_cpu
490 }
491 if (defined(invoker.toolchain_os)) {
492 assert(!defined(toolchain_args.current_os))
493 toolchain_args.current_os = invoker.toolchain_os
494 }
521 if (defined(invoker.use_debug_fission)) { 495 if (defined(invoker.use_debug_fission)) {
522 use_debug_fission = invoker.use_debug_fission 496 assert(!defined(toolchain_args.use_debug_fission))
497 toolchain_args.use_debug_fission = invoker.use_debug_fission
498 }
499 if (defined(invoker.use_gold)) {
500 assert(!defined(toolchain_args.use_gold))
501 toolchain_args.use_gold = invoker.use_gold
523 } 502 }
524 } 503 }
525 } 504 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698