@@ -68,9 +68,15 @@ build:v8-codegen-opt --per_file_copt=external/abseil-cpp@-O2
6868# zlib and tcmalloc (for Linux) are also CPU-intensive, optimize them too.
6969build:v8-codegen-opt --per_file_copt=external/tcmalloc@-O2
7070build:v8-codegen-opt --per_file_copt=external/zlib@-O2
71+ # BoringSSL is CPU-intensive for crypto tests, optimize it too.
72+ build:v8-codegen-opt --per_file_copt=external/boringssl@-O2
73+ # simdutf is used for fast string encoding/decoding
74+ build:v8-codegen-opt --per_file_copt=external/+http+simdutf@-O2
7175build:v8-codegen-opt-windows --per_file_copt=v8/src@/O2
7276build:v8-codegen-opt-windows --per_file_copt=external/abseil-cpp@/O2
7377build:v8-codegen-opt-windows --per_file_copt=external/zlib@/O2
78+ build:v8-codegen-opt-windows --per_file_copt=external/boringssl@/O2
79+ build:v8-codegen-opt-windows --per_file_copt=external/+http+simdutf@/O2
7480
7581# In Google projects, exceptions are not used as a rule. Disabling them is more consistent with the
7682# canonical V8 build and improves code size. Paths are adjusted for bzlmod mangling – V8 and ICU use
@@ -415,29 +421,59 @@ build:coverage --test_env=BAZEL_USE_LLVM_NATIVE_COVERAGE=1
415421# GCOV is used by rules_cc to merge raw profile data (.profraw) into indexed profile data (.profdata)
416422build:coverage --action_env=GCOV=llvm-profdata
417423build:coverage --test_env=GCOV=llvm-profdata
424+ # COVERAGE_GCOV_PATH is passed through from the environment. Users must set this to the absolute path
425+ # of llvm-profdata (used by collect_cc_coverage.sh for merging .profraw files).
426+ # Example: export COVERAGE_GCOV_PATH=$(which llvm-profdata)
427+ build:coverage --action_env=COVERAGE_GCOV_PATH
428+ build:coverage --test_env=COVERAGE_GCOV_PATH
418429# BAZEL_LLVM_COV is used by rules_cc to generate coverage reports from profile data
419430build:coverage --action_env=BAZEL_LLVM_COV=llvm-cov
420431build:coverage --test_env=BAZEL_LLVM_COV=llvm-cov
421- # Enable optimizations to reduce coverage overhead while maintaining good coverage quality
422- build:coverage --copt=-O2
423- build:coverage --copt=-DNDEBUG
424- build:coverage --combined_report=lcov
432+ # LLVM_COV is used by collect_cc_coverage.sh for generating LCOV output
433+ build:coverage --test_env=LLVM_COV=llvm-cov
425434build:coverage --experimental_use_llvm_covmap
426435build:coverage --experimental_generate_llvm_lcov
436+ # Ensure that we fetch coverage data from remote cache
427437build:coverage --experimental_fetch_all_coverage_outputs
438+ build:coverage --experimental_split_coverage_postprocessing
439+ # Allow coverage outputs to be writable for post-processing
440+ build:coverage --experimental_writable_outputs
428441build:coverage --collect_code_coverage
429- build:coverage --instrumentation_filter="^//,-//external"
442+ # Only instrument source code, not tests or tools - significantly speeds up coverage builds
443+ build:coverage --instrumentation_filter="^//src/workerd[/:],^//src/rust[/:]"
430444build:coverage --instrument_test_targets
445+ # Disable coverage instrumentation for external dependencies to speed up compilation.
446+ # Coverage for V8/external code is not useful for our purposes.
447+ # These flags negate -fprofile-instr-generate and -fcoverage-mapping set by rules_cc.
448+ build:coverage --per_file_copt=external/.*@-fno-profile-instr-generate,-fno-coverage-mapping
431449# KJ uses _exit() by default which bypasses atexit handlers and prevents LLVM profile runtime
432450# from writing coverage data. KJ_CLEAN_SHUTDOWN forces use of normal exit() instead.
433451build:coverage --test_env=KJ_CLEAN_SHUTDOWN=1
452+ # Use -O1 for faster compilation - coverage builds don't need heavy optimization
453+ build:coverage --copt=-O1
454+ # External dependencies can use -O2 since they're not instrumented anyway
455+ build:coverage --config=v8-codegen-opt
456+ # Run coverage-related actions locally with sandboxing - remote execution doesn't support LLVM coverage well
457+ build:coverage --strategy=TestRunner=worker,sandboxed,local
458+ build:coverage --strategy=CoverageReport=worker,sandboxed,local
459+ build:coverage --strategy=CoveragePostprocessing=worker,sandboxed,local
460+ # Reduce debug info for faster compilation and smaller binaries
461+ build:coverage --copt=-g1
462+ # Use limited coverage mode for smaller binaries and faster execution (used by Chromium)
463+ build:coverage --copt=-mllvm
464+ build:coverage --copt=-limited-coverage-experimental=true
465+ # Disable gc-sections for faster linking (coverage doesn't need dead code elimination)
466+ build:coverage --linkopt=-Wl,--no-gc-sections
467+ # Disable test result caching to ensure fresh coverage data is generated
468+ coverage --nocache_test_results
434469coverage --test_tag_filters=-off-by-default,-requires-fuzzilli,-requires-container-engine,-lint,-benchmark,-workerd-benchmark,-no-coverage
435470# Coverage instrumentation slows down test execution, so extend timeouts
436471# We disable enormous tests due to the slowdown (CI jobs have a 6h max duration)
437472coverage --test_size_filters=-enormous
438- coverage --test_timeout=60 ,240,240,240
473+ coverage --test_timeout=240 ,240,240,240
439474coverage --build_tests_only
440475coverage --config=coverage
476+ coverage --combined_report=lcov
441477
442478# This config is defined internally and enabled on many machines.
443479# Defining it as empty just so these machines can run build commands from the workerd repo
0 commit comments