Skip to content

Commit

Permalink
Add option cc_wrapper to GN
Browse files Browse the repository at this point in the history
For example:
cc_wrapper="ccache"
cc_wrapper="icecc"
cc_wrapper="distcc"
cc_wrapper="ccache distcc"

In addition, it deprecates use_ccache and clang_dir.
A user who uses use_ccache must switch to cc_wrapper="ccache"
clang_dir supported icecc in the masquerade way. There is
2 ways to use external compiler wrapper. For example using icecc,
1) CC='icecc gcc'
2) masquerade icecc
 mkdir /opt/icecc/bin
 ln -s /usr/bin/icecc /opt/icecc/bin/gcc
 ln -s /usr/bin/icecc /opt/icecc/bin/g++
 export PATH=/opt/icecc/bin:$PATH
 clang_dir="/opt/icecc/bin/"

This CL uses the chromium#1 way because goma uses the chromium#1 way, and removes
the chromium#2 hack, which is clang_dir.

Review URL: https://codereview.chromium.org/1660053005

Cr-Commit-Position: refs/heads/master@{#377251}
  • Loading branch information
ds-hwang authored and Commit bot committed Feb 24, 2016
1 parent f32a8b4 commit e279af1
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 25 deletions.
4 changes: 2 additions & 2 deletions build/config/compiler/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import("//build/config/android/config.gni")
import("//build/config/chrome_build.gni")
import("//build/config/compiler/compiler.gni")
import("//build/config/nacl/config.gni")
import("//build/toolchain/ccache.gni")
import("//build/toolchain/cc_wrapper.gni")

if (current_cpu == "arm") {
import("//build/config/arm.gni")
Expand Down Expand Up @@ -88,7 +88,7 @@ if (gold_path == false) {

if (use_debug_fission == "default") {
use_debug_fission = is_debug && !is_win && use_gold &&
linux_use_bundled_binutils && !use_ccache
linux_use_bundled_binutils && cc_wrapper == ""
}

# default_include_dirs ---------------------------------------------------------
Expand Down
20 changes: 15 additions & 5 deletions build/toolchain/ccache.gni → build/toolchain/cc_wrapper.gni
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

# Defines the configuration of ccache - a c/c++ compiler cache which can
# greatly reduce recompilation times.
# Defines the configuration of cc wrapper
# ccache: a c/c++ compiler cache which can greatly reduce recompilation times.
# icecc, distcc: it takes compile jobs from a build and distributes them among
# remote machines allowing a parallel build.
#
# TIPS:
# TIPS
#
# 1) ccache
# Set clang_use_chrome_plugins=false if using ccache 3.1.9 or earlier, since
# these versions don't support -Xclang. (3.1.10 and later will silently
# ignore -Xclang, so it doesn't matter if you disable clang_use_chrome_plugins
Expand All @@ -18,8 +21,15 @@
# To avoid -Wparentheses-equality clang warnings, at some cost in terms of
# speed, you can do:
# export CCACHE_CPP2=yes
#
# 2) icecc
# Set clang_use_chrome_plugins=false because icecc cannot distribute custom
# clang libraries.
#
# To use icecc and ccache together, set cc_wrapper = "ccache" with
# export CCACHE_PREFIX=icecc

declare_args() {
# Set to true to enable ccache. Probably doesn't work on windows.
use_ccache = false
# Set to "ccache", "icecc" or "distcc". Probably doesn't work on windows.
cc_wrapper = ""
}
2 changes: 1 addition & 1 deletion build/toolchain/cros/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -67,5 +67,5 @@ gcc_toolchain("target") {
toolchain_cpu = target_cpu
toolchain_os = "linux"
is_clang = is_clang
use_ccache = false
cc_wrapper = ""
}
26 changes: 12 additions & 14 deletions build/toolchain/gcc_toolchain.gni
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import("//build/config/nacl/config.gni")
import("//build/config/sanitizers/sanitizers.gni")
import("//build/toolchain/ccache.gni")
import("//build/toolchain/cc_wrapper.gni")
import("//build/toolchain/goma.gni")
import("//build/toolchain/toolchain.gni")

Expand Down Expand Up @@ -80,9 +80,10 @@ if (is_cfi) {
# 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.
# - 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_goma
# Override the global use_goma setting, useful to opt-out of goma in a
# particular toolchain by setting use_gome = false in it.
Expand All @@ -100,17 +101,17 @@ 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.cc_wrapper)) {
cc_wrapper = invoker.cc_wrapper
}
if (defined(invoker.use_goma)) {
use_goma = invoker.use_goma
}
if (use_goma) {
assert(!use_ccache, "Goma and ccache can't be used together.")
assert(cc_wrapper == "", "Goma and cc_wrapper can't be used together.")
compiler_prefix = "$goma_dir/gomacc "
} else if (use_ccache) {
compiler_prefix = "ccache "
} else if (cc_wrapper != "") {
compiler_prefix = cc_wrapper + " "
} else {
compiler_prefix = ""
}
Expand Down Expand Up @@ -425,10 +426,6 @@ template("gcc_toolchain") {
}
}

declare_args() {
clang_dir = "//third_party/llvm-build/Release+Asserts"
}

# 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
Expand All @@ -448,7 +445,8 @@ template("clang_toolchain") {
}

gcc_toolchain(target_name) {
prefix = rebase_path(clang_dir + "/bin", root_build_dir)
prefix = rebase_path("//third_party/llvm-build/Release+Asserts/bin",
root_build_dir)
cc = "$prefix/clang"
cxx = "$prefix/clang++"
ld = cxx
Expand Down
2 changes: 1 addition & 1 deletion build/toolchain/linux/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,6 @@ gcc_toolchain("mipsel") {
toolchain_cpu = "mipsel"
toolchain_os = "linux"
is_clang = false
use_ccache = false
cc_wrapper = ""
use_goma = false
}
2 changes: 1 addition & 1 deletion build/toolchain/nacl/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ template("pnacl_toolchain") {
# When the compilers are run via goma or ccache rather than directly by
# GN/Ninja, the goma/ccache wrapper handles .bat files but gets confused
# by being given the scriptprefix.
if (host_os == "win" && !use_goma && !use_ccache) {
if (host_os == "win" && !use_goma && cc_wrapper == "") {
compiler_scriptprefix = scriptprefix
} else {
compiler_scriptprefix = ""
Expand Down
2 changes: 1 addition & 1 deletion docs/ccache_mac.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ you can also use the absolute path here.)
You just need to set the use\_ccache variable. Do so like the following:

```shell
gn gen out-gn --args='use_ccache=true'
gn gen out-gn --args='cc_wrapper="ccache"'
```

## Build
Expand Down

0 comments on commit e279af1

Please sign in to comment.