All of lore.kernel.org
 help / color / mirror / Atom feed
* + kbuild-move-gcov-flags-to-scripts-makefilegcov.patch added to mm-nonmm-unstable branch
@ 2026-10-02  0:51 Andrew Morton
  0 siblings, 0 replies; only message in thread
From: Andrew Morton @ 2026-10-02  0:51 UTC (permalink / raw)
  To: mm-commits, zaslonko, oberpar, nsc, nathan, masahiroy, arnd,
	khorenko, akpm


The patch titled
     Subject: kbuild: move GCOV flags to scripts/Makefile.gcov
has been added to the -mm mm-nonmm-unstable branch.  Its filename is
     kbuild-move-gcov-flags-to-scripts-makefilegcov.patch

This patch will shortly appear at
     https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/kbuild-move-gcov-flags-to-scripts-makefilegcov.patch

This patch will later appear in the mm-nonmm-unstable branch at
    git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm

Before you just go and hit "reply", please:
   a) Consider who else should be cc'ed
   b) Prefer to cc a suitable mailing list as well
   c) Ideally: find the original patch on the mailing list and do a
      reply-to-all to that, adding suitable additional cc's

*** Remember to use Documentation/process/submit-checklist.rst when testing your code ***

The -mm tree is included into linux-next via various
branches at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
and is updated there most days

------------------------------------------------------
From: Konstantin Khorenko <khorenko@virtuozzo.com>
Subject: kbuild: move GCOV flags to scripts/Makefile.gcov
Date: Thu, 01 Oct 2026 18:57:12 +0200

 * 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>
---

 MAINTAINERS           |    1 +
 Makefile              |   22 +---------------------
 scripts/Makefile.gcov |   21 +++++++++++++++++++++
 3 files changed, 23 insertions(+), 21 deletions(-)

--- a/MAINTAINERS~kbuild-move-gcov-flags-to-scripts-makefilegcov
+++ a/MAINTAINERS
@@ -10898,6 +10898,7 @@ M:	Peter Oberparleiter <oberpar@linux.ib
 S:	Maintained
 F:	Documentation/dev-tools/gcov.rst
 F:	kernel/gcov/
+F:	scripts/Makefile.gcov
 
 GDB KERNEL DEBUGGING HELPER SCRIPTS
 M:	Jan Kiszka <jan.kiszka@siemens.com>
--- a/Makefile~kbuild-move-gcov-flags-to-scripts-makefilegcov
+++ a/Makefile
@@ -1176,27 +1176,6 @@ endif
 # Ensure compilers do not transform certain loops into calls to wcslen()
 KBUILD_CFLAGS += -fno-builtin-wcslen
 
-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
-
 # change __FILE__ to the relative path to the source directory
 ifdef building_out_of_srctree
 KBUILD_CPPFLAGS += -fmacro-prefix-map=$(srcroot)/=
@@ -1214,6 +1193,7 @@ include-$(CONFIG_KCSAN)		+= scripts/Make
 include-$(CONFIG_KMSAN)		+= scripts/Makefile.kmsan
 include-$(CONFIG_UBSAN)		+= scripts/Makefile.ubsan
 include-$(CONFIG_KCOV)		+= scripts/Makefile.kcov
+include-$(CONFIG_GCOV_KERNEL)	+= scripts/Makefile.gcov
 include-$(CONFIG_RANDSTRUCT)	+= scripts/Makefile.randstruct
 include-$(CONFIG_KSTACK_ERASE)	+= scripts/Makefile.kstack_erase
 include-$(CONFIG_AUTOFDO_CLANG)	+= scripts/Makefile.autofdo
diff --git a/scripts/Makefile.gcov a/scripts/Makefile.gcov
new file mode 100644
--- /dev/null
+++ a/scripts/Makefile.gcov
@@ -0,0 +1,21 @@
+# 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
_

Patches currently in -mm which might be from khorenko@virtuozzo.com are

selftests-core-fix-unshare_test-with-large-fsnr_open.patch
kbuild-use-cflags_gcov-in-the-prefer-atomic-try-run-test.patch
kbuild-move-gcov-flags-to-scripts-makefilegcov.patch


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2026-10-02  0:51 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-02  0:51 + kbuild-move-gcov-flags-to-scripts-makefilegcov.patch added to mm-nonmm-unstable branch Andrew Morton

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.