From 776fe3f999e637f6ae00a52aba88d4c2df0f25dc Mon Sep 17 00:00:00 2001 From: Paul Fagerburg Date: Thu, 11 Jun 2020 10:51:19 -0600 Subject: makefile: use separate directory for code coverage When building host-based unit tests for code coverage, put the build outputs in a different directory. Because the code coverage build has calls into gcov library functions, a partial rebuild without code coverage will result in undefined linker errors. The previous solution was an inefficient cycle of `make clobber` and full rebuild when switching between building with and without code coverage. BUG=b:157091606 BRANCH=None TEST=`make buildall -j ; make coverage -j` Verify that build/host and build/coverage both exist, and that code coverage data (*.gcno, *.gcda, *.info) is only in build/coverage. Signed-off-by: Paul Fagerburg Change-Id: Iac0b18068082d34546aa15b174f86efb6a7f41a7 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2242351 Tested-by: Paul Fagerburg Reviewed-by: Jett Rink Reviewed-by: Jack Rosenthal Commit-Queue: Paul Fagerburg --- docs/code_coverage.md | 21 +-------------------- 1 file changed, 1 insertion(+), 20 deletions(-) (limited to 'docs') diff --git a/docs/code_coverage.md b/docs/code_coverage.md index 92f091e52d..458d87b7c5 100644 --- a/docs/code_coverage.md +++ b/docs/code_coverage.md @@ -21,26 +21,7 @@ This target will compile and link the unit tests with `--coverage` flag (which pulls in the `gcov` libraries), run the tests, and then process the profiling data into a code coverage report using the `lcov` and `genhtml` tools. -The coverage report top-level page is `build/host/coverage_rpt/index.html`. - -### `make clobber` is required - -**Always** `make clobber` when switching from building with code coverage -to building without code coverage, or from building without code coverage -to building with code coverage. `make clean` is not sufficient. - -`make buildall -j ; make clobber ; make coverage -j` - -`make coverage -j ; make clobber ; make buildall -j` - -If you do not `make clobber`, you will get link-time errors such as: - -``` -core/host/task.c:558: undefined reference to `__gcov_init' -build/host/online_calibration/RO/core/host/timer.o:(.data+0x5b0): undefined reference to `__gcov_merge_add' -``` - -Note that `make clobber` will delete the coverage report. +The coverage report top-level page is `build/coverage/coverage_rpt/index.html`. ### Noise in the build output -- cgit v1.2.1