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.

Signed-off-by: Marek Marczykowski-Górecki <[email protected]>
---
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(+)

diff --git a/tools/Rules.mk b/tools/Rules.mk
index d9b9c740e964..de9100eb1681 100644
--- a/tools/Rules.mk
+++ b/tools/Rules.mk
@@ -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
-- 
2.51.0


Reply via email to