btrfs-progs: build: add support for gcov

With 'make D=gcov' the files are built with gcov support. After running
the workload, the results can be viewed by 'gcov file.c' or by
lcov+genhtml.

Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
David Sterba 2023-07-11 16:01:13 +02:00
parent b3b041302e
commit f2b3170c3b
1 changed files with 7 additions and 0 deletions

View File

@ -30,6 +30,7 @@
# tsan - enable thread sanitizer compiler feature
# ubsan - undefined behaviour sanitizer compiler feature
# bcheck - extended build checks
# gcov - enable GCOV support during build
# W=123 build with warnings (default: off)
# DEBUG_CFLAGS additional compiler flags for debugging build
# EXTRA_CFLAGS additional compiler flags
@ -283,6 +284,11 @@ ifeq ("$(origin D)", "command line")
DEBUG_LDFLAGS_INTERNAL = $(DEBUG_LDFLAGS_DEFAULT) $(DEBUG_LDFLAGS)
endif
ifneq (,$(findstring gcov,$(D)))
DEBUG_CFLAGS_INTERNAL += -fprofile-arcs -ftest-coverage --coverage
DEBUG_LDFLAGS_INTERNAL += -fprofile-generate --coverage
endif
ifneq (,$(findstring verbose,$(D)))
DEBUG_CFLAGS_INTERNAL += -DDEBUG_VERBOSE_ERROR=1
endif
@ -840,6 +846,7 @@ clean: $(CLEANDIRS)
crypto/*.o crypto/.deps/*.o.d \
tune/*.o tune/.deps/*.o.d \
libbtrfs/*.o libbtrfs/.deps/*.o.d \
*.gcno *.gcda *.gcov */*.gcno */*.gcda */*/.gcov \
ioctl-test quick-test library-test library-test-static \
mktables btrfs.static mkfs.btrfs.static fssum \
btrfs.box btrfs.box.static json-formatter-test \