Skip to contentSkip to conversation

gcov: shut up missing prototype warnings for internal stubs

PATCH Applied Arnd Bergmann 2 participants 2 messages Jul 25, 2023 – Jul 28, 2023 Gcov based kernel profiling

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 gcov: shut up missing prototype warnings for internal stubs

From: Arnd Bergmann <[email protected]>

gcov uses global functions that are called from generated code, but these have no prototype in a header, which causes a W=1 build warning:

kernel/gcov/gcc_base.c:12:6: error: no previous prototype for '__gcov_init' [-Werror=missing-prototypes] kernel/gcov/gcc_base.c:40:6: error: no previous prototype for '__gcov_flush' [-Werror=missing-prototypes] kernel/gcov/gcc_base.c:46:6: error: no previous prototype for '__gcov_merge_add' [-Werror=missing-prototypes] kernel/gcov/gcc_base.c:52:6: error: no previous prototype for '__gcov_merge_single' [-Werror=missing-prototypes]

Just turn off these warnings unconditionally for the two files that contain them.

---
 kernel/gcov/Makefile | 2 ++
 1 file changed, 2 insertions(+)
kernel/gcov/Makefile +2 -0
index 16f8ecc7d8821..ccd02afaeffb4 100644
@@ -3,4 +3,6 @@ ccflags-y := -DSRCTREE='"$(srctree)"' -DOBJTREE='"$(objtree)"'
 
 obj-y := base.o fs.o
 obj-$(CONFIG_CC_IS_GCC) += gcc_base.o gcc_4_7.o
+CFLAGS_gcc_base.o += -Wno-missing-prototypes -Wno-missing-declarations
 obj-$(CONFIG_CC_IS_CLANG) += clang.o
+CFLAGS_clang.o += -Wno-missing-prototypes -Wno-missing-declarations
Signature · 1 line
2.39.2
maintainer Acked-by on v2 1/1
#1 lore raw
Quoted 11 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

gcov uses global functions that are called from generated code, but these have no prototype in a header, which causes a W=1 build warning:

kernel/gcov/gcc_base.c:12:6: error: no previous prototype for '__gcov_init' [-Werror=missing-prototypes] kernel/gcov/gcc_base.c:40:6: error: no previous prototype for '__gcov_flush' [-Werror=missing-prototypes] kernel/gcov/gcc_base.c:46:6: error: no previous prototype for '__gcov_merge_add' [-Werror=missing-prototypes] kernel/gcov/gcc_base.c:52:6: error: no previous prototype for '__gcov_merge_single' [-Werror=missing-prototypes]

Quoted 5 lines

Just turn off these warnings unconditionally for the two files that contain them.

Tested successfully with GCC 13.1 and Clang 18. Thanks for the fix!

Andrew, could you add this patch via your tree?

Quoted 15 lines
---
 kernel/gcov/Makefile | 2 ++
 1 file changed, 2 insertions(+)
kernel/gcov/Makefile +2 -0
index 16f8ecc7d8821..ccd02afaeffb4 100644
@@ -3,4 +3,6 @@ ccflags-y := -DSRCTREE='"$(srctree)"' -DOBJTREE='"$(objtree)"'
 
 obj-y := base.o fs.o
 obj-$(CONFIG_CC_IS_GCC) += gcc_base.o gcc_4_7.o
+CFLAGS_gcc_base.o += -Wno-missing-prototypes -Wno-missing-declarations
 obj-$(CONFIG_CC_IS_CLANG) += clang.o
+CFLAGS_clang.o += -Wno-missing-prototypes -Wno-missing-declarations
Signature · 2 lines
Peter Oberparleiter
Linux on IBM Z Development - IBM Germany R&D