1
0
forked from pool/virtualbox

Fix building with GCC 15 [boo#1242085] #6

Merged
jengelh merged 1 commits from :master into master 2025-05-27 18:15:23 +02:00
Contributor

Add gentoo-C23.patch, taken from the corresponding gentoo package, to fix building with GCC 15 where the C language defaults to standard C23. [boo#1242085]

Add gentoo-C23.patch, taken from the corresponding gentoo package, to fix building with GCC 15 where the C language defaults to standard C23. [boo#1242085]
jamborm added 1 commit 2025-05-27 17:26:23 +02:00
jengelh merged commit 55b005b5e1 into master 2025-05-27 18:15:23 +02:00
Contributor

This breaks the build:

[   22s] ./include/iprt/types.h:284:13: fatal error: stdbool.h: No such file or directory
[   22s]   284 | #   include <stdbool.h>
[   22s]       |             ^~~~~~~~~~~

Note it is a KMP, so -nostdinc. How comes this works with gcc 15?

https://build.opensuse.org/package/live_build_log/Virtualization/virtualbox:kmp/openSUSE_Tumbleweed/x86_64

This breaks the build: ``` [ 22s] ./include/iprt/types.h:284:13: fatal error: stdbool.h: No such file or directory [ 22s] 284 | # include <stdbool.h> [ 22s] | ^~~~~~~~~~~ ``` Note it is a KMP, so `-nostdinc`. How comes this works with gcc 15? https://build.opensuse.org/package/live_build_log/Virtualization/virtualbox:kmp/openSUSE_Tumbleweed/x86_64
Author
Contributor

I admit I only tested the change locally (I don't know how to do this kind of remote build in the new git workflow) with:
oosc build --clean --no-service --alternative-project home:jamborm:gcc15fixes --no-verify

I did not know about the kmp flavor and so did not test that. It does fail with GCC 15 too.

I admit I only tested the change locally (I don't know how to do this kind of remote build in the new git workflow) with: `oosc build --clean --no-service --alternative-project home:jamborm:gcc15fixes --no-verify` I did not know about the kmp flavor and so did not test that. It does fail with GCC 15 too.
Author
Contributor

I am testing replacing the patch with:

--- include/iprt/types.h.orig   2025-05-28 09:43:50.881454540 +0000
+++ include/iprt/types.h        2025-05-28 13:38:47.385394708 +0000
@@ -282,7 +282,9 @@
 #   endif
 #  else
 #   undef bool /* see above netbsd explanation */
+#   if ( __STDC_VERSION__ < 202311 )
 typedef _Bool bool;
+#   endif
 #  endif
 # else
 #  if RT_MSC_PREREQ(RT_MSC_VER_VC120)
I am testing replacing the patch with: ``` --- include/iprt/types.h.orig 2025-05-28 09:43:50.881454540 +0000 +++ include/iprt/types.h 2025-05-28 13:38:47.385394708 +0000 @@ -282,7 +282,9 @@ # endif # else # undef bool /* see above netbsd explanation */ +# if ( __STDC_VERSION__ < 202311 ) typedef _Bool bool; +# endif # endif # else # if RT_MSC_PREREQ(RT_MSC_VER_VC120) ```
Owner

Is there something that would prevent from just unconditionally using <stdbool.h> at all times and killing off this hand-crafted typedef _Bool bool?

Is there something that would prevent from just unconditionally using <stdbool.h> at all times and killing off this hand-crafted `typedef _Bool bool`?
Author
Contributor

Well, that is what my patch tried to do, but when compiling with -nostdinc that is not an option.

Well, that is what my patch tried to do, but when compiling with `-nostdinc` that is not an option.
Owner

Yeah you're right. But we can cheat and test for that, too :-D

$ diff -dpru <(echo -en "" | gcc -dM -E -x c /dev/null | sort) <(echo -en "" | gcc -dM -E -x c -nostdinc /dev/null | sort)
--- /dev/fd/63  2025-05-28 21:59:02.474279367 +0200
+++ /dev/fd/62  2025-05-28 21:59:02.474279367 +0200
@@ -1,5 +1,4 @@
 #define _LP64 1
-#define _STDC_PREDEF_H 1
 #define __ATOMIC_ACQUIRE 2
 #define __ATOMIC_ACQ_REL 4
 #define __ATOMIC_CONSUME 1
@@ -328,11 +327,6 @@
 #define __SSE_MATH__ 1
 #define __SSE__ 1
 #define __STDC_HOSTED__ 1
-#define __STDC_IEC_559_COMPLEX__ 1
-#define __STDC_IEC_559__ 1
-#define __STDC_IEC_60559_BFP__ 201404L
-#define __STDC_IEC_60559_COMPLEX__ 201404L
-#define __STDC_ISO_10646__ 201706L
 #define __STDC_UTF_16__ 1
 #define __STDC_UTF_32__ 1
 #define __STDC_VERSION__ 201710L
``
Yeah you're right. But we can cheat and test for that, too :-D ``` $ diff -dpru <(echo -en "" | gcc -dM -E -x c /dev/null | sort) <(echo -en "" | gcc -dM -E -x c -nostdinc /dev/null | sort) --- /dev/fd/63 2025-05-28 21:59:02.474279367 +0200 +++ /dev/fd/62 2025-05-28 21:59:02.474279367 +0200 @@ -1,5 +1,4 @@ #define _LP64 1 -#define _STDC_PREDEF_H 1 #define __ATOMIC_ACQUIRE 2 #define __ATOMIC_ACQ_REL 4 #define __ATOMIC_CONSUME 1 @@ -328,11 +327,6 @@ #define __SSE_MATH__ 1 #define __SSE__ 1 #define __STDC_HOSTED__ 1 -#define __STDC_IEC_559_COMPLEX__ 1 -#define __STDC_IEC_559__ 1 -#define __STDC_IEC_60559_BFP__ 201404L -#define __STDC_IEC_60559_COMPLEX__ 201404L -#define __STDC_ISO_10646__ 201706L #define __STDC_UTF_16__ 1 #define __STDC_UTF_32__ 1 #define __STDC_VERSION__ 201710L ``
Author
Contributor

True, but in the case of gcc-14 and -nostdinc we need to keep the old typedef, I cannot see a way around that, so the result would have one more #if - one branch for a C23 compiler, one for a pre-C23 one with stdbool.h and one for a pre-C23 one without standard headers.

But if that is what you prefer, you are the maintainer, I'll comply.

True, but in the case of gcc-14 and `-nostdinc` we need to keep the old typedef, I cannot see a way around that, so the result would have one more `#if` - one branch for a C23 compiler, one for a pre-C23 one with stdbool.h and one for a pre-C23 one without standard headers. But if that is what you prefer, you are the maintainer, I'll comply.
Contributor

Maybe we can #include <linux/types.h> if __KERNEL__? (Kernel uses old std and the typedef for both gcc 14 and 15, I guess.)

Maybe we can `#include <linux/types.h>` if `__KERNEL__`? (Kernel uses old std and the `typedef` for both gcc 14 and 15, I guess.)
Author
Contributor

Just including #include <linux/types.h> does not work. Even with it I'm getting tons of error: unknown type name 'bool' failures (using gcc-14).

Doing the following works with gcc-15, because indeed the kernel compilations have -std=gnu11 on the command line:

--- ./include/iprt/types.h~     2025-05-30 13:53:47.278255052 +0000
+++ ./include/iprt/types.h      2025-05-30 14:01:03.062884861 +0000
@@ -281,7 +281,11 @@
      typedef _Bool bool;
 #   endif
 #  else
-#   include <stdbool.h>
+#   if defined (__KERNEL__)
+      typedef _Bool bool;
+#   else
+#     include <stdbool.h>
+#   endif
 #  endif
 # else
 #  if RT_MSC_PREREQ(RT_MSC_VER_VC120)

But I don't see the point of including <linux/types.h> in this case. (I also have not verified non-kmp flavors and gcc-14 builds work but they should.)

@jengelh, do you prefer the above over what I proposed two days ago?

Just including `#include <linux/types.h>` does not work. Even with it I'm getting tons of `error: unknown type name 'bool'` failures (using gcc-14). Doing the following works with gcc-15, because indeed the kernel compilations have `-std=gnu11` on the command line: ``` --- ./include/iprt/types.h~ 2025-05-30 13:53:47.278255052 +0000 +++ ./include/iprt/types.h 2025-05-30 14:01:03.062884861 +0000 @@ -281,7 +281,11 @@ typedef _Bool bool; # endif # else -# include <stdbool.h> +# if defined (__KERNEL__) + typedef _Bool bool; +# else +# include <stdbool.h> +# endif # endif # else # if RT_MSC_PREREQ(RT_MSC_VER_VC120) ``` But I don't see the point of including ` <linux/types.h>` in this case. (I also have not verified non-kmp flavors and gcc-14 builds work but they should.) @jengelh, do you prefer the above over what I proposed two days ago?
Owner

No preference.

I was just throwing around suggestions. (Another might be to look at virtualbox-7.2.0-beta1 what it does.)

No preference. I was just throwing around suggestions. (Another might be to look at virtualbox-7.2.0-beta1 what it does.)
Author
Contributor

I have created #7 - even though I am not very good at testing all works in the new git workflow (yet), I have locally built this variant using both gcc14 and gcc15 and in both cases both the kmp flavor and the main package.

Sorry for the breakage and thanks for your patience.

I have created https://src.opensuse.org/jengelh/virtualbox/pulls/7 - even though I am not very good at testing all works in the new git workflow (yet), I have locally built this variant using both gcc14 and gcc15 and in both cases both the kmp flavor and the main package. Sorry for the breakage and thanks for your patience.
Sign in to join this conversation.
No Reviewers
No Label
3 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: jengelh/virtualbox#6