Skip to content

Commit

Permalink
Strip absolute paths that may be found in depfiles generated by Goma …
Browse files Browse the repository at this point in the history
…builds (#806)

This workaround was originally added for RBE. Builds configured with
--goma can also output depfiles that contain the same absolute path
prefix seen in RBE builds.
  • Loading branch information
jason-simmons authored Jan 2, 2024
1 parent 33c04bd commit 44636f5
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions build/toolchain/gcc_toolchain.gni
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import("//build/toolchain/clang.gni")
import("//build/toolchain/clang_static_analyzer.gni")
import("//build/toolchain/goma.gni")
import("//build/toolchain/rbe.gni")

# Path to the Clang static analysis wrapper script.
Expand Down Expand Up @@ -124,7 +125,7 @@ template("gcc_toolchain") {
tool("cc") {
depfile = "{{output}}.d"
command = "$cc -MD -MF $depfile {{defines}} {{include_dirs}} {{cflags}} {{cflags_c}} $coverage_flags -c {{source}} -o {{output}}"
if (use_rbe) {
if (use_rbe || use_goma) {
# The depfile generated on an RBE worker can contain absolute paths.
# This sed command strips off the prefix, and rewrites to be
# relative to the buildroot.
Expand All @@ -139,7 +140,7 @@ template("gcc_toolchain") {
tool("cxx") {
depfile = "{{output}}.d"
command = "$cxx -MD -MF $depfile {{defines}} {{include_dirs}} {{cflags}} {{cflags_cc}} $coverage_flags -c {{source}} -o {{output}}"
if (use_rbe) {
if (use_rbe || use_goma) {
command += " && sed -i 's@/b/f/w@../..@g' $depfile"
}
depsformat = "gcc"
Expand All @@ -151,7 +152,7 @@ template("gcc_toolchain") {
tool("asm") {
depfile = "{{output}}.d"
command = "$asm -MD -MF $depfile {{defines}} {{include_dirs}} {{asmflags}} {{cflags}} {{cflags_c}} $coverage_flags -c {{source}} -o {{output}}"
if (use_rbe) {
if (use_rbe || use_goma) {
command += " && sed -i 's@/b/f/w@../..@g' $depfile"
}
depsformat = "gcc"
Expand Down

0 comments on commit 44636f5

Please sign in to comment.