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

Unified 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: wrap 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « build/toolchain/cros/BUILD.gn ('k') | build/toolchain/goma.gni » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: build/toolchain/gcc_toolchain.gni
diff --git a/build/toolchain/gcc_toolchain.gni b/build/toolchain/gcc_toolchain.gni
index 0045411afefb1b11b04b3cb7a9e9d5e2322819d8..163643fdd5b03dbb9c33d45612c6020e2c9ce184 100644
--- a/build/toolchain/gcc_toolchain.gni
+++ b/build/toolchain/gcc_toolchain.gni
@@ -18,11 +18,6 @@ import("//build/toolchain/toolchain.gni")
# - cc
# - cxx
# - ld
-# and the following which is used in the toolchain_args
-# - toolchain_cpu (What "current_cpu" should be set to when invoking a
-# build using this toolchain.)
-# - toolchain_os (What "current_os" should be set to when invoking a
-# build using this toolchain.)
#
# Optional parameters that control the tools:
#
@@ -72,61 +67,12 @@ import("//build/toolchain/toolchain.gni")
# Location of the strip executable. When specified, strip will be run on
# all shared libraries and executables as they are built. The pre-stripped
# artifacts will be put in lib.unstripped/ and exe.unstripped/.
-#
-# Optional build argument controls.
-#
-# - clear_sanitizers
-# When set to true, is_asan, is_msan, etc.will all be set to false. Often
-# secondary toolchains do not want to run with sanitizers.
-# - is_clang
-# Whether to use clang instead of gcc.
-# - is_component_build
-# Whether to forcibly enable or disable component builds for this
-# toolchain; if not specified, the toolchain will inherit the
-# default setting.
-# - is_nacl_glibc
-# Whether NaCl code is built using Glibc instead of Newlib.
-# - cc_wrapper
-# Override the global cc_wrapper setting. e.g. "ccache" or "icecc".
-# useful to opt-out of cc_wrapper in a particular toolchain by setting
-# cc_wrapper = "" in it.
-# - use_debug_fission
-# Override the global use_debug_fission setting, useful if the particular
-# toolchain should not be generating split-dwarf code.
-# - use_goma
-# Override the global use_goma setting, useful to opt-out of goma in a
-# particular toolchain by setting use_gome = false in it.
-# - use_gold
-# Override the global use_gold setting, useful if the particular
-# toolchain has a custom link step that is not actually using Gold.
-# - v8_toolchain_cpu
-# If defined, set v8_current_cpu to this, else set v8_current_cpu
-# to current_cpu.
template("gcc_toolchain") {
toolchain(target_name) {
assert(defined(invoker.ar), "gcc_toolchain() must specify a \"ar\" value")
assert(defined(invoker.cc), "gcc_toolchain() must specify a \"cc\" value")
assert(defined(invoker.cxx), "gcc_toolchain() must specify a \"cxx\" value")
assert(defined(invoker.ld), "gcc_toolchain() must specify a \"ld\" value")
- assert(defined(invoker.toolchain_cpu),
- "gcc_toolchain() must specify a \"toolchain_cpu\"")
- assert(defined(invoker.toolchain_os),
- "gcc_toolchain() must specify a \"toolchain_os\"")
-
- if (defined(invoker.cc_wrapper)) {
- cc_wrapper = invoker.cc_wrapper
- }
- if (defined(invoker.use_goma)) {
- use_goma = invoker.use_goma
- }
- if (use_goma) {
- assert(cc_wrapper == "", "Goma and cc_wrapper can't be used together.")
- compiler_prefix = "$goma_dir/gomacc "
- } else if (cc_wrapper != "") {
- compiler_prefix = cc_wrapper + " "
- } else {
- compiler_prefix = ""
- }
# This define changes when the toolchain changes, forcing a rebuild.
# Nothing should ever use this define.
@@ -136,6 +82,63 @@ template("gcc_toolchain") {
rebuild_string = ""
}
+ # GN's syntax can't handle more than one scope dereference at once, like
+ # "invoker.toolchain_args.foo", so make a temporary to hold the toolchain
+ # args so we can do "invoker_toolchain_args.foo".
+ assert(defined(invoker.toolchain_args),
+ "Toolchains must specify toolchain_args")
+ invoker_toolchain_args = invoker.toolchain_args
+ assert(defined(invoker_toolchain_args.current_cpu),
+ "toolchain_args must specify a current_cpu")
+ assert(defined(invoker_toolchain_args.current_os),
+ "toolchain_args must specify a current_os")
+
+ # When invoking this toolchain not as the default one, these args will be
+ # passed to the build. They are ignored when this is the default toolchain.
+ toolchain_args = {
+ # Populate toolchain args from the invoker.
+ forward_variables_from(invoker_toolchain_args, "*")
+
+ # These values need to be passed through unchanged to all secondary
+ # toolchains. BUILDCONFIG.gn sets some defaults based on the values of
+ # the operating system and compiler, and we want to force the values to
+ # be consistent if re-running the computation in another context leads
+ # to different defaults.
+ host_toolchain = host_toolchain
+ target_os = target_os
+ target_cpu = target_cpu
+
+ if (!defined(invoker_toolchain_args.v8_current_cpu)) {
+ v8_current_cpu = invoker_toolchain_args.current_cpu
+ }
+ }
+
+ # When the invoker has explicitly overridden use_goma or cc_wrapper in the
+ # toolchain args, use those values, otherwise default to the global one.
+ # This works because the only reasonable override that toolchains might
+ # supply for these values are to force-disable them.
+ if (defined(toolchain_args.use_goma)) {
+ toolchain_uses_goma = toolchain_args.use_goma
+ } else {
+ toolchain_uses_goma = use_goma
+ }
+ if (defined(toolchain_args.cc_wrapper)) {
+ toolchain_cc_wrapper = toolchain_args.cc_wrapper
+ } else {
+ toolchain_cc_wrapper = cc_wrapper
+ }
+
+ # Compute the compiler prefix.
+ if (toolchain_uses_goma) {
+ assert(toolchain_cc_wrapper == "",
+ "Goma and cc_wrapper can't be used together.")
+ compiler_prefix = "$goma_dir/gomacc "
+ } else if (toolchain_cc_wrapper != "") {
+ compiler_prefix = toolchain_cc_wrapper + " "
+ } else {
+ compiler_prefix = ""
+ }
+
cc = compiler_prefix + invoker.cc
cxx = compiler_prefix + invoker.cxx
ar = invoker.ar
@@ -434,64 +437,18 @@ template("gcc_toolchain") {
description = copy_description
}
- # When invoking this toolchain not as the default one, these args will be
- # passed to the build. They are ignored when this is the default toolchain.
- toolchain_args() {
- current_cpu = invoker.toolchain_cpu
- current_os = invoker.toolchain_os
-
- # These values need to be passed through unchanged.
- host_toolchain = host_toolchain
- target_os = target_os
- target_cpu = target_cpu
-
- if (defined(invoker.is_clang)) {
- is_clang = invoker.is_clang
- }
- if (defined(invoker.is_component_build)) {
- is_component_build = invoker.is_component_build
- }
- if (defined(invoker.is_nacl_glibc)) {
- is_nacl_glibc = invoker.is_nacl_glibc
- }
- if (defined(invoker.symbol_level)) {
- symbol_level = invoker.symbol_level
- }
- if (defined(invoker.use_allocator)) {
- use_allocator = invoker.use_allocator
- }
- if (defined(invoker.use_debug_fission)) {
- use_debug_fission = invoker.use_debug_fission
- }
- if (defined(invoker.use_gold)) {
- use_gold = invoker.use_gold
- }
- if (defined(invoker.use_sysroot)) {
- use_sysroot = invoker.use_sysroot
- }
- if (defined(invoker.v8_toolchain_cpu)) {
- v8_current_cpu = invoker.v8_toolchain_cpu
- } else {
- v8_current_cpu = current_cpu
- }
- }
-
forward_variables_from(invoker, [ "deps" ])
}
}
-# This is a shorthand for gcc_toolchain instances based on the
-# Chromium-built version of Clang. Only the toolchain_cpu and
-# toolchain_os variables need to be specified by the invoker, and
-# optionally toolprefix if it's a cross-compile case. Note that for
-# a cross-compile case this toolchain requires a config to pass the
-# appropriate -target option, or else it will actually just be doing
-# a native compile. The invoker can optionally override use_gold too.
+# This is a shorthand for gcc_toolchain instances based on the Chromium-built
+# version of Clang. Only the toolchain_cpu and toolchain_os variables need to
+# be specified by the invoker, and optionally toolprefix if it's a
+# cross-compile case. Note that for a cross-compile case this toolchain
+# requires a config to pass the appropriate -target option, or else it will
+# actually just be doing a native compile. The invoker can optionally override
+# use_gold too.
template("clang_toolchain") {
- assert(defined(invoker.toolchain_cpu),
- "clang_toolchain() must specify a \"toolchain_cpu\"")
- assert(defined(invoker.toolchain_os),
- "clang_toolchain() must specify a \"toolchain_os\"")
if (defined(invoker.toolprefix)) {
toolprefix = invoker.toolprefix
} else {
@@ -503,23 +460,41 @@ template("clang_toolchain") {
cc = "$prefix/clang"
cxx = "$prefix/clang++"
ld = cxx
- is_clang = true
readelf = "${toolprefix}readelf"
ar = "${toolprefix}ar"
nm = "${toolprefix}nm"
- forward_variables_from(invoker,
- [
- "strip",
- "toolchain_cpu",
- "toolchain_os",
- "use_gold",
- "v8_toolchain_cpu",
- ])
+ forward_variables_from(invoker, [ "strip" ])
+ toolchain_args = {
+ if (defined(invoker.toolchain_args)) {
+ forward_variables_from(invoker.toolchain_args, "*")
+ }
+ is_clang = true
+ }
+
+ # Backwards-compatible handling for toolchain definitions in the Native
+ # Client repo.
+ #
+ # TODO(brettw) bug 634446 remove this when
+ # //native_client/src/trusted/service_runtime/linux/BUILD.gn is updated to
+ # use the new-style toolchain_args.
+ if (defined(invoker.toolchain_cpu)) {
+ assert(!defined(toolchain_args.current_cpu))
+ toolchain_args.current_cpu = invoker.toolchain_cpu
+ }
+ if (defined(invoker.toolchain_os)) {
+ assert(!defined(toolchain_args.current_os))
+ toolchain_args.current_os = invoker.toolchain_os
+ }
if (defined(invoker.use_debug_fission)) {
- use_debug_fission = invoker.use_debug_fission
+ assert(!defined(toolchain_args.use_debug_fission))
+ toolchain_args.use_debug_fission = invoker.use_debug_fission
+ }
+ if (defined(invoker.use_gold)) {
+ assert(!defined(toolchain_args.use_gold))
+ toolchain_args.use_gold = invoker.use_gold
}
}
}
« no previous file with comments | « build/toolchain/cros/BUILD.gn ('k') | build/toolchain/goma.gni » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698