Skip to contentSkip to conversation

Xen: Update compiler checks

PATCH Superseded Andrew Cooper 3 participants 6 messages Mar 27, 2025

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 Xen: Update compiler checks

We have checks in both xen/compiler.h, and Config.mk. Both are incomplete. Remove the one from compiler.h, as it's pointless to perform in addition to the xen.git-wide one as well.

Expand the checks to cover RISCV wanting GCC 11.1, and to cover Clang on x86.

PPC still is unspecified, and inherits the GCC 5.1 global baseline.

---
CC: Anthony PERARD <[email protected]>
CC: Michal Orzel <[email protected]>
CC: Jan Beulich <[email protected]>
CC: Julien Grall <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Stefano Stabellini <[email protected]>
CC: Oleksii Kurochko <[email protected]>

v2:
* Change to altering Config.mk

https://gitlab.com/xen-project/people/andyhhp/xen/-/pipelines/1738628602 with the CI changes reverted, so as to expect failures for CentOS 7 and earlier Ubuntu Clangs.

The $(eval $(check-y)) is badly positioned:

xen.git/xen$ make
*** FATAL BUILD ERROR: Xen requires at least GCC 0x150100 *** FATAL BUILD ERROR: Xen requires at least GCC 0x150100 *** FATAL BUILD ERROR: Xen requires at least GCC 0x150100 *** FATAL BUILD ERROR: Xen requires at least GCC 0x150100 *** FATAL BUILD ERROR: Xen requires at least GCC 0x150100 *** FATAL BUILD ERROR: Xen requires at least GCC 0x150100 *** FATAL BUILD ERROR: Xen requires at least GCC 0x150100 *** FATAL BUILD ERROR: Xen requires at least GCC 0x150100 *** FATAL BUILD ERROR: Xen requires at least GCC 0x150100 *** FATAL BUILD ERROR: Xen requires at least GCC 0x150100 *** FATAL BUILD ERROR: Xen requires at least GCC 0x150100 *** FATAL BUILD ERROR: Xen requires at least GCC 0x150100 *** FATAL BUILD ERROR: Xen requires at least GCC 0x150100 *** FATAL BUILD ERROR: Xen requires at least GCC 0x150100 *** FATAL BUILD ERROR: Xen requires at least GCC 0x150100
HOSTCC tools/fixdep
*** FATAL BUILD ERROR: Xen requires at least GCC 0x150100 make[1]: *** [scripts/Makefile.host:108: tools/fixdep] Error 1
HOSTCC tools/symbols
*** FATAL BUILD ERROR: Xen requires at least GCC 0x150100 make[1]: *** [scripts/Makefile.host:108: tools/symbols] Error 1
make: *** [Makefile:610: xen] Error 2

It is involved every time Config.mk is included, rather than once per make invocation.

---
 Config.mk                  | 14 ++++++++++++--
 xen/include/xen/compiler.h | 14 --------------
 2 files changed, 12 insertions(+), 16 deletions(-)
Config.mk +12 -2
index 8a73f3da62b4..a9d62fc10cfa 100644
@@ -125,8 +125,18 @@ define cc-ver-check-closure
     endif
 endef
 
-# Require GCC v4.1+
-check-$(gcc) = $(call cc-ver-check,CC,0x040100,"Xen requires at least gcc-4.1")
+# Minimum GCC version: 5.1, except for RISCV which needs 11.1
+ifeq ($(XEN_TARGET_ARCH),riscv64)
+check-$(gcc) = $(call cc-ver-check,CC,0x110100,"Xen requires at least GCC 11.1")
+else
+check-$(gcc) = $(call cc-ver-check,CC,0x050100,"Xen requires at least GCC 5.1")
+endif
+
+# Minimum Clang version: 11, x86 only
+ifeq ($(XEN_TARGET_ARCH),x86_64)
+check-$(clang) = $(call cc-ver-check,CC,0x110000,"Xen requires at least Clang 11")
+endif
+
 $(eval $(check-y))
 
 ld-ver-build-id = $(shell $(1) --build-id 2>&1 | \
xen/include/xen/compiler.h +0 -14
index 636a85bc417d..43b666133a92 100644
@@ -1,20 +1,6 @@
 #ifndef __LINUX_COMPILER_H
 #define __LINUX_COMPILER_H
 
-#if !defined(__GNUC__) || (__GNUC__ < 4)
-#error Sorry, your compiler is too old/not recognized.
-#elif CONFIG_CC_IS_GCC
-# if defined(CONFIG_ARM_32) && CONFIG_GCC_VERSION < 40900
-#  error Sorry, your version of GCC is too old - please use 4.9 or newer.
-# elif defined(CONFIG_ARM_64) && CONFIG_GCC_VERSION < 50100
-/*
- * https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63293
- * https://lore.kernel.org/r/[email protected]
- */
-#  error Sorry, your version of GCC is too old - please use 5.1 or newer.
-# endif
-#endif
-
 #ifdef CONFIG_CC_HAS_VISIBILITY_ATTRIBUTE
 /* Results in more efficient PIC code (no indirections through GOT or PLT). */
 #pragma GCC visibility push(hidden)
Signature · 1 line
2.39.5
#1 lore raw
Quoted 5 lines · Andrew Cooper

We have checks in both xen/compiler.h, and Config.mk. Both are incomplete. Remove the one from compiler.h, as it's pointless to perform in addition to the xen.git-wide one as well.

Expand the checks to cover RISCV wanting GCC 11.1, and to cover Clang on x86.

Why GCC 11.1 for RISC-V? We declared in ./README that 12.2.

~ Oleksii

Quoted 103 lines

PPC still is unspecified, and inherits the GCC 5.1 global baseline.

---
CC: Anthony PERARD<[email protected]>
CC: Michal Orzel<[email protected]>
CC: Jan Beulich<[email protected]>
CC: Julien Grall<[email protected]>
CC: Roger Pau Monné<[email protected]>
CC: Stefano Stabellini<[email protected]>
CC: Oleksii Kurochko<[email protected]>

v2:
* Change to altering Config.mk

https://gitlab.com/xen-project/people/andyhhp/xen/-/pipelines/1738628602 with the CI changes reverted, so as to expect failures for CentOS 7 and earlier Ubuntu Clangs.

The $(eval $(check-y)) is badly positioned:

xen.git/xen$ make
*** FATAL BUILD ERROR: Xen requires at least GCC 0x150100 *** FATAL BUILD ERROR: Xen requires at least GCC 0x150100 *** FATAL BUILD ERROR: Xen requires at least GCC 0x150100 *** FATAL BUILD ERROR: Xen requires at least GCC 0x150100 *** FATAL BUILD ERROR: Xen requires at least GCC 0x150100 *** FATAL BUILD ERROR: Xen requires at least GCC 0x150100 *** FATAL BUILD ERROR: Xen requires at least GCC 0x150100 *** FATAL BUILD ERROR: Xen requires at least GCC 0x150100 *** FATAL BUILD ERROR: Xen requires at least GCC 0x150100 *** FATAL BUILD ERROR: Xen requires at least GCC 0x150100 *** FATAL BUILD ERROR: Xen requires at least GCC 0x150100 *** FATAL BUILD ERROR: Xen requires at least GCC 0x150100 *** FATAL BUILD ERROR: Xen requires at least GCC 0x150100 *** FATAL BUILD ERROR: Xen requires at least GCC 0x150100 *** FATAL BUILD ERROR: Xen requires at least GCC 0x150100
HOSTCC tools/fixdep
*** FATAL BUILD ERROR: Xen requires at least GCC 0x150100 make[1]: *** [scripts/Makefile.host:108: tools/fixdep] Error 1
HOSTCC tools/symbols
*** FATAL BUILD ERROR: Xen requires at least GCC 0x150100 make[1]: *** [scripts/Makefile.host:108: tools/symbols] Error 1
make: *** [Makefile:610: xen] Error 2

It is involved every time Config.mk is included, rather than once per make invocation.

---
  Config.mk                  | 14 ++++++++++++--
  xen/include/xen/compiler.h | 14 --------------
  2 files changed, 12 insertions(+), 16 deletions(-)
Config.mk +12 -2
index 8a73f3da62b4..a9d62fc10cfa 100644
@@ -125,8 +125,18 @@ define cc-ver-check-closure
      endif
  endef
 
-# Require GCC v4.1+
-check-$(gcc) = $(call cc-ver-check,CC,0x040100,"Xen requires at least gcc-4.1")
+# Minimum GCC version: 5.1, except for RISCV which needs 11.1
+ifeq ($(XEN_TARGET_ARCH),riscv64)
+check-$(gcc) = $(call cc-ver-check,CC,0x110100,"Xen requires at least GCC 11.1")
+else
+check-$(gcc) = $(call cc-ver-check,CC,0x050100,"Xen requires at least GCC 5.1")
+endif
+
+# Minimum Clang version: 11, x86 only
+ifeq ($(XEN_TARGET_ARCH),x86_64)
+check-$(clang) = $(call cc-ver-check,CC,0x110000,"Xen requires at least Clang 11")
+endif
+
  $(eval $(check-y))
 
  ld-ver-build-id = $(shell $(1) --build-id 2>&1 | \
xen/include/xen/compiler.h +0 -14
index 636a85bc417d..43b666133a92 100644
@@ -1,20 +1,6 @@
  #ifndef __LINUX_COMPILER_H
  #define __LINUX_COMPILER_H
 
-#if !defined(__GNUC__) || (__GNUC__ < 4)
-#error Sorry, your compiler is too old/not recognized.
-#elif CONFIG_CC_IS_GCC
-# if defined(CONFIG_ARM_32) && CONFIG_GCC_VERSION < 40900
-#  error Sorry, your version of GCC is too old - please use 4.9 or newer.
-# elif defined(CONFIG_ARM_64) && CONFIG_GCC_VERSION < 50100
-/*
- *https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63293
- *https://lore.kernel.org/r/[email protected]
- */
-#  error Sorry, your version of GCC is too old - please use 5.1 or newer.
-# endif
-#endif
-
  #ifdef CONFIG_CC_HAS_VISIBILITY_ATTRIBUTE
  /* Results in more efficient PIC code (no indirections through GOT or PLT). */
  #pragma GCC visibility push(hidden)
#2 lore raw
Quoted 9 lines · Oleksii Kurochko
Quoted 5 lines · Andrew Cooper

We have checks in both xen/compiler.h, and Config.mk. Both are incomplete. Remove the one from compiler.h, as it's pointless to perform in addition to the xen.git-wide one as well.

Expand the checks to cover RISCV wanting GCC 11.1, and to cover Clang on x86.

Why GCC 11.1 for RISC-V? We declared in ./README that 12.2.

Sorry, that's me not paying enough attention.  I'll fix.

~Andrew

#3 lore raw
In reply to Andrew Cooper
Quoted 13 lines · Andrew Cooper
Config.mk +3 -2
index 8a73f3da62b4..a9d62fc10cfa 100644
@@ -125,8 +125,18 @@ define cc-ver-check-closure
     endif
 endef
 
-# Require GCC v4.1+
-check-$(gcc) = $(call cc-ver-check,CC,0x040100,"Xen requires at least gcc-4.1")
+# Minimum GCC version: 5.1, except for RISCV which needs 11.1
+ifeq ($(XEN_TARGET_ARCH),riscv64)
+check-$(gcc) = $(call cc-ver-check,CC,0x110100,"Xen requires at least GCC 11.1")

Config.mk define cc-ver-check-closure · line 140

Quoted 10 lines
Config.mk +9 -0
+else
+check-$(gcc) = $(call cc-ver-check,CC,0x050100,"Xen requires at least GCC 5.1")
+endif
+
+# Minimum Clang version: 11, x86 only
+ifeq ($(XEN_TARGET_ARCH),x86_64)
+check-$(clang) = $(call cc-ver-check,CC,0x110000,"Xen requires at least Clang 11")
+endif
+
 $(eval $(check-y))

No, this doesn't work.  Tracing a RISC-V cross-compile, it's invoked with different $(CC)'s.

+ gcc -dumpversion
+ awk -F. { printf "0x%02x%02x%02x", $1, $2, $3}
+ [ 786432 -ge 327936 ]
+ echo y
+ riscv64-linux-gnu-gcc -dumpversion
+ awk -F. { printf "0x%02x%02x%02x", $1, $2, $3}
+ [ 786432 -ge 1114368 ]
+ echo n

~Andrew

#4 lore raw
In reply to Andrew Cooper
Quoted 3 lines · Andrew Cooper

We have checks in both xen/compiler.h, and Config.mk. Both are incomplete. Remove the one from compiler.h, as it's pointless to perform in addition to the xen.git-wide one as well.

Isn't this premature? The Config.mk one doesn't terminate the build, according to what there is in the post-commit-message area?

Quoted 1 line

Expand the checks to cover RISCV wanting GCC 11.1, and to cover Clang on x86.

./README says 12.2 though.

Quoted 45 lines

PPC still is unspecified, and inherits the GCC 5.1 global baseline.

---
CC: Anthony PERARD <[email protected]>
CC: Michal Orzel <[email protected]>
CC: Jan Beulich <[email protected]>
CC: Julien Grall <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Stefano Stabellini <[email protected]>
CC: Oleksii Kurochko <[email protected]>

v2:
* Change to altering Config.mk

https://gitlab.com/xen-project/people/andyhhp/xen/-/pipelines/1738628602 with the CI changes reverted, so as to expect failures for CentOS 7 and earlier Ubuntu Clangs.

The $(eval $(check-y)) is badly positioned:

xen.git/xen$ make
*** FATAL BUILD ERROR: Xen requires at least GCC 0x150100 *** FATAL BUILD ERROR: Xen requires at least GCC 0x150100 *** FATAL BUILD ERROR: Xen requires at least GCC 0x150100 *** FATAL BUILD ERROR: Xen requires at least GCC 0x150100 *** FATAL BUILD ERROR: Xen requires at least GCC 0x150100 *** FATAL BUILD ERROR: Xen requires at least GCC 0x150100 *** FATAL BUILD ERROR: Xen requires at least GCC 0x150100 *** FATAL BUILD ERROR: Xen requires at least GCC 0x150100 *** FATAL BUILD ERROR: Xen requires at least GCC 0x150100 *** FATAL BUILD ERROR: Xen requires at least GCC 0x150100 *** FATAL BUILD ERROR: Xen requires at least GCC 0x150100 *** FATAL BUILD ERROR: Xen requires at least GCC 0x150100 *** FATAL BUILD ERROR: Xen requires at least GCC 0x150100 *** FATAL BUILD ERROR: Xen requires at least GCC 0x150100 *** FATAL BUILD ERROR: Xen requires at least GCC 0x150100
HOSTCC tools/fixdep
*** FATAL BUILD ERROR: Xen requires at least GCC 0x150100 make[1]: *** [scripts/Makefile.host:108: tools/fixdep] Error 1
HOSTCC tools/symbols
*** FATAL BUILD ERROR: Xen requires at least GCC 0x150100 make[1]: *** [scripts/Makefile.host:108: tools/symbols] Error 1
make: *** [Makefile:610: xen] Error 2

Quoted 2 lines

It is involved every time Config.mk is included, rather than once per make invocation.

Right, I guess the $(eval ...) wants to move to every */Makefile in the top-level subdirs. But as you said elsewhere, that's an orthogonal issue.

Jan

#5 lore raw
Quoted 6 lines · Jan Beulich
Quoted 3 lines · Andrew Cooper

We have checks in both xen/compiler.h, and Config.mk. Both are incomplete. Remove the one from compiler.h, as it's pointless to perform in addition to the xen.git-wide one as well.

Isn't this premature? The Config.mk one doesn't terminate the build, according to what there is in the post-commit-message area?

It's also broken for cross-compiles, in a way that I don't have time to fix now.

I'm going to leave this as a 5.1 baseline across the board, and reintroduce the xen/compile.h one with the per-arch nuances.

~Andrew