Skip to content

Commit d54a288

Browse files
fmeumcopybara-github
authored andcommitted
Optionally enable LLVM profile continuous mode
LLVM's profile instrumentation offers a continuous mode in which counters are continuously synced to a file rather than being dumped once in an exit hook. This is useful for coverage runs that include binaries that exit abnormally (e.g. in failure tests), but may require additional compiler flags and can negatively impact runtime performance and memory usage. Enabling continuous mode requires adding the "%c" modifier to the value of the LLVM_PROFILE_FILE environment variable. With this commit, the collect_coverage.sh script adds the modifier if the test environment has the variable LLVM_PROFILE_CONTINUOUS_MODE set. This allows both all and individual tests to use continuous mode by setting the variable, either via --test_env or the env attribute. Closes bazelbuild#15166. PiperOrigin-RevId: 454558752 Change-Id: Id03d00d0644742e336feab41ea479d7d8527f6c4
1 parent 5aaa5af commit d54a288

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

tools/test/collect_coverage.sh

+5
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,11 @@ if [[ -z "$GCOV_PREFIX_STRIP" ]]; then
9393
fi
9494
export GCOV_PREFIX="${COVERAGE_DIR}"
9595
export LLVM_PROFILE_FILE="${COVERAGE_DIR}/%h-%p-%m.profraw"
96+
if [[ -n "$LLVM_PROFILE_CONTINUOUS_MODE" ]]; then
97+
# %c enables continuous mode but expands out to nothing, so the position
98+
# within LLVM_PROFILE_FILE does not matter.
99+
export LLVM_PROFILE_FILE="${LLVM_PROFILE_FILE}%c"
100+
fi
96101

97102
# In coverage mode for Java, we need to merge the runtime classpath before
98103
# running the tests. JacocoCoverageRunner uses this merged jar in order

0 commit comments

Comments
 (0)