@@ -311,16 +311,15 @@ HOST_GNU_TYPE= @host@
311
311
# PROFILE_TASK="-m test --pgo-extended"
312
312
PROFILE_TASK= @PROFILE_TASK@
313
313
314
- # report files for gcov / lcov coverage report
315
- COVERAGE_INFO= $(abs_builddir)/coverage.info
316
- COVERAGE_REPORT=$(abs_builddir)/lcov-report
317
- COVERAGE_LCOV_OPTIONS=--rc lcov_branch_coverage=1
318
- COVERAGE_REPORT_OPTIONS=--rc lcov_branch_coverage=1 --branch-coverage --title "CPython $(VERSION) LCOV report [commit $(shell $(GITVERSION))]"
319
-
320
- # report files for llvm-cov coverage report
321
- COVERAGE_INFO_LLVM= $(abs_builddir)/coverage.profdata
322
- COVERAGE_REPORT_LLVM=$(abs_builddir)/llvm-cov-report
323
- COVERAGE_REPORT_OPTIONS_LLVM=-show-branches=count -show-regions
314
+ # parameters for coverage
315
+ COVERAGE_CC=@COVERAGE_CC@
316
+ COVERAGE_CFLAGS=@COVERAGE_CFLAGS@
317
+ COVERAGE_LDFLAGS=@COVERAGE_LDFLAGS@
318
+ COVERAGE_GEN_TARGET=@COVERAGE_GEN_TARGET@
319
+ COVERAGE_INFO=$(abs_builddir)/@COVERAGE_INFO@
320
+ COVERAGE_REPORT=$(abs_builddir)/coverage-report
321
+ COVERAGE_OPTIONS=@COVERAGE_OPTIONS@
322
+ COVERAGE_REPORT_OPTIONS=@COVERAGE_REPORT_OPTIONS@
324
323
325
324
# === Definitions added by makesetup ===
326
325
@@ -658,36 +657,38 @@ bolt-opt: @PREBOLT_RULE@
658
657
rm -f $(BUILDPYTHON).bolt_inst
659
658
mv $(BUILDPYTHON).bolt $(BUILDPYTHON)
660
659
661
- .PHONY=coverage-report
660
+ .PHONY=coverage-report coverage coverage-generate-lcov coverage-generate-profdata
662
661
coverage-report:
663
- @if [ $(CC_NAME) = "gcc" ]; then \
664
- $(MAKE) coverage-report-lcov; \
665
- elif [ $(CC_NAME) = "clang" ]; then \
666
- $(MAKE) coverage-report-llvm; \
667
- else \
668
- echo "Coverage is not supported with the $(CC_NAME) compiler"; \
669
- exit 1; \
670
- fi
662
+ @ # build with coverage info
663
+ $(MAKE) coverage
664
+ @ # run tests, ignore failures
665
+ @ # The LLVM_PROFILE_FILE must specify %m so results can be collected in parallel.
666
+ @ # Also, must be an absolute path since test suite changes working directory.
667
+ LLVM_PROFILE_FILE=${abs_builddir}/python%m.profraw $(TESTRUNNER) $(TESTOPTS) || true
668
+ @ # build lcov report
669
+ $(MAKE) $(COVERAGE_GEN_TARGET)
670
+ @echo
671
+ @echo "coverage report at $(COVERAGE_REPORT)/index.html"
672
+ @echo
671
673
672
- # Compile and run with gcov
673
- .PHONY=coverage-gcc coverage-lcov coverage-report-lcov
674
- coverage-gcc:
674
+ # Compile and run generating coverage
675
+ coverage:
675
676
@echo "Building with support for coverage checking:"
676
677
$(MAKE) clean
677
- $(MAKE) @DEF_MAKE_RULE@ CFLAGS="$(CFLAGS) -O0 -pg --coverage " LDFLAGS="$(LDFLAGS) --coverage "
678
+ $(MAKE) @DEF_MAKE_RULE@ CC="$(COVERAGE_CC)" CFLAGS="$(CFLAGS) $(COVERAGE_CFLAGS) " LDFLAGS="$(LDFLAGS) $(COVERAGE_LDFLAGS) "
678
679
679
- coverage-lcov:
680
+ coverage-generate- lcov:
680
681
@echo "Creating Coverage HTML report with LCOV:"
681
682
@rm -f $(COVERAGE_INFO)
682
683
@rm -rf $(COVERAGE_REPORT)
683
- @lcov $(COVERAGE_LCOV_OPTIONS ) --capture \
684
+ @lcov $(COVERAGE_OPTIONS ) --capture \
684
685
--directory $(abs_builddir) \
685
686
--base-directory $(realpath $(abs_builddir)) \
686
687
--path $(realpath $(abs_srcdir)) \
687
688
--output-file $(COVERAGE_INFO)
688
689
@ # remove 3rd party modules, system headers and internal files with
689
690
@ # debug, test or dummy functions.
690
- @lcov $(COVERAGE_LCOV_OPTIONS ) --remove $(COVERAGE_INFO) \
691
+ @lcov $(COVERAGE_OPTIONS ) --remove $(COVERAGE_INFO) \
691
692
'*/Modules/_blake2/impl/*' \
692
693
'*/Modules/_ctypes/libffi*/*' \
693
694
'*/Modules/_decimal/libmpdec/*' \
@@ -702,51 +703,15 @@ coverage-lcov:
702
703
@genhtml $(COVERAGE_INFO) \
703
704
--output-directory $(COVERAGE_REPORT) \
704
705
$(COVERAGE_REPORT_OPTIONS)
705
- @echo
706
- @echo "lcov report at $(COVERAGE_REPORT)/index.html"
707
- @echo
708
-
709
- # Force regeneration of parser and frozen modules
710
- coverage-report-lcov: regen-token regen-frozen
711
- @ # build with coverage info
712
- $(MAKE) coverage-gcc
713
- @ # run tests, ignore failures
714
- $(TESTRUNNER) $(TESTOPTS) || true
715
- @ # build lcov report
716
- $(MAKE) coverage-lcov
717
706
718
- # Compile and calculate coverage with llvm-cov
719
- .PHONY=coverage-clang coverage-profdata coverage-report-llvm
720
-
721
- coverage-clang:
722
- @echo "Building with support for coverage checking:"
723
- $(MAKE) clean
724
- @ # Override CC rather than CFLAGS since these flags must come first
725
- $(MAKE) @DEF_MAKE_RULE@ CC="$(CC) -fprofile-instr-generate -fcoverage-mapping"
726
-
727
- coverage-profdata:
707
+ coverage-generate-profdata:
728
708
@echo "Creating Coverage HTML report with llvm-profdata/llvm-cov:"
729
- @rm -f $(COVERAGE_INFO_LLVM )
730
- @rm -rf $(COVERAGE_REPORT_LLVM )
709
+ @rm -f $(COVERAGE_INFO )
710
+ @rm -rf $(COVERAGE_REPORT )
731
711
@ # Merge coverage results
732
- $(LLVM_PROFDATA) merge -sparse python*.profraw -o $(COVERAGE_INFO_LLVM )
712
+ $(LLVM_PROFDATA) merge -sparse python*.profraw -o $(COVERAGE_INFO )
733
713
@ # Generate HTML
734
- $(LLVM_COV) show -format=html -output-dir=$(COVERAGE_REPORT_LLVM) -instr-profile=$(COVERAGE_INFO_LLVM) $(COVERAGE_REPORT_OPTIONS_LLVM) python .
735
- @echo
736
- @echo "llvm-cov report at $(COVERAGE_REPORT_LLVM)/index.html"
737
- @echo
738
-
739
- # Force regeneration of parser and importlib
740
- # Specify the LLVM_PROFILE_FILE using %m so multiple shared objects can write
741
- # in parallel. Set the full path to the directory so results aren't written
742
- # into temporary directories created by tests.
743
- coverage-report-llvm: regen-token regen-importlib
744
- @ # build with coverage info
745
- $(MAKE) coverage-clang
746
- @ # run tests, ignore failures
747
- LLVM_PROFILE_FILE=${PWD}/python%m.profraw $(TESTRUNNER) $(TESTOPTS) || true
748
- @ # build llvm-cov report
749
- $(MAKE) coverage-profdata
714
+ $(LLVM_COV) show -format=html -output-dir=$(COVERAGE_REPORT) -instr-profile=$(COVERAGE_INFO) $(COVERAGE_REPORT_OPTIONS) python .
750
715
751
716
# Run "Argument Clinic" over all source files
752
717
.PHONY=clinic
0 commit comments