Skip to content

Commit 565cbc2

Browse files
committed
[gn build] Use build-machine-independent paths in coverage information
This is possible after D106314 / 8773822. Makes the required prepare-code-coverage-artifact.py invocation a bit longer, but that seems like a good tradeoff. Differential Revision: https://reviews.llvm.org/D113282
1 parent 2672094 commit 565cbc2

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

llvm/utils/gn/build/BUILD.gn

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ import("//llvm/utils/gn/build/toolchain/target_flags.gni")
77
declare_args() {
88
# Whether to build everything with coverage information.
99
# After building with this, run tests and then run
10-
# llvm/utils/prepare-code-coverage-artifact.py \
10+
# llvm/utils/prepare-code-coverage-artifact.py \
11+
# --compilation-dir=out/gn \
1112
# .../llvm-profdata .../llvm-cov out/gn/profiles/ report/ \
1213
# out/gn/bin/llvm-undname ...
1314
# to generate a HTML report for the binaries passed in the last line.
@@ -226,6 +227,10 @@ config("compiler_defaults") {
226227
cflags += [
227228
"-fcoverage-mapping",
228229

230+
# For build determinism. Using this requires passing --compilation-dir to
231+
# llvm/utils/prepare-code-coverage-artifact.py.
232+
"-fcoverage-compilation-dir=.",
233+
229234
# Using an absolute path here is lame, but it's used at test execution
230235
# time to generate the profiles, and lit doesn't specify a fixed folder
231236
# for test execution -- so this is the only way to get all profiles into
@@ -234,14 +239,6 @@ config("compiler_defaults") {
234239
"-fprofile-instr-generate=" +
235240
rebase_path("$root_build_dir/profiles/%4m.profraw"),
236241
]
237-
if (use_goma) {
238-
# goma has a bug where it writes the server-side absolute path.
239-
# Work around that.
240-
# FIXME: Instead, set this to `.` for deterministic builds and pass
241-
# the build dir to prepare-code-coverage-artifact.py instead.
242-
cflags += [ "-fcoverage-compilation-dir=" + rebase_path(root_build_dir) ]
243-
}
244-
245242
if (host_os != "win") {
246243
ldflags += [ "-fprofile-instr-generate" ]
247244
}

0 commit comments

Comments
 (0)