Skip to contentSkip to conversation

gcov: add support for GCC 14

PATCH Applied Peter Oberparleiter 3 participants 4 messages Jun 10, 2024 – Jun 12, 2024 Gcov based kernel profiling

lore
Share & tools
lore

Peter Oberparleiter

author maintainer
#0 lore raw

PATCH 1/1 gcov: add support for GCC 14

Using gcov on kernels compiled with GCC 14 results in truncated 16-byte long .gcda files with no usable data. To fix this, update GCOV_COUNTERS to match the value defined by GCC 14.

Tested with GCC versions 14.1.0 and 13.2.0.

---
 kernel/gcov/gcc_4_7.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
kernel/gcov/gcc_4_7.c +3 -1
index 74a4ef1da9ad..fd75b4a484d7 100644
@@ -18,7 +18,9 @@
 #include <linux/mm.h>
 #include "gcov.h"
 
-#if (__GNUC__ >= 10)
+#if (__GNUC__ >= 14)
+#define GCOV_COUNTERS			9
+#elif (__GNUC__ >= 10)
 #define GCOV_COUNTERS			8
 #elif (__GNUC__ >= 7)
 #define GCOV_COUNTERS			9
Signature · 1 line
2.40.1
Tested-by on v1 1/1
#1 lore raw
Quoted 31 lines · Peter Oberparleiter

Using gcov on kernels compiled with GCC 14 results in truncated 16-byte long .gcda files with no usable data. To fix this, update GCOV_COUNTERS to match the value defined by GCC 14.

Tested with GCC versions 14.1.0 and 13.2.0.

---
 kernel/gcov/gcc_4_7.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
kernel/gcov/gcc_4_7.c +3 -1
index 74a4ef1da9ad..fd75b4a484d7 100644
@@ -18,7 +18,9 @@
 #include <linux/mm.h>
 #include "gcov.h"
 
-#if (__GNUC__ >= 10)
+#if (__GNUC__ >= 14)
+#define GCOV_COUNTERS			9
+#elif (__GNUC__ >= 10)
 #define GCOV_COUNTERS			8
 #elif (__GNUC__ >= 7)
 #define GCOV_COUNTERS			9
Signature · 1 line
2.40.1

With "gcc (GCC) 14.1.1 20240522 (Red Hat 14.1.1-4)" on Fedora 40:

lines: 58.2% (2350 out of 4036)
functions: 72.2% (197 out of 273)
branches: 35.5% (1037 out of 2923)
calls: 0.0% (0 out of 0)

All were 0% previously.

Signature · 1 line
Chuck Lever
#2 lore raw
Quoted 11 lines · On Mon, 10 Jun 2024 09:41:19 -0400 Chuck Lever <[email protected]> wrote:
Quoted 6 lines · Peter Oberparleiter

Using gcov on kernels compiled with GCC 14 results in truncated 16-byte long .gcda files with no usable data. To fix this, update GCOV_COUNTERS to match the value defined by GCC 14.

Tested with GCC versions 14.1.0 and 13.2.0.

...

I assume this problem will affect people who use gcc-14 to compile older kernels, so I have added cc:stable to this patch.

author maintainer
#3 lore raw
Quoted 9 lines · Andrew Morton
Quoted 8 lines · On Mon, 10 Jun 2024 09:41:19 -0400 Chuck Lever <[email protected]> wrote:
Quoted 6 lines · Peter Oberparleiter

Using gcov on kernels compiled with GCC 14 results in truncated 16-byte long .gcda files with no usable data. To fix this, update GCOV_COUNTERS to match the value defined by GCC 14.

Tested with GCC versions 14.1.0 and 13.2.0.

Quoted 6 lines
Quoted 3 lines

...

I assume this problem will affect people who use gcc-14 to compile older kernels, so I have added cc:stable to this patch.

Yes, adding this fix also to stable kernels makes sense.

Signature · 2 lines
Peter Oberparleiter
Linux on IBM Z Development - IBM Germany R&D