Skip to content

Commit dcd71b5

Browse files
authored
Add RBE support to the Fuchsia GN toolchain (#843)
It turns out RBE Fuchsia builds are slow because we never actually plumbed the option through the GN toolchain...
1 parent ba3ca69 commit dcd71b5

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

build/toolchain/fuchsia/BUILD.gn

+16-7
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,21 @@
44

55
import("//build/toolchain/clang.gni")
66
import("//build/toolchain/goma.gni")
7+
import("//build/toolchain/rbe.gni")
78
import("//build/toolchain/toolchain.gni")
89

910
if (use_goma) {
10-
goma_prefix = "$goma_dir/gomacc "
11+
assert(!use_rbe, "Goma and RBE can't be used together.")
12+
compiler_prefix = "$goma_dir/gomacc "
13+
link_prefix = "$goma_dir/gomacc "
14+
} else if (use_rbe) {
15+
compiler_args =
16+
rewrapper_command + [ "--labels=type=compile,compiler=clang,lang=cpp " ]
17+
compiler_prefix = string_join(" ", compiler_args)
18+
link_prefix = ""
1119
} else {
12-
goma_prefix = ""
20+
compiler_prefix = ""
21+
link_prefix = ""
1322
}
1423

1524
toolchain("fuchsia") {
@@ -49,7 +58,7 @@ toolchain("fuchsia") {
4958

5059
tool("cc") {
5160
depfile = "{{output}}.d"
52-
command = "$goma_prefix $cc -MD -MF $depfile $target_triple_flags $sysroot_flags $lto_flags {{defines}} {{include_dirs}} {{cflags}} {{cflags_c}} -c {{source}} -o {{output}}"
61+
command = "$compiler_prefix $cc -MD -MF $depfile $target_triple_flags $sysroot_flags $lto_flags {{defines}} {{include_dirs}} {{cflags}} {{cflags_c}} -c {{source}} -o {{output}}"
5362
depsformat = "gcc"
5463
description = "CC {{output}}"
5564
outputs =
@@ -58,7 +67,7 @@ toolchain("fuchsia") {
5867

5968
tool("cxx") {
6069
depfile = "{{output}}.d"
61-
command = "$goma_prefix $cxx -MD -MF $depfile $target_triple_flags $sysroot_flags $lto_flags {{defines}} {{include_dirs}} {{cflags}} {{cflags_cc}} -c {{source}} -o {{output}}"
70+
command = "$compiler_prefix $cxx -MD -MF $depfile $target_triple_flags $sysroot_flags $lto_flags {{defines}} {{include_dirs}} {{cflags}} {{cflags_cc}} -c {{source}} -o {{output}}"
6271
depsformat = "gcc"
6372
description = "CXX {{output}}"
6473
outputs =
@@ -67,7 +76,7 @@ toolchain("fuchsia") {
6776

6877
tool("asm") {
6978
depfile = "{{output}}.d"
70-
command = "$goma_prefix $cc -MD -MF $depfile $target_triple_flags $sysroot_flags $lto_flags {{defines}} {{include_dirs}} {{asmflags}} {{cflags}} {{cflags_c}} -c {{source}} -o {{output}}"
79+
command = "$cc -MD -MF $depfile $target_triple_flags $sysroot_flags $lto_flags {{defines}} {{include_dirs}} {{asmflags}} {{cflags}} {{cflags_c}} -c {{source}} -o {{output}}"
7180
depsformat = "gcc"
7281
description = "ASM {{output}}"
7382
outputs =
@@ -99,7 +108,7 @@ toolchain("fuchsia") {
99108
# existing .TOC file, overwrite it, otherwise, don't change it.
100109
tocfile = sofile + ".TOC"
101110
temporary_tocname = sofile + ".tmp"
102-
link_command = "$goma_prefix $ld $target_triple_flags $sysroot_flags $lto_flags -shared {{ldflags}} -o $unstripped_sofile -Wl,--build-id=sha1 -Wl,-soname=$soname @$rspfile"
111+
link_command = "$link_prefix $ld $target_triple_flags $sysroot_flags $lto_flags -shared {{ldflags}} -o $unstripped_sofile -Wl,--build-id=sha1 -Wl,-soname=$soname @$rspfile"
103112
toc_command = "{ $readelf -d $unstripped_sofile | grep SONAME ; $nm -gD -f p $unstripped_sofile | cut -f1-2 -d' '; } > $temporary_tocname"
104113
replace_command = "if ! cmp -s $temporary_tocname $tocfile; then mv $temporary_tocname $tocfile; fi"
105114
strip_command = "$strip -o $sofile $unstripped_sofile"
@@ -136,7 +145,7 @@ toolchain("fuchsia") {
136145
outfile = "{{root_out_dir}}/$exename"
137146
rspfile = "$outfile.rsp"
138147
unstripped_outfile = "{{root_out_dir}}/exe.unstripped/$exename"
139-
command = "$goma_prefix $ld $target_triple_flags $sysroot_flags $lto_flags {{ldflags}} -o $unstripped_outfile -Wl,--build-id=sha1 -Wl,--start-group @$rspfile {{solibs}} -Wl,--end-group {{libs}} && ${strip} -o $outfile $unstripped_outfile"
148+
command = "$link_prefix $ld $target_triple_flags $sysroot_flags $lto_flags {{ldflags}} -o $unstripped_outfile -Wl,--build-id=sha1 -Wl,--start-group @$rspfile {{solibs}} -Wl,--end-group {{libs}} && ${strip} -o $outfile $unstripped_outfile"
140149
description = "LINK $outfile"
141150
rspfile_content = "{{inputs}}"
142151
outputs = [

0 commit comments

Comments
 (0)