* [XEN PATCH v2 0/2] update gcov info for newer versions of gcc
@ 2023-09-08 16:20 Javi Merino
2023-09-08 16:20 ` [XEN PATCH v2 1/2] coverage: simplify the logic of choosing the number of gcov counters depending on the gcc version Javi Merino
2023-09-08 16:20 ` [XEN PATCH v2 2/2] coverage: update gcov info for newer versions of gcc Javi Merino
0 siblings, 2 replies; 11+ messages in thread
From: Javi Merino @ 2023-09-08 16:20 UTC (permalink / raw)
To: xen-devel; +Cc: Javi Merino, Jan Beulich, Henry Wang
The gcov info changes with different versions of gcc. This patch
series updates it so that we can capture coverage for xen built with
newer compilers.
This doesn't solve all the problems with coverage as Xen still crashes
when trying to reset/read coverage[0]. Still, it's a step forward.
[0] https://gitlab.com/xen-project/xen/-/issues/168
I have tested it with a workaround for the aforementioned bug
(commenting out freeing of the init sections) and the following gcc
versions:
- gcc 4.8.5
- gcc 4.9.4
- gcc 6.5.0
- gcc 7.5.0
- gcc 8.5.0
- gcc 9.5.0
- gcc 10.5.0
- gcc 11.4.0
- gcc 12.3.0
Javi Merino (2):
coverage: simplify the logic of choosing the number of gcov counters
depending on the gcc version
coverage: update gcov info for newer versions of gcc
xen/common/coverage/Makefile | 6 +-----
xen/common/coverage/gcc_4_7.c | 39 ++++++++++++++++++++++++++---------
xen/common/coverage/gcc_4_9.c | 33 -----------------------------
xen/common/coverage/gcc_5.c | 33 -----------------------------
xen/common/coverage/gcc_7.c | 30 ---------------------------
5 files changed, 30 insertions(+), 111 deletions(-)
delete mode 100644 xen/common/coverage/gcc_4_9.c
delete mode 100644 xen/common/coverage/gcc_5.c
delete mode 100644 xen/common/coverage/gcc_7.c
--
2.41.0
^ permalink raw reply [flat|nested] 11+ messages in thread
* [XEN PATCH v2 1/2] coverage: simplify the logic of choosing the number of gcov counters depending on the gcc version
2023-09-08 16:20 [XEN PATCH v2 0/2] update gcov info for newer versions of gcc Javi Merino
@ 2023-09-08 16:20 ` Javi Merino
2023-09-11 7:54 ` Jan Beulich
2023-09-08 16:20 ` [XEN PATCH v2 2/2] coverage: update gcov info for newer versions of gcc Javi Merino
1 sibling, 1 reply; 11+ messages in thread
From: Javi Merino @ 2023-09-08 16:20 UTC (permalink / raw)
To: xen-devel
Cc: Javi Merino, Andrew Cooper, George Dunlap, Jan Beulich,
Julien Grall, Stefano Stabellini, Wei Liu
The current structure of choosing the correct file based on the
compiler version makes us make 33 line files just to define a
constant. The changes after gcc 4.7 are minimal, just the number of
counters.
Fold the changes in gcc_4_9.c, gcc_5.c and gcc_7.c into gcc_4_7.c to
remove a lot of the boilerplate and keep the logic of choosing the
GCOV_COUNTER in gcc_4_7.c.
Signed-off-by: Javi Merino <javi.merino@cloud.com>
---
xen/common/coverage/Makefile | 6 +-----
xen/common/coverage/gcc_4_7.c | 17 +++++++++--------
xen/common/coverage/gcc_4_9.c | 33 ---------------------------------
xen/common/coverage/gcc_5.c | 33 ---------------------------------
xen/common/coverage/gcc_7.c | 30 ------------------------------
5 files changed, 10 insertions(+), 109 deletions(-)
delete mode 100644 xen/common/coverage/gcc_4_9.c
delete mode 100644 xen/common/coverage/gcc_5.c
delete mode 100644 xen/common/coverage/gcc_7.c
diff --git a/xen/common/coverage/Makefile b/xen/common/coverage/Makefile
index 63f98c71d6..d729afc9c7 100644
--- a/xen/common/coverage/Makefile
+++ b/xen/common/coverage/Makefile
@@ -1,11 +1,7 @@
obj-y += coverage.o
ifneq ($(CONFIG_CC_IS_CLANG),y)
obj-y += gcov_base.o gcov.o
-obj-y += $(call cc-ifversion,-lt,0407, \
- gcc_3_4.o, $(call cc-ifversion,-lt,0409, \
- gcc_4_7.o, $(call cc-ifversion,-lt,0500, \
- gcc_4_9.o, $(call cc-ifversion,-lt,0700, \
- gcc_5.o, gcc_7.o))))
+obj-y += $(call cc-ifversion,-lt,0407, gcc_3_4.o, gcc_4_7.o)
else
obj-y += llvm.o
endif
diff --git a/xen/common/coverage/gcc_4_7.c b/xen/common/coverage/gcc_4_7.c
index 25b4a8bcdc..ddbc9f4bb0 100644
--- a/xen/common/coverage/gcc_4_7.c
+++ b/xen/common/coverage/gcc_4_7.c
@@ -18,15 +18,16 @@
#include "gcov.h"
-/*
- * GCOV_COUNTERS will be defined if this file is included by other
- * source files.
- */
-#ifndef GCOV_COUNTERS
-# if !(GCC_VERSION >= 40700 && GCC_VERSION < 40900)
-# error "Wrong version of GCC used to compile gcov"
-# endif
+#if (GCC_VERSION >= 40700 && GCC_VERSION < 40900)
#define GCOV_COUNTERS 8
+#elif (GCC_VERSION >= 40900 && GCC_VERSION < 50000)
+#define GCOV_COUNTERS 9
+#elif GCC_VERSION >= 50000 && GCC_VERSION < 70000
+#define GCOV_COUNTERS 10
+#elif GCC_VERSION >= 70000
+#define GCOV_COUNTERS 9
+#else
+#error "Wrong version of GCC used to compile gcov"
#endif
#define GCOV_TAG_FUNCTION_LENGTH 3
diff --git a/xen/common/coverage/gcc_4_9.c b/xen/common/coverage/gcc_4_9.c
deleted file mode 100644
index dcea961936..0000000000
--- a/xen/common/coverage/gcc_4_9.c
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * This code provides functions to handle gcc's profiling data format
- * introduced with gcc 4.7.
- *
- * For a better understanding, refer to gcc source:
- * gcc/gcov-io.h
- * libgcc/libgcov.c
- *
- * Uses gcc-internal data definitions.
- *
- * Imported from Linux and modified for Xen by
- * Wei Liu <wei.liu2@citrix.com>
- */
-
-#include "gcov.h"
-
-#if !(GCC_VERSION >= 40900 && GCC_VERSION < 50000)
-#error "Wrong version of GCC used to compile gcov"
-#endif
-
-#define GCOV_COUNTERS 9
-
-#include "gcc_4_7.c"
-
-/*
- * Local variables:
- * mode: C
- * c-file-style: "BSD"
- * c-basic-offset: 4
- * tab-width: 4
- * indent-tabs-mode: nil
- * End:
- */
diff --git a/xen/common/coverage/gcc_5.c b/xen/common/coverage/gcc_5.c
deleted file mode 100644
index 6e0d276f3b..0000000000
--- a/xen/common/coverage/gcc_5.c
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * This code provides functions to handle gcc's profiling data format
- * introduced with gcc 5.
- *
- * For a better understanding, refer to gcc source:
- * gcc/gcov-io.h
- * libgcc/libgcov.c
- *
- * Uses gcc-internal data definitions.
- *
- * Imported from Linux and modified for Xen by
- * Wei Liu <wei.liu2@citrix.com>
- */
-
-#include "gcov.h"
-
-#if GCC_VERSION < 50000 || GCC_VERSION >= 70000
-#error "Wrong version of GCC used to compile gcov"
-#endif
-
-#define GCOV_COUNTERS 10
-
-#include "gcc_4_7.c"
-
-/*
- * Local variables:
- * mode: C
- * c-file-style: "BSD"
- * c-basic-offset: 4
- * tab-width: 4
- * indent-tabs-mode: nil
- * End:
- */
diff --git a/xen/common/coverage/gcc_7.c b/xen/common/coverage/gcc_7.c
deleted file mode 100644
index 3962eb4c76..0000000000
--- a/xen/common/coverage/gcc_7.c
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * This code provides functions to handle gcc's profiling data format
- * introduced with gcc 7.
- *
- * For a better understanding, refer to gcc source:
- * gcc/gcov-io.h
- * libgcc/libgcov.c
- *
- * Uses gcc-internal data definitions.
- */
-
-#include "gcov.h"
-
-#if GCC_VERSION < 70000
-#error "Wrong version of GCC used to compile gcov"
-#endif
-
-#define GCOV_COUNTERS 9
-
-#include "gcc_4_7.c"
-
-/*
- * Local variables:
- * mode: C
- * c-file-style: "BSD"
- * c-basic-offset: 4
- * tab-width: 4
- * indent-tabs-mode: nil
- * End:
- */
--
2.41.0
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [XEN PATCH v2 2/2] coverage: update gcov info for newer versions of gcc
2023-09-08 16:20 [XEN PATCH v2 0/2] update gcov info for newer versions of gcc Javi Merino
2023-09-08 16:20 ` [XEN PATCH v2 1/2] coverage: simplify the logic of choosing the number of gcov counters depending on the gcc version Javi Merino
@ 2023-09-08 16:20 ` Javi Merino
2023-09-11 8:00 ` Jan Beulich
1 sibling, 1 reply; 11+ messages in thread
From: Javi Merino @ 2023-09-08 16:20 UTC (permalink / raw)
To: xen-devel
Cc: Javi Merino, Andrew Cooper, George Dunlap, Jan Beulich,
Julien Grall, Stefano Stabellini, Wei Liu
Shamelessly copy changes to gcov_info structures from linux so that we
can capture coverage for xen built with newer compilers.
Signed-off-by: Javi Merino <javi.merino@cloud.com>
---
xen/common/coverage/gcc_4_7.c | 24 +++++++++++++++++++++---
1 file changed, 21 insertions(+), 3 deletions(-)
diff --git a/xen/common/coverage/gcc_4_7.c b/xen/common/coverage/gcc_4_7.c
index ddbc9f4bb0..8f6e287474 100644
--- a/xen/common/coverage/gcc_4_7.c
+++ b/xen/common/coverage/gcc_4_7.c
@@ -24,14 +24,23 @@
#define GCOV_COUNTERS 9
#elif GCC_VERSION >= 50000 && GCC_VERSION < 70000
#define GCOV_COUNTERS 10
-#elif GCC_VERSION >= 70000
+#elif GCC_VERSION >= 70000 && GCC_VERSION < 100000
#define GCOV_COUNTERS 9
+#elif GCC_VERSION >= 100000
+#define GCOV_COUNTERS 8
#else
#error "Wrong version of GCC used to compile gcov"
#endif
#define GCOV_TAG_FUNCTION_LENGTH 3
+#if GCC_VERSION >= 120000
+/* Since GCC 12.1, sizes are in BYTES and not in WORDS (4B). */
+#define GCOV_UNIT_SIZE 4
+#else
+#define GCOV_UNIT_SIZE 1
+#endif
+
static struct gcov_info *gcov_info_head;
/**
@@ -89,6 +98,10 @@ struct gcov_info {
unsigned int version;
struct gcov_info *next;
unsigned int stamp;
+#if (GCC_VERSION >= 120000)
+ /* GCC 12.1 introduced a checksum field */
+ unsigned int checksum;
+#endif
const char *filename;
void (*merge[GCOV_COUNTERS])(gcov_type *, unsigned int);
unsigned int n_functions;
@@ -161,13 +174,18 @@ size_t gcov_info_to_gcda(char *buffer, const struct gcov_info *info)
pos += gcov_store_uint32(buffer, pos, info->version);
pos += gcov_store_uint32(buffer, pos, info->stamp);
+#if (GCC_VERSION >= 120000)
+ /* Use zero as checksum of the compilation unit. */
+ pos += gcov_store_uint32(buffer, pos, 0);
+#endif
+
for ( fi_idx = 0; fi_idx < info->n_functions; fi_idx++ )
{
fi_ptr = info->functions[fi_idx];
/* Function record. */
pos += gcov_store_uint32(buffer, pos, GCOV_TAG_FUNCTION);
- pos += gcov_store_uint32(buffer, pos, GCOV_TAG_FUNCTION_LENGTH);
+ pos += gcov_store_uint32(buffer, pos, GCOV_TAG_FUNCTION_LENGTH * GCOV_UNIT_SIZE);
pos += gcov_store_uint32(buffer, pos, fi_ptr->ident);
pos += gcov_store_uint32(buffer, pos, fi_ptr->lineno_checksum);
pos += gcov_store_uint32(buffer, pos, fi_ptr->cfg_checksum);
@@ -182,7 +200,7 @@ size_t gcov_info_to_gcda(char *buffer, const struct gcov_info *info)
/* Counter record. */
pos += gcov_store_uint32(buffer, pos,
GCOV_TAG_FOR_COUNTER(ct_idx));
- pos += gcov_store_uint32(buffer, pos, ci_ptr->num * 2);
+ pos += gcov_store_uint32(buffer, pos, ci_ptr->num * 2 * GCOV_UNIT_SIZE);
for ( cv_idx = 0; cv_idx < ci_ptr->num; cv_idx++ )
pos += gcov_store_uint64(buffer, pos, ci_ptr->values[cv_idx]);
--
2.41.0
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [XEN PATCH v2 1/2] coverage: simplify the logic of choosing the number of gcov counters depending on the gcc version
2023-09-08 16:20 ` [XEN PATCH v2 1/2] coverage: simplify the logic of choosing the number of gcov counters depending on the gcc version Javi Merino
@ 2023-09-11 7:54 ` Jan Beulich
2023-09-11 9:13 ` Javi Merino
2023-09-11 9:48 ` Andrew Cooper
0 siblings, 2 replies; 11+ messages in thread
From: Jan Beulich @ 2023-09-11 7:54 UTC (permalink / raw)
To: Javi Merino
Cc: Andrew Cooper, George Dunlap, Julien Grall, Stefano Stabellini,
Wei Liu, xen-devel
On 08.09.2023 18:20, Javi Merino wrote:
> The current structure of choosing the correct file based on the
> compiler version makes us make 33 line files just to define a
> constant. The changes after gcc 4.7 are minimal, just the number of
> counters.
>
> Fold the changes in gcc_4_9.c, gcc_5.c and gcc_7.c into gcc_4_7.c to
> remove a lot of the boilerplate and keep the logic of choosing the
> GCOV_COUNTER in gcc_4_7.c.
>
> Signed-off-by: Javi Merino <javi.merino@cloud.com>
> ---
> xen/common/coverage/Makefile | 6 +-----
> xen/common/coverage/gcc_4_7.c | 17 +++++++++--------
> xen/common/coverage/gcc_4_9.c | 33 ---------------------------------
> xen/common/coverage/gcc_5.c | 33 ---------------------------------
> xen/common/coverage/gcc_7.c | 30 ------------------------------
> 5 files changed, 10 insertions(+), 109 deletions(-)
> delete mode 100644 xen/common/coverage/gcc_4_9.c
> delete mode 100644 xen/common/coverage/gcc_5.c
> delete mode 100644 xen/common/coverage/gcc_7.c
>
> diff --git a/xen/common/coverage/Makefile b/xen/common/coverage/Makefile
> index 63f98c71d6..d729afc9c7 100644
> --- a/xen/common/coverage/Makefile
> +++ b/xen/common/coverage/Makefile
> @@ -1,11 +1,7 @@
> obj-y += coverage.o
> ifneq ($(CONFIG_CC_IS_CLANG),y)
> obj-y += gcov_base.o gcov.o
> -obj-y += $(call cc-ifversion,-lt,0407, \
> - gcc_3_4.o, $(call cc-ifversion,-lt,0409, \
> - gcc_4_7.o, $(call cc-ifversion,-lt,0500, \
> - gcc_4_9.o, $(call cc-ifversion,-lt,0700, \
> - gcc_5.o, gcc_7.o))))
> +obj-y += $(call cc-ifversion,-lt,0407, gcc_3_4.o, gcc_4_7.o)
> else
> obj-y += llvm.o
> endif
> diff --git a/xen/common/coverage/gcc_4_7.c b/xen/common/coverage/gcc_4_7.c
> index 25b4a8bcdc..ddbc9f4bb0 100644
> --- a/xen/common/coverage/gcc_4_7.c
> +++ b/xen/common/coverage/gcc_4_7.c
> @@ -18,15 +18,16 @@
>
> #include "gcov.h"
>
> -/*
> - * GCOV_COUNTERS will be defined if this file is included by other
> - * source files.
> - */
> -#ifndef GCOV_COUNTERS
> -# if !(GCC_VERSION >= 40700 && GCC_VERSION < 40900)
> -# error "Wrong version of GCC used to compile gcov"
> -# endif
> +#if (GCC_VERSION >= 40700 && GCC_VERSION < 40900)
> #define GCOV_COUNTERS 8
> +#elif (GCC_VERSION >= 40900 && GCC_VERSION < 50000)
> +#define GCOV_COUNTERS 9
> +#elif GCC_VERSION >= 50000 && GCC_VERSION < 70000
> +#define GCOV_COUNTERS 10
> +#elif GCC_VERSION >= 70000
> +#define GCOV_COUNTERS 9
> +#else
> +#error "Wrong version of GCC used to compile gcov"
> #endif
How about inverse order:
#if GCC_VERSION >= 70000
#define GCOV_COUNTERS 9
#elif GCC_VERSION >= 50000
#define GCOV_COUNTERS 10
#elif GCC_VERSION >= 40900
#define GCOV_COUNTERS 9
#elif GCC_VERSION >= 40700
#define GCOV_COUNTERS 8
#else
#error "Wrong version of GCC used to compile gcov"
#endif
Otherwise a nit and a question: Parentheses would want using consistently.
And wouldn't it make sense to combine the two ranges resulting in 9 being
chosen? (Imo in the alternative layout that's less desirable.)
Since the adjustment would be easy to make, I'd be fine doing so while
committing, and then
Reviewed-by: Jan Beulich <jbeulich@suse.com>
As an unrelated remark: gcc_3_4.c is clearly outdated as well, simply by
its name. Imo it would have wanted to be gcc_4_1.c the latest as of commit
03f22f0070f3 ("README: adjust gcc version requirement"), i.e. for over 10
years.
Jan
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [XEN PATCH v2 2/2] coverage: update gcov info for newer versions of gcc
2023-09-08 16:20 ` [XEN PATCH v2 2/2] coverage: update gcov info for newer versions of gcc Javi Merino
@ 2023-09-11 8:00 ` Jan Beulich
2023-09-11 9:19 ` Javi Merino
0 siblings, 1 reply; 11+ messages in thread
From: Jan Beulich @ 2023-09-11 8:00 UTC (permalink / raw)
To: Javi Merino
Cc: Andrew Cooper, George Dunlap, Julien Grall, Stefano Stabellini,
Wei Liu, xen-devel
On 08.09.2023 18:20, Javi Merino wrote:
> Shamelessly copy changes to gcov_info structures from linux so that we
> can capture coverage for xen built with newer compilers.
>
> Signed-off-by: Javi Merino <javi.merino@cloud.com>
> ---
> xen/common/coverage/gcc_4_7.c | 24 +++++++++++++++++++++---
> 1 file changed, 21 insertions(+), 3 deletions(-)
>
> diff --git a/xen/common/coverage/gcc_4_7.c b/xen/common/coverage/gcc_4_7.c
> index ddbc9f4bb0..8f6e287474 100644
> --- a/xen/common/coverage/gcc_4_7.c
> +++ b/xen/common/coverage/gcc_4_7.c
> @@ -24,14 +24,23 @@
> #define GCOV_COUNTERS 9
> #elif GCC_VERSION >= 50000 && GCC_VERSION < 70000
> #define GCOV_COUNTERS 10
> -#elif GCC_VERSION >= 70000
> +#elif GCC_VERSION >= 70000 && GCC_VERSION < 100000
> #define GCOV_COUNTERS 9
> +#elif GCC_VERSION >= 100000
> +#define GCOV_COUNTERS 8
> #else
> #error "Wrong version of GCC used to compile gcov"
> #endif
This would need adjustment if patch 1 is adjusted as suggested, then ...
> #define GCOV_TAG_FUNCTION_LENGTH 3
>
> +#if GCC_VERSION >= 120000
> +/* Since GCC 12.1, sizes are in BYTES and not in WORDS (4B). */
> +#define GCOV_UNIT_SIZE 4
> +#else
> +#define GCOV_UNIT_SIZE 1
> +#endif
... making the earlier group also match this one (which already works
downwards in version number space).
As to the comments (here and below): Since the version check is for
12.0, may I suggest to simply say "gcc 12" everywhere?
> @@ -89,6 +98,10 @@ struct gcov_info {
> unsigned int version;
> struct gcov_info *next;
> unsigned int stamp;
> +#if (GCC_VERSION >= 120000)
Nit: Here any below parentheses likely want omitting, to match there
being none further up. Preferably with the adjustments (which again
I'd be okay doing while committing, so long as you agree)
Acked-by: Jan Beulich <jbeulich@suse.com>
Jan
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [XEN PATCH v2 1/2] coverage: simplify the logic of choosing the number of gcov counters depending on the gcc version
2023-09-11 7:54 ` Jan Beulich
@ 2023-09-11 9:13 ` Javi Merino
2023-09-11 9:48 ` Andrew Cooper
1 sibling, 0 replies; 11+ messages in thread
From: Javi Merino @ 2023-09-11 9:13 UTC (permalink / raw)
To: Jan Beulich
Cc: Andrew Cooper, George Dunlap, Julien Grall, Stefano Stabellini,
Wei Liu, xen-devel
On Mon, Sep 11, 2023 at 09:54:53AM +0200, Jan Beulich wrote:
> On 08.09.2023 18:20, Javi Merino wrote:
> > The current structure of choosing the correct file based on the
> > compiler version makes us make 33 line files just to define a
> > constant. The changes after gcc 4.7 are minimal, just the number of
> > counters.
> >
> > Fold the changes in gcc_4_9.c, gcc_5.c and gcc_7.c into gcc_4_7.c to
> > remove a lot of the boilerplate and keep the logic of choosing the
> > GCOV_COUNTER in gcc_4_7.c.
> >
> > Signed-off-by: Javi Merino <javi.merino@cloud.com>
> > ---
> > xen/common/coverage/Makefile | 6 +-----
> > xen/common/coverage/gcc_4_7.c | 17 +++++++++--------
> > xen/common/coverage/gcc_4_9.c | 33 ---------------------------------
> > xen/common/coverage/gcc_5.c | 33 ---------------------------------
> > xen/common/coverage/gcc_7.c | 30 ------------------------------
> > 5 files changed, 10 insertions(+), 109 deletions(-)
> > delete mode 100644 xen/common/coverage/gcc_4_9.c
> > delete mode 100644 xen/common/coverage/gcc_5.c
> > delete mode 100644 xen/common/coverage/gcc_7.c
> >
> > diff --git a/xen/common/coverage/Makefile b/xen/common/coverage/Makefile
> > index 63f98c71d6..d729afc9c7 100644
> > --- a/xen/common/coverage/Makefile
> > +++ b/xen/common/coverage/Makefile
> > @@ -1,11 +1,7 @@
> > obj-y += coverage.o
> > ifneq ($(CONFIG_CC_IS_CLANG),y)
> > obj-y += gcov_base.o gcov.o
> > -obj-y += $(call cc-ifversion,-lt,0407, \
> > - gcc_3_4.o, $(call cc-ifversion,-lt,0409, \
> > - gcc_4_7.o, $(call cc-ifversion,-lt,0500, \
> > - gcc_4_9.o, $(call cc-ifversion,-lt,0700, \
> > - gcc_5.o, gcc_7.o))))
> > +obj-y += $(call cc-ifversion,-lt,0407, gcc_3_4.o, gcc_4_7.o)
> > else
> > obj-y += llvm.o
> > endif
> > diff --git a/xen/common/coverage/gcc_4_7.c b/xen/common/coverage/gcc_4_7.c
> > index 25b4a8bcdc..ddbc9f4bb0 100644
> > --- a/xen/common/coverage/gcc_4_7.c
> > +++ b/xen/common/coverage/gcc_4_7.c
> > @@ -18,15 +18,16 @@
> >
> > #include "gcov.h"
> >
> > -/*
> > - * GCOV_COUNTERS will be defined if this file is included by other
> > - * source files.
> > - */
> > -#ifndef GCOV_COUNTERS
> > -# if !(GCC_VERSION >= 40700 && GCC_VERSION < 40900)
> > -# error "Wrong version of GCC used to compile gcov"
> > -# endif
> > +#if (GCC_VERSION >= 40700 && GCC_VERSION < 40900)
> > #define GCOV_COUNTERS 8
> > +#elif (GCC_VERSION >= 40900 && GCC_VERSION < 50000)
> > +#define GCOV_COUNTERS 9
> > +#elif GCC_VERSION >= 50000 && GCC_VERSION < 70000
> > +#define GCOV_COUNTERS 10
> > +#elif GCC_VERSION >= 70000
> > +#define GCOV_COUNTERS 9
> > +#else
> > +#error "Wrong version of GCC used to compile gcov"
> > #endif
>
> How about inverse order:
>
> #if GCC_VERSION >= 70000
> #define GCOV_COUNTERS 9
> #elif GCC_VERSION >= 50000
> #define GCOV_COUNTERS 10
> #elif GCC_VERSION >= 40900
> #define GCOV_COUNTERS 9
> #elif GCC_VERSION >= 40700
> #define GCOV_COUNTERS 8
> #else
> #error "Wrong version of GCC used to compile gcov"
> #endif
>
> Otherwise a nit and a question: Parentheses would want using consistently.
True, the parenthesis are unnecessary and inconsistent in the patch.
> And wouldn't it make sense to combine the two ranges resulting in 9 being
> chosen? (Imo in the alternative layout that's less desirable.)
>
> Since the adjustment would be easy to make, I'd be fine doing so while
> committing, and then
> Reviewed-by: Jan Beulich <jbeulich@suse.com>
Happy for you to do the changes. Or I can do it and fix the next
patch as well.
Cheers,
Javi
> As an unrelated remark: gcc_3_4.c is clearly outdated as well, simply by
> its name. Imo it would have wanted to be gcc_4_1.c the latest as of commit
> 03f22f0070f3 ("README: adjust gcc version requirement"), i.e. for over 10
> years.
>
> Jan
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [XEN PATCH v2 2/2] coverage: update gcov info for newer versions of gcc
2023-09-11 8:00 ` Jan Beulich
@ 2023-09-11 9:19 ` Javi Merino
0 siblings, 0 replies; 11+ messages in thread
From: Javi Merino @ 2023-09-11 9:19 UTC (permalink / raw)
To: Jan Beulich
Cc: Andrew Cooper, George Dunlap, Julien Grall, Stefano Stabellini,
Wei Liu, xen-devel
On Mon, Sep 11, 2023 at 10:00:14AM +0200, Jan Beulich wrote:
> On 08.09.2023 18:20, Javi Merino wrote:
> > Shamelessly copy changes to gcov_info structures from linux so that we
> > can capture coverage for xen built with newer compilers.
> >
> > Signed-off-by: Javi Merino <javi.merino@cloud.com>
> > ---
> > xen/common/coverage/gcc_4_7.c | 24 +++++++++++++++++++++---
> > 1 file changed, 21 insertions(+), 3 deletions(-)
> >
> > diff --git a/xen/common/coverage/gcc_4_7.c b/xen/common/coverage/gcc_4_7.c
> > index ddbc9f4bb0..8f6e287474 100644
> > --- a/xen/common/coverage/gcc_4_7.c
> > +++ b/xen/common/coverage/gcc_4_7.c
> > @@ -24,14 +24,23 @@
> > #define GCOV_COUNTERS 9
> > #elif GCC_VERSION >= 50000 && GCC_VERSION < 70000
> > #define GCOV_COUNTERS 10
> > -#elif GCC_VERSION >= 70000
> > +#elif GCC_VERSION >= 70000 && GCC_VERSION < 100000
> > #define GCOV_COUNTERS 9
> > +#elif GCC_VERSION >= 100000
> > +#define GCOV_COUNTERS 8
> > #else
> > #error "Wrong version of GCC used to compile gcov"
> > #endif
>
> This would need adjustment if patch 1 is adjusted as suggested, then ...
>
> > #define GCOV_TAG_FUNCTION_LENGTH 3
> >
> > +#if GCC_VERSION >= 120000
> > +/* Since GCC 12.1, sizes are in BYTES and not in WORDS (4B). */
> > +#define GCOV_UNIT_SIZE 4
> > +#else
> > +#define GCOV_UNIT_SIZE 1
> > +#endif
>
> ... making the earlier group also match this one (which already works
> downwards in version number space).
True
> As to the comments (here and below): Since the version check is for
> 12.0, may I suggest to simply say "gcc 12" everywhere?
>
> > @@ -89,6 +98,10 @@ struct gcov_info {
> > unsigned int version;
> > struct gcov_info *next;
> > unsigned int stamp;
> > +#if (GCC_VERSION >= 120000)
>
> Nit: Here any below parentheses likely want omitting, to match there
> being none further up. Preferably with the adjustments (which again
> I'd be okay doing while committing, so long as you agree)
> Acked-by: Jan Beulich <jbeulich@suse.com>
I'm ok with those changes and I'm fine with you doing them.
Cheers,
Javi
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [XEN PATCH v2 1/2] coverage: simplify the logic of choosing the number of gcov counters depending on the gcc version
2023-09-11 7:54 ` Jan Beulich
2023-09-11 9:13 ` Javi Merino
@ 2023-09-11 9:48 ` Andrew Cooper
2023-09-11 9:53 ` Jan Beulich
1 sibling, 1 reply; 11+ messages in thread
From: Andrew Cooper @ 2023-09-11 9:48 UTC (permalink / raw)
To: Jan Beulich, Javi Merino
Cc: George Dunlap, Julien Grall, Stefano Stabellini, Wei Liu,
xen-devel
On 11/09/2023 8:54 am, Jan Beulich wrote:
> On 08.09.2023 18:20, Javi Merino wrote:
>> The current structure of choosing the correct file based on the
>> compiler version makes us make 33 line files just to define a
>> constant. The changes after gcc 4.7 are minimal, just the number of
>> counters.
>>
>> Fold the changes in gcc_4_9.c, gcc_5.c and gcc_7.c into gcc_4_7.c to
>> remove a lot of the boilerplate and keep the logic of choosing the
>> GCOV_COUNTER in gcc_4_7.c.
>>
>> Signed-off-by: Javi Merino <javi.merino@cloud.com>
>> ---
>> xen/common/coverage/Makefile | 6 +-----
>> xen/common/coverage/gcc_4_7.c | 17 +++++++++--------
>> xen/common/coverage/gcc_4_9.c | 33 ---------------------------------
>> xen/common/coverage/gcc_5.c | 33 ---------------------------------
>> xen/common/coverage/gcc_7.c | 30 ------------------------------
>> 5 files changed, 10 insertions(+), 109 deletions(-)
>> delete mode 100644 xen/common/coverage/gcc_4_9.c
>> delete mode 100644 xen/common/coverage/gcc_5.c
>> delete mode 100644 xen/common/coverage/gcc_7.c
>>
>> diff --git a/xen/common/coverage/Makefile b/xen/common/coverage/Makefile
>> index 63f98c71d6..d729afc9c7 100644
>> --- a/xen/common/coverage/Makefile
>> +++ b/xen/common/coverage/Makefile
>> @@ -1,11 +1,7 @@
>> obj-y += coverage.o
>> ifneq ($(CONFIG_CC_IS_CLANG),y)
>> obj-y += gcov_base.o gcov.o
>> -obj-y += $(call cc-ifversion,-lt,0407, \
>> - gcc_3_4.o, $(call cc-ifversion,-lt,0409, \
>> - gcc_4_7.o, $(call cc-ifversion,-lt,0500, \
>> - gcc_4_9.o, $(call cc-ifversion,-lt,0700, \
>> - gcc_5.o, gcc_7.o))))
>> +obj-y += $(call cc-ifversion,-lt,0407, gcc_3_4.o, gcc_4_7.o)
>> else
>> obj-y += llvm.o
>> endif
>> diff --git a/xen/common/coverage/gcc_4_7.c b/xen/common/coverage/gcc_4_7.c
>> index 25b4a8bcdc..ddbc9f4bb0 100644
>> --- a/xen/common/coverage/gcc_4_7.c
>> +++ b/xen/common/coverage/gcc_4_7.c
>> @@ -18,15 +18,16 @@
>>
>> #include "gcov.h"
>>
>> -/*
>> - * GCOV_COUNTERS will be defined if this file is included by other
>> - * source files.
>> - */
>> -#ifndef GCOV_COUNTERS
>> -# if !(GCC_VERSION >= 40700 && GCC_VERSION < 40900)
>> -# error "Wrong version of GCC used to compile gcov"
>> -# endif
>> +#if (GCC_VERSION >= 40700 && GCC_VERSION < 40900)
>> #define GCOV_COUNTERS 8
>> +#elif (GCC_VERSION >= 40900 && GCC_VERSION < 50000)
>> +#define GCOV_COUNTERS 9
>> +#elif GCC_VERSION >= 50000 && GCC_VERSION < 70000
>> +#define GCOV_COUNTERS 10
>> +#elif GCC_VERSION >= 70000
>> +#define GCOV_COUNTERS 9
>> +#else
>> +#error "Wrong version of GCC used to compile gcov"
>> #endif
> How about inverse order:
>
> #if GCC_VERSION >= 70000
> #define GCOV_COUNTERS 9
> #elif GCC_VERSION >= 50000
> #define GCOV_COUNTERS 10
> #elif GCC_VERSION >= 40900
> #define GCOV_COUNTERS 9
> #elif GCC_VERSION >= 40700
> #define GCOV_COUNTERS 8
> #else
> #error "Wrong version of GCC used to compile gcov"
> #endif
Forward order is the one that results in a smaller diff when inserting
new entries.
More importantly, it's the more natural way to structure such a list.
~Andrew
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [XEN PATCH v2 1/2] coverage: simplify the logic of choosing the number of gcov counters depending on the gcc version
2023-09-11 9:48 ` Andrew Cooper
@ 2023-09-11 9:53 ` Jan Beulich
2023-09-11 9:59 ` Andrew Cooper
0 siblings, 1 reply; 11+ messages in thread
From: Jan Beulich @ 2023-09-11 9:53 UTC (permalink / raw)
To: Andrew Cooper
Cc: George Dunlap, Julien Grall, Stefano Stabellini, Wei Liu,
xen-devel, Javi Merino
On 11.09.2023 11:48, Andrew Cooper wrote:
> On 11/09/2023 8:54 am, Jan Beulich wrote:
>> On 08.09.2023 18:20, Javi Merino wrote:
>>> The current structure of choosing the correct file based on the
>>> compiler version makes us make 33 line files just to define a
>>> constant. The changes after gcc 4.7 are minimal, just the number of
>>> counters.
>>>
>>> Fold the changes in gcc_4_9.c, gcc_5.c and gcc_7.c into gcc_4_7.c to
>>> remove a lot of the boilerplate and keep the logic of choosing the
>>> GCOV_COUNTER in gcc_4_7.c.
>>>
>>> Signed-off-by: Javi Merino <javi.merino@cloud.com>
>>> ---
>>> xen/common/coverage/Makefile | 6 +-----
>>> xen/common/coverage/gcc_4_7.c | 17 +++++++++--------
>>> xen/common/coverage/gcc_4_9.c | 33 ---------------------------------
>>> xen/common/coverage/gcc_5.c | 33 ---------------------------------
>>> xen/common/coverage/gcc_7.c | 30 ------------------------------
>>> 5 files changed, 10 insertions(+), 109 deletions(-)
>>> delete mode 100644 xen/common/coverage/gcc_4_9.c
>>> delete mode 100644 xen/common/coverage/gcc_5.c
>>> delete mode 100644 xen/common/coverage/gcc_7.c
>>>
>>> diff --git a/xen/common/coverage/Makefile b/xen/common/coverage/Makefile
>>> index 63f98c71d6..d729afc9c7 100644
>>> --- a/xen/common/coverage/Makefile
>>> +++ b/xen/common/coverage/Makefile
>>> @@ -1,11 +1,7 @@
>>> obj-y += coverage.o
>>> ifneq ($(CONFIG_CC_IS_CLANG),y)
>>> obj-y += gcov_base.o gcov.o
>>> -obj-y += $(call cc-ifversion,-lt,0407, \
>>> - gcc_3_4.o, $(call cc-ifversion,-lt,0409, \
>>> - gcc_4_7.o, $(call cc-ifversion,-lt,0500, \
>>> - gcc_4_9.o, $(call cc-ifversion,-lt,0700, \
>>> - gcc_5.o, gcc_7.o))))
>>> +obj-y += $(call cc-ifversion,-lt,0407, gcc_3_4.o, gcc_4_7.o)
>>> else
>>> obj-y += llvm.o
>>> endif
>>> diff --git a/xen/common/coverage/gcc_4_7.c b/xen/common/coverage/gcc_4_7.c
>>> index 25b4a8bcdc..ddbc9f4bb0 100644
>>> --- a/xen/common/coverage/gcc_4_7.c
>>> +++ b/xen/common/coverage/gcc_4_7.c
>>> @@ -18,15 +18,16 @@
>>>
>>> #include "gcov.h"
>>>
>>> -/*
>>> - * GCOV_COUNTERS will be defined if this file is included by other
>>> - * source files.
>>> - */
>>> -#ifndef GCOV_COUNTERS
>>> -# if !(GCC_VERSION >= 40700 && GCC_VERSION < 40900)
>>> -# error "Wrong version of GCC used to compile gcov"
>>> -# endif
>>> +#if (GCC_VERSION >= 40700 && GCC_VERSION < 40900)
>>> #define GCOV_COUNTERS 8
>>> +#elif (GCC_VERSION >= 40900 && GCC_VERSION < 50000)
>>> +#define GCOV_COUNTERS 9
>>> +#elif GCC_VERSION >= 50000 && GCC_VERSION < 70000
>>> +#define GCOV_COUNTERS 10
>>> +#elif GCC_VERSION >= 70000
>>> +#define GCOV_COUNTERS 9
>>> +#else
>>> +#error "Wrong version of GCC used to compile gcov"
>>> #endif
>> How about inverse order:
>>
>> #if GCC_VERSION >= 70000
>> #define GCOV_COUNTERS 9
>> #elif GCC_VERSION >= 50000
>> #define GCOV_COUNTERS 10
>> #elif GCC_VERSION >= 40900
>> #define GCOV_COUNTERS 9
>> #elif GCC_VERSION >= 40700
>> #define GCOV_COUNTERS 8
>> #else
>> #error "Wrong version of GCC used to compile gcov"
>> #endif
>
> Forward order is the one that results in a smaller diff when inserting
> new entries.
Hmm, even in forward order one prior #elif will need touching (to amend
the version check), so I'm afraid I don't see such a diff being smaller
(it's uniformly -1/+3 afaict).
> More importantly, it's the more natural way to structure such a list.
I would say multiple views are possible: Naming recent compiler versions
first may also be viewed as beneficial. In the end what counts is how
easy it is to follow the overall construct. And I'm pretty sure less
complex expressions help there.
Jan
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [XEN PATCH v2 1/2] coverage: simplify the logic of choosing the number of gcov counters depending on the gcc version
2023-09-11 9:53 ` Jan Beulich
@ 2023-09-11 9:59 ` Andrew Cooper
2023-09-11 10:33 ` Jan Beulich
0 siblings, 1 reply; 11+ messages in thread
From: Andrew Cooper @ 2023-09-11 9:59 UTC (permalink / raw)
To: Jan Beulich
Cc: George Dunlap, Julien Grall, Stefano Stabellini, Wei Liu,
xen-devel, Javi Merino
On 11/09/2023 10:53 am, Jan Beulich wrote:
> On 11.09.2023 11:48, Andrew Cooper wrote:
>> On 11/09/2023 8:54 am, Jan Beulich wrote:
>>> On 08.09.2023 18:20, Javi Merino wrote:
>>>> The current structure of choosing the correct file based on the
>>>> compiler version makes us make 33 line files just to define a
>>>> constant. The changes after gcc 4.7 are minimal, just the number of
>>>> counters.
>>>>
>>>> Fold the changes in gcc_4_9.c, gcc_5.c and gcc_7.c into gcc_4_7.c to
>>>> remove a lot of the boilerplate and keep the logic of choosing the
>>>> GCOV_COUNTER in gcc_4_7.c.
>>>>
>>>> Signed-off-by: Javi Merino <javi.merino@cloud.com>
>>>> ---
>>>> xen/common/coverage/Makefile | 6 +-----
>>>> xen/common/coverage/gcc_4_7.c | 17 +++++++++--------
>>>> xen/common/coverage/gcc_4_9.c | 33 ---------------------------------
>>>> xen/common/coverage/gcc_5.c | 33 ---------------------------------
>>>> xen/common/coverage/gcc_7.c | 30 ------------------------------
>>>> 5 files changed, 10 insertions(+), 109 deletions(-)
>>>> delete mode 100644 xen/common/coverage/gcc_4_9.c
>>>> delete mode 100644 xen/common/coverage/gcc_5.c
>>>> delete mode 100644 xen/common/coverage/gcc_7.c
>>>>
>>>> diff --git a/xen/common/coverage/Makefile b/xen/common/coverage/Makefile
>>>> index 63f98c71d6..d729afc9c7 100644
>>>> --- a/xen/common/coverage/Makefile
>>>> +++ b/xen/common/coverage/Makefile
>>>> @@ -1,11 +1,7 @@
>>>> obj-y += coverage.o
>>>> ifneq ($(CONFIG_CC_IS_CLANG),y)
>>>> obj-y += gcov_base.o gcov.o
>>>> -obj-y += $(call cc-ifversion,-lt,0407, \
>>>> - gcc_3_4.o, $(call cc-ifversion,-lt,0409, \
>>>> - gcc_4_7.o, $(call cc-ifversion,-lt,0500, \
>>>> - gcc_4_9.o, $(call cc-ifversion,-lt,0700, \
>>>> - gcc_5.o, gcc_7.o))))
>>>> +obj-y += $(call cc-ifversion,-lt,0407, gcc_3_4.o, gcc_4_7.o)
>>>> else
>>>> obj-y += llvm.o
>>>> endif
>>>> diff --git a/xen/common/coverage/gcc_4_7.c b/xen/common/coverage/gcc_4_7.c
>>>> index 25b4a8bcdc..ddbc9f4bb0 100644
>>>> --- a/xen/common/coverage/gcc_4_7.c
>>>> +++ b/xen/common/coverage/gcc_4_7.c
>>>> @@ -18,15 +18,16 @@
>>>>
>>>> #include "gcov.h"
>>>>
>>>> -/*
>>>> - * GCOV_COUNTERS will be defined if this file is included by other
>>>> - * source files.
>>>> - */
>>>> -#ifndef GCOV_COUNTERS
>>>> -# if !(GCC_VERSION >= 40700 && GCC_VERSION < 40900)
>>>> -# error "Wrong version of GCC used to compile gcov"
>>>> -# endif
>>>> +#if (GCC_VERSION >= 40700 && GCC_VERSION < 40900)
>>>> #define GCOV_COUNTERS 8
>>>> +#elif (GCC_VERSION >= 40900 && GCC_VERSION < 50000)
>>>> +#define GCOV_COUNTERS 9
>>>> +#elif GCC_VERSION >= 50000 && GCC_VERSION < 70000
>>>> +#define GCOV_COUNTERS 10
>>>> +#elif GCC_VERSION >= 70000
>>>> +#define GCOV_COUNTERS 9
>>>> +#else
>>>> +#error "Wrong version of GCC used to compile gcov"
>>>> #endif
>>> How about inverse order:
>>>
>>> #if GCC_VERSION >= 70000
>>> #define GCOV_COUNTERS 9
>>> #elif GCC_VERSION >= 50000
>>> #define GCOV_COUNTERS 10
>>> #elif GCC_VERSION >= 40900
>>> #define GCOV_COUNTERS 9
>>> #elif GCC_VERSION >= 40700
>>> #define GCOV_COUNTERS 8
>>> #else
>>> #error "Wrong version of GCC used to compile gcov"
>>> #endif
>> Forward order is the one that results in a smaller diff when inserting
>> new entries.
> Hmm, even in forward order one prior #elif will need touching
#if GCC_VERSION < 40700
#define GCOV_COUNTERS 8
#elif GCC_VERSION < 40900
#define GCOV_COUNTERS 9
#elif GCC_VERSION < 50000
#define GCOV_COUNTERS 10
#elif GCC_VERSION < 70000
#define GCOV_COUNTERS 9
+#elif GCC_VERSION < FOO
+#define GCOV_COUNTERS BAR
#else
#error "Wrong version of GCC used to compile gcov"
#endif
~Andrew
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [XEN PATCH v2 1/2] coverage: simplify the logic of choosing the number of gcov counters depending on the gcc version
2023-09-11 9:59 ` Andrew Cooper
@ 2023-09-11 10:33 ` Jan Beulich
0 siblings, 0 replies; 11+ messages in thread
From: Jan Beulich @ 2023-09-11 10:33 UTC (permalink / raw)
To: Andrew Cooper
Cc: George Dunlap, Julien Grall, Stefano Stabellini, Wei Liu,
xen-devel, Javi Merino
On 11.09.2023 11:59, Andrew Cooper wrote:
> On 11/09/2023 10:53 am, Jan Beulich wrote:
>> On 11.09.2023 11:48, Andrew Cooper wrote:
>>> On 11/09/2023 8:54 am, Jan Beulich wrote:
>>>> On 08.09.2023 18:20, Javi Merino wrote:
>>>>> The current structure of choosing the correct file based on the
>>>>> compiler version makes us make 33 line files just to define a
>>>>> constant. The changes after gcc 4.7 are minimal, just the number of
>>>>> counters.
>>>>>
>>>>> Fold the changes in gcc_4_9.c, gcc_5.c and gcc_7.c into gcc_4_7.c to
>>>>> remove a lot of the boilerplate and keep the logic of choosing the
>>>>> GCOV_COUNTER in gcc_4_7.c.
>>>>>
>>>>> Signed-off-by: Javi Merino <javi.merino@cloud.com>
>>>>> ---
>>>>> xen/common/coverage/Makefile | 6 +-----
>>>>> xen/common/coverage/gcc_4_7.c | 17 +++++++++--------
>>>>> xen/common/coverage/gcc_4_9.c | 33 ---------------------------------
>>>>> xen/common/coverage/gcc_5.c | 33 ---------------------------------
>>>>> xen/common/coverage/gcc_7.c | 30 ------------------------------
>>>>> 5 files changed, 10 insertions(+), 109 deletions(-)
>>>>> delete mode 100644 xen/common/coverage/gcc_4_9.c
>>>>> delete mode 100644 xen/common/coverage/gcc_5.c
>>>>> delete mode 100644 xen/common/coverage/gcc_7.c
>>>>>
>>>>> diff --git a/xen/common/coverage/Makefile b/xen/common/coverage/Makefile
>>>>> index 63f98c71d6..d729afc9c7 100644
>>>>> --- a/xen/common/coverage/Makefile
>>>>> +++ b/xen/common/coverage/Makefile
>>>>> @@ -1,11 +1,7 @@
>>>>> obj-y += coverage.o
>>>>> ifneq ($(CONFIG_CC_IS_CLANG),y)
>>>>> obj-y += gcov_base.o gcov.o
>>>>> -obj-y += $(call cc-ifversion,-lt,0407, \
>>>>> - gcc_3_4.o, $(call cc-ifversion,-lt,0409, \
>>>>> - gcc_4_7.o, $(call cc-ifversion,-lt,0500, \
>>>>> - gcc_4_9.o, $(call cc-ifversion,-lt,0700, \
>>>>> - gcc_5.o, gcc_7.o))))
>>>>> +obj-y += $(call cc-ifversion,-lt,0407, gcc_3_4.o, gcc_4_7.o)
>>>>> else
>>>>> obj-y += llvm.o
>>>>> endif
>>>>> diff --git a/xen/common/coverage/gcc_4_7.c b/xen/common/coverage/gcc_4_7.c
>>>>> index 25b4a8bcdc..ddbc9f4bb0 100644
>>>>> --- a/xen/common/coverage/gcc_4_7.c
>>>>> +++ b/xen/common/coverage/gcc_4_7.c
>>>>> @@ -18,15 +18,16 @@
>>>>>
>>>>> #include "gcov.h"
>>>>>
>>>>> -/*
>>>>> - * GCOV_COUNTERS will be defined if this file is included by other
>>>>> - * source files.
>>>>> - */
>>>>> -#ifndef GCOV_COUNTERS
>>>>> -# if !(GCC_VERSION >= 40700 && GCC_VERSION < 40900)
>>>>> -# error "Wrong version of GCC used to compile gcov"
>>>>> -# endif
>>>>> +#if (GCC_VERSION >= 40700 && GCC_VERSION < 40900)
>>>>> #define GCOV_COUNTERS 8
>>>>> +#elif (GCC_VERSION >= 40900 && GCC_VERSION < 50000)
>>>>> +#define GCOV_COUNTERS 9
>>>>> +#elif GCC_VERSION >= 50000 && GCC_VERSION < 70000
>>>>> +#define GCOV_COUNTERS 10
>>>>> +#elif GCC_VERSION >= 70000
>>>>> +#define GCOV_COUNTERS 9
>>>>> +#else
>>>>> +#error "Wrong version of GCC used to compile gcov"
>>>>> #endif
>>>> How about inverse order:
>>>>
>>>> #if GCC_VERSION >= 70000
>>>> #define GCOV_COUNTERS 9
>>>> #elif GCC_VERSION >= 50000
>>>> #define GCOV_COUNTERS 10
>>>> #elif GCC_VERSION >= 40900
>>>> #define GCOV_COUNTERS 9
>>>> #elif GCC_VERSION >= 40700
>>>> #define GCOV_COUNTERS 8
>>>> #else
>>>> #error "Wrong version of GCC used to compile gcov"
>>>> #endif
>>> Forward order is the one that results in a smaller diff when inserting
>>> new entries.
>> Hmm, even in forward order one prior #elif will need touching
>
> #if GCC_VERSION < 40700
> #define GCOV_COUNTERS 8
> #elif GCC_VERSION < 40900
> #define GCOV_COUNTERS 9
> #elif GCC_VERSION < 50000
> #define GCOV_COUNTERS 10
> #elif GCC_VERSION < 70000
> #define GCOV_COUNTERS 9
> +#elif GCC_VERSION < FOO
> +#define GCOV_COUNTERS BAR
> #else
> #error "Wrong version of GCC used to compile gcov"
> #endif
But that doesn't achieve the same as the other construct: No #error for
gcc earlier than 4.7, and your (presumed; i.e. taking just patch context
without the two added lines) construct would fail to build for gcc 7. We
want an open upper bound but a determined lower one.
Jan
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2023-09-11 10:33 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-09-08 16:20 [XEN PATCH v2 0/2] update gcov info for newer versions of gcc Javi Merino
2023-09-08 16:20 ` [XEN PATCH v2 1/2] coverage: simplify the logic of choosing the number of gcov counters depending on the gcc version Javi Merino
2023-09-11 7:54 ` Jan Beulich
2023-09-11 9:13 ` Javi Merino
2023-09-11 9:48 ` Andrew Cooper
2023-09-11 9:53 ` Jan Beulich
2023-09-11 9:59 ` Andrew Cooper
2023-09-11 10:33 ` Jan Beulich
2023-09-08 16:20 ` [XEN PATCH v2 2/2] coverage: update gcov info for newer versions of gcc Javi Merino
2023-09-11 8:00 ` Jan Beulich
2023-09-11 9:19 ` Javi Merino
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.