tools: specify C standard explicitly
PATCH v2 1/1 tools: specify C standard explicitly
Archlinux just updated gcc to 15.2.1+r604+g0b99615a8aef-1, and that defaults now to GNU23 standard. This isn't what Xen codebase expects, for example libxl fails to build with:
libxl_cpuid.c: In function ‘libxl_cpuid_parse_config_xend’:
libxl_cpuid.c:447:16: error: assignment discards ‘const’ qualifier from pointer target type [-Werror=discarded-qualifiers]
447 | endptr = strchr(str, '=');
| ^
libxl_cpuid.c:452:16: error: assignment discards ‘const’ qualifier from pointer target type [-Werror=discarded-qualifiers]
452 | endptr = strchr(str, ',');
| ^
libxl_cpuid.c:454:20: error: assignment discards ‘const’ qualifier from pointer target type [-Werror=discarded-qualifiers]
454 | endptr = strchr(str, 0);
| ^
libxl_cpuid.c: In function ‘libxl_cpuid_parse_config_xend’:
libxl_cpuid.c:447:16: error: assignment discards ‘const’ qualifier from pointer target type [-Werror=discarded-qualifiers]
447 | endptr = strchr(str, '=');
| ^
libxl_cpuid.c:452:16: error: assignment discards ‘const’ qualifier from pointer target type [-Werror=discarded-qualifiers]
452 | endptr = strchr(str, ',');
| ^
libxl_cpuid.c:454:20: error: assignment discards ‘const’ qualifier from pointer target type [-Werror=discarded-qualifiers]
454 | endptr = strchr(str, 0);
| ^
cc1: all warnings being treated as errors
Specify GNU99 explicitly (same version as in the hypervisor, but the GNU dialect), to fix the build, and avoid such surprises in the future.
---
As discussed in v1, I'm changing the standard version for now. Note GCC 14 used to default to -std=gnu17, so that should work too, but keep it consistent with the hypervisor.
The v1 that adjusted libxl can be used anyway, but it's less backport-friendly.
Changes in v2:
- revert to old standard (specify it explicitly now), instead of adjusting the code to the new standard - this way is more backport-friendly
--- tools/Rules.mk | 2 ++ 1 file changed, 2 insertions(+)
tools/Rules.mk +2 -0
@@ -38,6 +38,8 @@ ifeq ($(debug_symbols),y) CFLAGS += -g3 endif +CFLAGS += -std=gnu99 + ifneq ($(nosharedlibs),y) INSTALL_SHLIB = $(INSTALL_PROG) SYMLINK_SHLIB = ln -sf
Signature · 1 line
2.51.0
Quoted 26 lines · Marek Marczykowski-Górecki
Archlinux just updated gcc to 15.2.1+r604+g0b99615a8aef-1, and that defaults now to GNU23 standard. This isn't what Xen codebase expects, for example libxl fails to build with:
libxl_cpuid.c: In function ‘libxl_cpuid_parse_config_xend’:
libxl_cpuid.c:447:16: error: assignment discards ‘const’ qualifier from pointer target type [-Werror=discarded-qualifiers]
447 | endptr =strchr(str, '=');
| ^
libxl_cpuid.c:452:16: error: assignment discards ‘const’ qualifier from pointer target type [-Werror=discarded-qualifiers]
452 | endptr =strchr(str, ',');
| ^
libxl_cpuid.c:454:20: error: assignment discards ‘const’ qualifier from pointer target type [-Werror=discarded-qualifiers]
454 | endptr =strchr(str, 0);
| ^
libxl_cpuid.c: In function ‘libxl_cpuid_parse_config_xend’:
libxl_cpuid.c:447:16: error: assignment discards ‘const’ qualifier from pointer target type [-Werror=discarded-qualifiers]
447 | endptr =strchr(str, '=');
| ^
libxl_cpuid.c:452:16: error: assignment discards ‘const’ qualifier from pointer target type [-Werror=discarded-qualifiers]
452 | endptr =strchr(str, ',');
| ^
libxl_cpuid.c:454:20: error: assignment discards ‘const’ qualifier from pointer target type [-Werror=discarded-qualifiers]
454 | endptr =strchr(str, 0);
| ^
cc1: all warnings being treated as errors
Quoted 4 lines
Specify GNU99 explicitly (same version as in the hypervisor, but the GNU dialect), to fix the build, and avoid such surprises in the future.
Signed-off-by Marek Marczykowski-Górecki <[email protected]>
Hm, I should have tested it more precisely. This actually does not solve the issue, it still fails to build on Arch. I did confirmed the -std=gnu99 ended up in the relevant GCC call for libxl_cpuid.c.
So, I guess iterate on v1?
Quoted 31 lines
---
As discussed in v1, I'm changing the standard version for now. Note GCC 14 used to default to -std=gnu17, so that should work too, but keep it consistent with the hypervisor.
The v1 that adjusted libxl can be used anyway, but it's less backport-friendly.Changes in v2:
- revert to old standard (specify it explicitly now), instead of adjusting the code to the new standard - this way is more backport-friendly--- tools/Rules.mk | 2 ++ 1 file changed, 2 insertions(+)tools/Rules.mk +2
-0@@ -38,6 +38,8 @@ ifeq ($(debug_symbols),y) CFLAGS += -g3 endif +CFLAGS += -std=gnu99 + ifneq ($(nosharedlibs),y) INSTALL_SHLIB = $(INSTALL_PROG) SYMLINK_SHLIB = ln -sfSignature · 1 line
2.51.0
Signature · 3 lines
Best Regards, Marek Marczykowski-Górecki Invisible Things Lab
Quoted 27 lines · Marek Marczykowski-Górecki
Quoted 26 lines · Marek Marczykowski-Górecki
Archlinux just updated gcc to 15.2.1+r604+g0b99615a8aef-1, and that defaults now to GNU23 standard. This isn't what Xen codebase expects, for example libxl fails to build with:
libxl_cpuid.c: In function ‘libxl_cpuid_parse_config_xend’:
libxl_cpuid.c:447:16: error: assignment discards ‘const’ qualifier from pointer target type [-Werror=discarded-qualifiers]
447 | endptr =strchr(str, '=');
| ^
libxl_cpuid.c:452:16: error: assignment discards ‘const’ qualifier from pointer target type [-Werror=discarded-qualifiers]
452 | endptr =strchr(str, ',');
| ^
libxl_cpuid.c:454:20: error: assignment discards ‘const’ qualifier from pointer target type [-Werror=discarded-qualifiers]
454 | endptr =strchr(str, 0);
| ^
libxl_cpuid.c: In function ‘libxl_cpuid_parse_config_xend’:
libxl_cpuid.c:447:16: error: assignment discards ‘const’ qualifier from pointer target type [-Werror=discarded-qualifiers]
447 | endptr =strchr(str, '=');
| ^
libxl_cpuid.c:452:16: error: assignment discards ‘const’ qualifier from pointer target type [-Werror=discarded-qualifiers]
452 | endptr =strchr(str, ',');
| ^
libxl_cpuid.c:454:20: error: assignment discards ‘const’ qualifier from pointer target type [-Werror=discarded-qualifiers]
454 | endptr =strchr(str, 0);
| ^
cc1: all warnings being treated as errors
Quoted 8 lines
Quoted 4 lines
Specify GNU99 explicitly (same version as in the hypervisor, but the GNU dialect), to fix the build, and avoid such surprises in the future.
Signed-off-by Marek Marczykowski-Górecki <[email protected]>Hm, I should have tested it more precisely. This actually does not solve the issue, it still fails to build on Arch. I did confirmed the -std=gnu99 ended up in the relevant GCC call for
libxl_cpuid.c.
Is it possible that it's not so much the compiler, but glibc, which is the problem here?
Quoted 1 line
So, I guess iterate on v1?
Perhaps. As per above it first needs to become clear where the issue is actually coming from. Otoh making the code suitably C23-const-correct will want to happen at some point anyway, I suppose.
Jan
Quoted 2 lines · Jan Beulich
Is it possible that it's not so much the compiler, but glibc, which is the problem here?
Indeed, that's glibc. I tested it starting with CI container and updated packages one by one - it's about glic 2.42 -> 2.43.
Quoted 5 lines
Quoted 1 line
So, I guess iterate on v1?
Perhaps. As per above it first needs to become clear where the issue is actually coming from. Otoh making the code suitably C23-const-correct will want to happen at some point anyway, I suppose.
I'll sent v3 with remarks from your review on v1 applied.
Signature · 3 lines
Best Regards, Marek Marczykowski-Górecki Invisible Things Lab
Quoted 12 lines · Marek Marczykowski-Górecki
Quoted 2 lines · Jan Beulich
Is it possible that it's not so much the compiler, but glibc, which is the problem here?
Indeed, that's glibc. I tested it starting with CI container and updated packages one by one - it's about glic 2.42 -> 2.43.
Quoted 4 lines
Quoted 1 line
So, I guess iterate on v1?
Perhaps. As per above it first needs to become clear where the issue is actually coming from. Otoh making the code suitably C23-const-correct will want to happen at some point anyway, I suppose.
I'll sent v3 with remarks from your review on v1 applied.
Agreed, the moment we limit tools to a specific std, we will fail to find stuff like this.
In my copious free time, I keep on meaning to do one CI run with Xen forced the the newest std too, so we can pick up fixes as we go rather than finding them all in one go while trying to do something else in a hurry.
~Andrew