@@ -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 used by collect_cc_coverage.sh for merging .profraw files.
425+ build:coverage --action_env=COVERAGE_GCOV_PATH=/usr/bin/llvm-profdata
426+ build:coverage --test_env=COVERAGE_GCOV_PATH=/usr/bin/llvm-profdata
418427# BAZEL_LLVM_COV is used by rules_cc to generate coverage reports from profile data
419428build:coverage --action_env=BAZEL_LLVM_COV=llvm-cov
420429build: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
430+ # LLVM_COV is used by collect_cc_coverage.sh for generating LCOV output
431+ build:coverage --test_env=LLVM_COV=llvm-cov
432+ # GENERATE_LLVM_LCOV=1 tells collect_cc_coverage.sh to use llvm-cov export to generate LCOV format
433+ # instead of just outputting raw profdata. LLVM_COV specifies the llvm-cov binary to use.
434+ build:coverage --test_env=GENERATE_LLVM_LCOV=1
425435build:coverage --experimental_use_llvm_covmap
426436build:coverage --experimental_generate_llvm_lcov
437+ # Ensure that we fetch coverage data from remote cache
427438build:coverage --experimental_fetch_all_coverage_outputs
439+ build:coverage --experimental_split_coverage_postprocessing
440+ # Allow coverage outputs to be writable for post-processing
441+ build:coverage --experimental_writable_outputs
428442build:coverage --collect_code_coverage
429- build:coverage --instrumentation_filter="^//,-//external"
443+ # Only instrument source code, not tests or tools - significantly speeds up coverage builds
444+ build:coverage --instrumentation_filter="^//src/workerd[/:],^//src/rust[/:]"
430445build:coverage --instrument_test_targets
446+ # Disable coverage instrumentation for external dependencies to speed up compilation.
447+ # Coverage for V8/external code is not useful for our purposes.
448+ # These flags negate -fprofile-instr-generate and -fcoverage-mapping set by rules_cc.
449+ build:coverage --per_file_copt=external/.*@-fno-profile-instr-generate,-fno-coverage-mapping
431450# KJ uses _exit() by default which bypasses atexit handlers and prevents LLVM profile runtime
432451# from writing coverage data. KJ_CLEAN_SHUTDOWN forces use of normal exit() instead.
433452build:coverage --test_env=KJ_CLEAN_SHUTDOWN=1
453+ # Use -O1 for faster compilation - coverage builds don't need heavy optimization
454+ build:coverage --copt=-O1
455+ # External dependencies can use -O2 since they're not instrumented anyway
456+ build:coverage --config=v8-codegen-opt
457+ # Run coverage-related actions locally with sandboxing - remote execution doesn't support LLVM coverage well
458+ build:coverage --strategy=TestRunner=worker,sandboxed,local
459+ build:coverage --strategy=CoverageReport=worker,sandboxed,local
460+ build:coverage --strategy=CoveragePostprocessing=worker,sandboxed,local
461+ # Reduce debug info for faster compilation and smaller binaries
462+ build:coverage --copt=-g1
463+ # Use limited coverage mode for smaller binaries and faster execution (used by Chromium)
464+ build:coverage --copt=-mllvm
465+ build:coverage --copt=-limited-coverage-experimental=true
434466coverage --test_tag_filters=-off-by-default,-requires-fuzzilli,-requires-container-engine,-lint,-benchmark,-workerd-benchmark,-no-coverage
467+ # Let tests know they're running in CI (normally set by ci-test but we can't use that config
468+ # due to --remote_download_minimal which prevents coverage data from being fetched)
469+ coverage --test_env=CI=true
470+ coverage --config=wpt-test
435471# Coverage instrumentation slows down test execution, so extend timeouts
436472# We disable enormous tests due to the slowdown (CI jobs have a 6h max duration)
437473coverage --test_size_filters=-enormous
438- coverage --test_timeout=60 ,240,240,240
474+ coverage --test_timeout=240 ,240,240,240
439475coverage --build_tests_only
440- coverage --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