Skip to content

Commit 5d969bd

Browse files
authored
Don't use sed to clean up depsfiles. Use -MMD instead. (#818)
Related flutter/flutter#141640
1 parent e75c1ca commit 5d969bd

File tree

2 files changed

+8
-42
lines changed

2 files changed

+8
-42
lines changed

build/toolchain/gcc_toolchain.gni

+3-22
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,6 @@ analyzer_wrapper =
1212
rebase_path("//build/toolchain/clang_static_analyzer_wrapper.py",
1313
root_build_dir) + " --mode=clang"
1414

15-
# Flag passed to sed to edit files in place
16-
if (host_os == "mac") {
17-
sed_in_place_flag = "-i ''"
18-
} else {
19-
sed_in_place_flag = "-i"
20-
}
21-
2215
# This template defines a toolchain for something that works like gcc
2316
# (including clang).
2417
#
@@ -131,13 +124,7 @@ template("gcc_toolchain") {
131124

132125
tool("cc") {
133126
depfile = "{{output}}.d"
134-
command = "$cc -MD -MF $depfile {{defines}} {{include_dirs}} {{cflags}} {{cflags_c}} $coverage_flags -c {{source}} -o {{output}}"
135-
if (use_rbe || use_goma) {
136-
# The depfile generated on an RBE worker can contain absolute paths.
137-
# This sed command strips off the prefix, and rewrites to be
138-
# relative to the buildroot.
139-
command += " && sed $sed_in_place_flag 's@/b/f/w@../..@g' $depfile"
140-
}
127+
command = "$cc -MMD -MF$depfile {{defines}} {{include_dirs}} {{cflags}} {{cflags_c}} $coverage_flags -c {{source}} -o {{output}}"
141128
depsformat = "gcc"
142129
description = "CC {{output}}"
143130
outputs =
@@ -146,10 +133,7 @@ template("gcc_toolchain") {
146133

147134
tool("cxx") {
148135
depfile = "{{output}}.d"
149-
command = "$cxx -MD -MF $depfile {{defines}} {{include_dirs}} {{cflags}} {{cflags_cc}} $coverage_flags -c {{source}} -o {{output}}"
150-
if (use_rbe || use_goma) {
151-
command += " && sed $sed_in_place_flag 's@/b/f/w@../..@g' $depfile"
152-
}
136+
command = "$cxx -MMD -MF$depfile {{defines}} {{include_dirs}} {{cflags}} {{cflags_cc}} $coverage_flags -c {{source}} -o {{output}}"
153137
depsformat = "gcc"
154138
description = "CXX {{output}}"
155139
outputs =
@@ -158,10 +142,7 @@ template("gcc_toolchain") {
158142

159143
tool("asm") {
160144
depfile = "{{output}}.d"
161-
command = "$asm -MD -MF $depfile {{defines}} {{include_dirs}} {{asmflags}} {{cflags}} {{cflags_c}} $coverage_flags -c {{source}} -o {{output}}"
162-
if (use_rbe || use_goma) {
163-
command += " && sed $sed_in_place_flag 's@/b/f/w@../..@g' $depfile"
164-
}
145+
command = "$asm -MMD -MF$depfile {{defines}} {{include_dirs}} {{asmflags}} {{cflags}} {{cflags_c}} $coverage_flags -c {{source}} -o {{output}}"
165146
depsformat = "gcc"
166147
description = "ASM {{output}}"
167148
outputs =

build/toolchain/mac/BUILD.gn

+5-20
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,7 @@ template("mac_toolchain") {
9494

9595
tool("cc") {
9696
depfile = "{{output}}.d"
97-
command = "$cc -MD -MF $depfile {{defines}} {{include_dirs}} {{cflags}} {{cflags_c}} $sysroot_flags $coverage_flags -c {{source}} -o {{output}}"
98-
if (use_rbe || use_goma) {
99-
command += " && sed -i '' -e 's@/b/f/w@../..@g' $depfile"
100-
}
97+
command = "$cc -MMD -MF $depfile {{defines}} {{include_dirs}} {{cflags}} {{cflags_c}} $sysroot_flags $coverage_flags -c {{source}} -o {{output}}"
10198
depsformat = "gcc"
10299
description = "CC {{output}}"
103100
outputs =
@@ -106,10 +103,7 @@ template("mac_toolchain") {
106103

107104
tool("cxx") {
108105
depfile = "{{output}}.d"
109-
command = "$cxx -MD -MF $depfile {{defines}} {{include_dirs}} {{cflags}} {{cflags_cc}} $sysroot_flags $coverage_flags -c {{source}} -o {{output}}"
110-
if (use_rbe || use_goma) {
111-
command += " && sed -i '' -e 's@/b/f/w@../..@g' $depfile"
112-
}
106+
command = "$cxx -MMD -MF $depfile {{defines}} {{include_dirs}} {{cflags}} {{cflags_cc}} $sysroot_flags $coverage_flags -c {{source}} -o {{output}}"
113107
depsformat = "gcc"
114108
description = "CXX {{output}}"
115109
outputs =
@@ -118,10 +112,7 @@ template("mac_toolchain") {
118112

119113
tool("asm") {
120114
depfile = "{{output}}.d"
121-
command = "$asm -MD -MF $depfile {{defines}} {{include_dirs}} {{asmflags}} {{cflags}} {{cflags_c}} $sysroot_flags -c {{source}} -o {{output}}"
122-
if (use_rbe || use_goma) {
123-
command += " && sed -i '' -e 's@/b/f/w@../..@g' $depfile"
124-
}
115+
command = "$asm -MMD -MF $depfile {{defines}} {{include_dirs}} {{asmflags}} {{cflags}} {{cflags_c}} $sysroot_flags -c {{source}} -o {{output}}"
125116
depsformat = "gcc"
126117
description = "ASM {{output}}"
127118
outputs =
@@ -130,10 +121,7 @@ template("mac_toolchain") {
130121

131122
tool("objc") {
132123
depfile = "{{output}}.d"
133-
command = "$objc -MD -MF $depfile {{defines}} {{include_dirs}} {{cflags}} {{cflags_c}} {{cflags_objc}} $sysroot_flags $coverage_flags -c {{source}} -o {{output}}"
134-
if (use_rbe || use_goma) {
135-
command += " && sed -i '' -e 's@/b/f/w@../..@g' $depfile"
136-
}
124+
command = "$objc -MMD -MF $depfile {{defines}} {{include_dirs}} {{cflags}} {{cflags_c}} {{cflags_objc}} $sysroot_flags $coverage_flags -c {{source}} -o {{output}}"
137125
depsformat = "gcc"
138126
description = "OBJC {{output}}"
139127
outputs =
@@ -142,10 +130,7 @@ template("mac_toolchain") {
142130

143131
tool("objcxx") {
144132
depfile = "{{output}}.d"
145-
command = "$objc -MD -MF $depfile {{defines}} {{include_dirs}} {{cflags}} {{cflags_cc}} {{cflags_objcc}} $sysroot_flags $coverage_flags -c {{source}} -o {{output}}"
146-
if (use_rbe || use_goma) {
147-
command += " && sed -i '' -e 's@/b/f/w@../..@g' $depfile"
148-
}
133+
command = "$objc -MMD -MF $depfile {{defines}} {{include_dirs}} {{cflags}} {{cflags_cc}} {{cflags_objcc}} $sysroot_flags $coverage_flags -c {{source}} -o {{output}}"
149134
depsformat = "gcc"
150135
description = "OBJCXX {{output}}"
151136
outputs =

0 commit comments

Comments
 (0)