diff options
author | tsniatowski <tsniatowski@opera.com> | 2015-09-24 21:43:41 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-09-25 04:44:28 +0000 |
commit | dfe796aa7deb3cb7c72dfdd294c73554b4e5c0c2 (patch) | |
tree | 216f43452922d1a7c47a52388559f3f30e6a7f23 /build/toolchain | |
parent | 74b6a80b20f8b48da1a6189e5544549feea5d815 (diff) | |
download | chromium_src-dfe796aa7deb3cb7c72dfdd294c73554b4e5c0c2.zip chromium_src-dfe796aa7deb3cb7c72dfdd294c73554b4e5c0c2.tar.gz chromium_src-dfe796aa7deb3cb7c72dfdd294c73554b4e5c0c2.tar.bz2 |
Move goma/ccache logic to //build/toolchain/gcc_toolchain.gni
Avoid logic duplication between linux/android/... toolchain definitions
that all did the same thing. This is helpful for further work with
compiler prefixes / wrappers, in particular for non-goma-users.
Some toolchains used the prefix on nm and objcopy calls, this was probably
wrong and no longer happens. The toolchains that used gcc_toolchain.gni
but did not manually setup goma/ccache opt out of the setting to avoid
large behavior changes.
BUG=
Review URL: https://codereview.chromium.org/1361403002
Cr-Commit-Position: refs/heads/master@{#350767}
Diffstat (limited to 'build/toolchain')
-rw-r--r-- | build/toolchain/android/BUILD.gn | 23 | ||||
-rw-r--r-- | build/toolchain/cros/BUILD.gn | 2 | ||||
-rw-r--r-- | build/toolchain/gcc_toolchain.gni | 30 | ||||
-rw-r--r-- | build/toolchain/linux/BUILD.gn | 37 | ||||
-rw-r--r-- | build/toolchain/nacl_toolchain.gni | 2 |
5 files changed, 49 insertions, 45 deletions
diff --git a/build/toolchain/android/BUILD.gn b/build/toolchain/android/BUILD.gn index 749d28b..313e609 100644 --- a/build/toolchain/android/BUILD.gn +++ b/build/toolchain/android/BUILD.gn @@ -3,8 +3,6 @@ # found in the LICENSE file. import("//build/config/sysroot.gni") # Imports android/config.gni. -import("//build/toolchain/ccache.gni") -import("//build/toolchain/goma.gni") import("//build/toolchain/gcc_toolchain.gni") # The Android GCC toolchains share most of the same parameters, so we have this @@ -35,29 +33,20 @@ template("android_gcc_toolchain") { # The tools should be run relative to the build dir. tool_prefix = rebase_path(invoker.tool_prefix, root_build_dir) - if (use_goma) { - assert(!use_ccache, "Goma and ccache can't be used together.") - compiler_prefix = "$goma_dir/gomacc " - } else if (use_ccache) { - compiler_prefix = "ccache " - } else { - compiler_prefix = "" - } - is_clang = invoker.is_clang if (is_clang) { prefix = rebase_path("//third_party/llvm-build/Release+Asserts/bin", root_build_dir) - cc = "${compiler_prefix}$prefix/clang" - cxx = "${compiler_prefix}$prefix/clang++" + cc = "$prefix/clang" + cxx = "$prefix/clang++" } else { - cc = "${compiler_prefix}${tool_prefix}gcc" - cxx = "${compiler_prefix}${tool_prefix}g++" + cc = "${tool_prefix}gcc" + cxx = "${tool_prefix}g++" } ar = tool_prefix + "ar" ld = cxx - readelf = compiler_prefix + tool_prefix + "readelf" - nm = compiler_prefix + tool_prefix + "nm" + readelf = tool_prefix + "readelf" + nm = tool_prefix + "nm" strip = "${tool_prefix}strip" toolchain_os = "android" diff --git a/build/toolchain/cros/BUILD.gn b/build/toolchain/cros/BUILD.gn index 755721b..5db3c20 100644 --- a/build/toolchain/cros/BUILD.gn +++ b/build/toolchain/cros/BUILD.gn @@ -31,4 +31,6 @@ gcc_toolchain("target") { toolchain_cpu = "${target_cpu}" toolchain_os = "linux" is_clang = is_clang + use_ccache = false + use_goma = false } diff --git a/build/toolchain/gcc_toolchain.gni b/build/toolchain/gcc_toolchain.gni index 41766ce..74dbf07 100644 --- a/build/toolchain/gcc_toolchain.gni +++ b/build/toolchain/gcc_toolchain.gni @@ -4,6 +4,8 @@ import("//build/config/nacl/config.gni") import("//build/config/sanitizers/sanitizers.gni") +import("//build/toolchain/ccache.gni") +import("//build/toolchain/goma.gni") import("//build/toolchain/toolchain.gni") # This value will be inherited in the toolchain below. @@ -73,6 +75,12 @@ concurrent_links = exec_script("get_concurrent_links.py", [], "value") # default setting. # - is_nacl_glibc # Whether NaCl code is built using Glibc instead of Newlib. +# - use_ccache +# Override the global use_ccache setting, useful to opt-out of ccache in +# a particular toolchain by setting use_ccache = false in it. +# - 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. template("gcc_toolchain") { toolchain(target_name) { assert(defined(invoker.cc), "gcc_toolchain() must specify a \"cc\" value") @@ -84,6 +92,21 @@ template("gcc_toolchain") { assert(defined(invoker.toolchain_os), "gcc_toolchain() must specify a \"toolchain_os\"") + if (defined(invoker.use_ccache)) { + use_ccache = invoker.use_ccache + } + if (defined(invoker.use_goma)) { + use_goma = invoker.use_goma + } + if (use_goma) { + assert(!use_ccache, "Goma and ccache can't be used together.") + compiler_prefix = "$goma_dir/gomacc " + } else if (use_ccache) { + compiler_prefix = "ccache " + } else { + compiler_prefix = "" + } + # This define changes when the toolchain changes, forcing a rebuild. # Nothing should ever use this define. if (defined(invoker.rebuild_define)) { @@ -92,11 +115,8 @@ template("gcc_toolchain") { rebuild_string = "" } - # We can't do string interpolation ($ in strings) on things with dots in - # them. To allow us to use $cc below, for example, we create copies of - # these values in our scope. - cc = invoker.cc - cxx = invoker.cxx + cc = compiler_prefix + invoker.cc + cxx = compiler_prefix + invoker.cxx ar = invoker.ar ld = invoker.ld if (defined(invoker.readelf)) { diff --git a/build/toolchain/linux/BUILD.gn b/build/toolchain/linux/BUILD.gn index 84a790d..2e24938 100644 --- a/build/toolchain/linux/BUILD.gn +++ b/build/toolchain/linux/BUILD.gn @@ -3,24 +3,13 @@ # found in the LICENSE file. import("//build/config/sysroot.gni") -import("//build/toolchain/ccache.gni") import("//build/toolchain/gcc_toolchain.gni") -import("//build/toolchain/goma.gni") - -if (use_goma) { - assert(!use_ccache, "Goma and ccache can't be used together.") - compiler_prefix = "$goma_dir/gomacc " -} else if (use_ccache) { - compiler_prefix = "ccache " -} else { - compiler_prefix = "" -} gcc_toolchain("clang_arm") { prefix = rebase_path("//third_party/llvm-build/Release+Asserts/bin", root_build_dir) - cc = "${compiler_prefix}$prefix/clang" - cxx = "${compiler_prefix}$prefix/clang++" + cc = "$prefix/clang" + cxx = "$prefix/clang++" toolprefix = "arm-linux-gnueabihf-" readelf = "${toolprefix}readelf" @@ -37,8 +26,8 @@ gcc_toolchain("clang_arm") { gcc_toolchain("arm") { toolprefix = "arm-linux-gnueabihf-" - cc = "${compiler_prefix}${toolprefix}gcc" - cxx = "${compiler_prefix}${toolprefix}g++" + cc = "${toolprefix}gcc" + cxx = "${toolprefix}g++" ar = "${toolprefix}ar" ld = cxx @@ -53,8 +42,8 @@ gcc_toolchain("arm") { gcc_toolchain("clang_x86") { prefix = rebase_path("//third_party/llvm-build/Release+Asserts/bin", root_build_dir) - cc = "${compiler_prefix}$prefix/clang" - cxx = "${compiler_prefix}$prefix/clang++" + cc = "$prefix/clang" + cxx = "$prefix/clang++" readelf = "readelf" nm = "nm" ar = "ar" @@ -66,8 +55,8 @@ gcc_toolchain("clang_x86") { } gcc_toolchain("x86") { - cc = "${compiler_prefix}gcc" - cxx = "${compiler_prefix}g++" + cc = "gcc" + cxx = "g++" readelf = "readelf" nm = "nm" @@ -82,8 +71,8 @@ gcc_toolchain("x86") { gcc_toolchain("clang_x64") { prefix = rebase_path("//third_party/llvm-build/Release+Asserts/bin", root_build_dir) - cc = "${compiler_prefix}$prefix/clang" - cxx = "${compiler_prefix}$prefix/clang++" + cc = "$prefix/clang" + cxx = "$prefix/clang++" readelf = "readelf" nm = "nm" @@ -96,8 +85,8 @@ gcc_toolchain("clang_x64") { } gcc_toolchain("x64") { - cc = "${compiler_prefix}gcc" - cxx = "${compiler_prefix}g++" + cc = "gcc" + cxx = "g++" readelf = "readelf" nm = "nm" @@ -120,4 +109,6 @@ gcc_toolchain("mipsel") { toolchain_cpu = "mipsel" toolchain_os = "linux" is_clang = false + use_ccache = false + use_goma = false } diff --git a/build/toolchain/nacl_toolchain.gni b/build/toolchain/nacl_toolchain.gni index 15ae604..7600488 100644 --- a/build/toolchain/nacl_toolchain.gni +++ b/build/toolchain/nacl_toolchain.gni @@ -49,6 +49,8 @@ template("nacl_toolchain") { # We do not suport component builds or sanitizers with the NaCl toolchains. is_component_build = false clear_sanitizers = true + use_ccache = false + use_goma = false rebuild_define = "NACL_TC_REV=" + invoker.toolchain_revision } |