commit 27784f804ece302937042a480c037414669d433e
parent 3c213707b73adac686fd208ff1f109d7a39bea2e
Author: Mike Hommey <mh+mozilla@glandium.org>
Date: Mon, 10 Nov 2025 22:13:33 +0000
Bug 1998862 - Add the coverage linker flag at the configure level. r=firefox-build-system-reviewers,sergesanspaille
We've been relying on mozconfigs adding the necessary things for long
enough. We should make the builds as simple as humanly possible.
Interestingly enough, we're even adding the clang runtime manually while
clang adds it itself when the coverage flag is given.
What this doesn't handle yet, though, is the rust side of things.
But at least with this change the build doesn't straight fail.
Differential Revision: https://phabricator.services.mozilla.com/D271728
Diffstat:
3 files changed, 1 insertion(+), 6 deletions(-)
diff --git a/browser/config/mozconfigs/linux64/code-coverage b/browser/config/mozconfigs/linux64/code-coverage
@@ -8,8 +8,5 @@ ac_add_options --disable-warnings-as-errors
ac_add_options --without-wasm-sandboxed-libraries
ac_add_options --enable-coverage
-CLANG_LIB_DIR="$(cd $MOZ_FETCHES_DIR/clang/lib/clang/* && cd lib/linux && pwd)"
-export LDFLAGS="--coverage -L$CLANG_LIB_DIR"
-export LIBS="-lclang_rt.profile-x86_64"
export RUSTFLAGS="-Ccodegen-units=1 -Zprofile -Cpanic=abort -Zpanic_abort_tests -Coverflow-checks=off"
export RUSTDOCFLAGS="-Cpanic=abort"
diff --git a/browser/config/mozconfigs/macosx64/code-coverage b/browser/config/mozconfigs/macosx64/code-coverage
@@ -6,8 +6,5 @@ ac_add_options --disable-warnings-as-errors
ac_add_options --without-wasm-sandboxed-libraries
ac_add_options --enable-coverage
-CLANG_LIB_DIR="$(cd $MOZ_FETCHES_DIR/clang/lib/clang/* && cd lib/darwin && pwd)"
-export LDFLAGS="-coverage -L$CLANG_LIB_DIR"
-export LIBS="-lclang_rt.profile_osx"
export RUSTFLAGS="-Ccodegen-units=1 -Zprofile -Cpanic=abort -Zpanic_abort_tests -Coverflow-checks=off"
export RUSTDOCFLAGS="-Cpanic=abort"
diff --git a/build/moz.configure/toolchain.configure b/build/moz.configure/toolchain.configure
@@ -3178,6 +3178,7 @@ def coverage_cflags(target, c_compiler, build_env):
set_config("COVERAGE_CFLAGS", coverage_cflags)
+add_linker_flag("--coverage", when=code_coverage & building_with_gnu_compatible_cc)
# Assembler detection
# ==============================================================