mirror of
https://github.com/torvalds/linux.git
synced 2026-11-06 21:58:01 +01:00
* split the CFLAGS_GCOV block out of the top-level Makefile into scripts/Makefile.gcov * include it via include-$(CONFIG_GCOV_KERNEL) like neighbour KASAN/KCOV/UBSAN makefiles do * keep the include before scripts/Makefile.gcc-plugins: the try-run must not get -fplugin= options, plugins do not exist on clean builds CFLAGS_GCOV is no longer defined when CONFIG_GCOV_KERNEL is off: * its user in scripts/Makefile.lib is guarded by the CONFIG_GCOV_KERNEL * in i915/xe header an empty value is harmless The try-run compiler invocations also stop running on builds without GCOV. Link: https://lore.kernel.org/20261001-b4-prep-gcov-v1-2-794792e06f24@virtuozzo.com Signed-off-by: Konstantin Khorenko <khorenko@virtuozzo.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Suggested-by: Peter Oberparleiter <oberpar@linux.ibm.com> Cc: Nathan Chancellor <nathan@kernel.org> Cc: Nicolas Schier <nsc@kernel.org> Cc: Masahiro Yamada <masahiroy@kernel.org> Cc: Arnd Bergmann <arnd@arndb.de> Cc: Mikhail Zaslonko <zaslonko@linux.ibm.com>
22 lines
910 B
Makefile
22 lines
910 B
Makefile
# SPDX-License-Identifier: GPL-2.0-only
|
|
CFLAGS_GCOV := -fprofile-arcs -ftest-coverage
|
|
ifdef CONFIG_CC_IS_GCC
|
|
CFLAGS_GCOV += -fno-tree-loop-im
|
|
# Use atomic counter updates to avoid concurrent-access crashes in GCOV.
|
|
# Only enable if -fprofile-update=prefer-atomic does not introduce new
|
|
# undefined symbols (e.g. libatomic calls that the kernel cannot link).
|
|
CFLAGS_GCOV += $(call try-run,\
|
|
echo 'long long x; void f(void){x++;}' | \
|
|
$(CC) $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) -w $(CFLAGS_GCOV) \
|
|
-x c - -c -o "$$TMP.base" && \
|
|
echo 'long long x; void f(void){x++;}' | \
|
|
$(CC) $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) -w $(CFLAGS_GCOV) \
|
|
-fprofile-update=prefer-atomic \
|
|
-x c - -c -o "$$TMP" && \
|
|
$(NM) "$$TMP.base" | grep ' U ' > "$$TMP.ubase" || true ; \
|
|
$(NM) "$$TMP" | grep ' U ' > "$$TMP.utest" || true ; \
|
|
cmp -s "$$TMP.ubase" "$$TMP.utest",\
|
|
-fprofile-update=prefer-atomic)
|
|
endif
|
|
export CFLAGS_GCOV
|