diff mbox series

[meta-oe,v2] vboxguestdrivers: Provide target kernel version

Message ID 20260804114425.120520-1-rouven.rastetter.ext@karlstorz.com
State New
Headers show
Series [meta-oe,v2] vboxguestdrivers: Provide target kernel version | expand

Commit Message

Rouven Rastetter Aug. 4, 2026, 11:44 a.m. UTC
The Makefile uses `KERN_MAJ = $(shell uname -r | cut -d . -f1)` to
determine if the kernel version is <7, which enables building vboxvideo.

Therefore, with a host kernel >=7 and a target kernel <7, vboxvideo is
not built and we get this error in vboxsf:

```
| In file included from ../vboxsf/include/iprt/stdarg.h:59,
|                  from ../vboxsf/include/iprt/types.h:44,
|                  from ../vboxsf/include/iprt/string.h:43,
|                  from mount.vboxsf.c:62:
| ../vboxsf/include/linux/stdarg.h:6:9: warning: 'va_start' redefined
|     6 | #define va_start(v, l)  __builtin_va_start(v, l)
|       |         ^~~~~~~~
| In file included from mount.vboxsf.c:44:
|
/work/oe-upstream/bitbake-builds/poky-master/build/tmp/work/qemux86_64-poky-linux/vboxguestdrivers/7.2.14/recipe-sysroot-native/usr/lib/x86_64-poky-linux/gcc/x86_64-poky-linux/16.1.0/include/stdarg.h:49:9:
note: this is the location of the previous definition
|    49 | #define va_start(...) __builtin_c23_va_start(__VA_ARGS__)
|       |         ^~~~~~~~
| ../vboxsf/include/linux/stdarg.h:8:9: warning: 'va_arg' redefined
|     8 | #define va_arg(v, T)    __builtin_va_arg(v, T)
|       |         ^~~~~~
|
/work/oe-upstream/bitbake-builds/poky-master/build/tmp/work/qemux86_64-poky-linux/vboxguestdrivers/7.2.14/recipe-sysroot-native/usr/lib/x86_64-poky-linux/gcc/x86_64-poky-linux/16.1.0/include/stdarg.h:54:9:
note: this is the location of the previous definition
|    54 | #define va_arg(v,l)     __builtin_va_arg(v,l)
|       |         ^~~~~~
| ../vboxsf/include/linux/stdarg.h:9:9: warning: 'va_copy' redefined
|     9 | #define va_copy(d, s)   __builtin_va_copy(d, s)
|       |         ^~~~~~~
|
/work/oe-upstream/bitbake-builds/poky-master/build/tmp/work/qemux86_64-poky-linux/vboxguestdrivers/7.2.14/recipe-sysroot-native/usr/lib/x86_64-poky-linux/gcc/x86_64-poky-linux/16.1.0/include/stdarg.h:57:9:
note: this is the location of the previous definition
|    57 | #define va_copy(d,s)    __builtin_va_copy(d,s)
|       |         ^~~~~~~
```

If the missmatch is reversed, there is probably a different error.

To fix this we provide the actual target kernel version via the KERN_MAJ
Makefile variable

Note: The kernel version might be empty during parsing (e.g. when using
linux-dummy), therefore `or ''` is needed.

CC: Khem Raj <raj.khem@gmail.com>
---
 .../recipes-support/vboxguestdrivers/vboxguestdrivers_7.2.14.bb | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/meta-oe/recipes-support/vboxguestdrivers/vboxguestdrivers_7.2.14.bb b/meta-oe/recipes-support/vboxguestdrivers/vboxguestdrivers_7.2.14.bb
index 18fda0393d..45f3f22481 100644
--- a/meta-oe/recipes-support/vboxguestdrivers/vboxguestdrivers_7.2.14.bb
+++ b/meta-oe/recipes-support/vboxguestdrivers/vboxguestdrivers_7.2.14.bb
@@ -32,7 +32,7 @@  S:task-patch = "${UNPACKDIR}/${BP}"
 export VBOX_KBUILD_TARGET_ARCH = "${ARCH}"
 export VBOX_KBUILD_TARGET_ARCH:x86-64 = "amd64"
 
-EXTRA_OEMAKE += "KERN_DIR='${WORKDIR}/${KERNEL_VERSION}/build' KBUILD_VERBOSE=1 CC='${CC} ${DEBUG_PREFIX_MAP} -ffile-prefix-map=${STAGING_KERNEL_DIR}=${KERNEL_SRC_PATH} -ffile-prefix-map=${STAGING_KERNEL_BUILDDIR}=${KERNEL_SRC_PATH}'"
+EXTRA_OEMAKE += "KERN_DIR='${WORKDIR}/${KERNEL_VERSION}/build' KERN_MAJ='${@(oe.kernel.get_version_file('${STAGING_KERNEL_BUILDDIR}') or '').split('.')[0]}' KBUILD_VERBOSE=1 CC='${CC} ${DEBUG_PREFIX_MAP} -ffile-prefix-map=${STAGING_KERNEL_DIR}=${KERNEL_SRC_PATH} -ffile-prefix-map=${STAGING_KERNEL_BUILDDIR}=${KERNEL_SRC_PATH}'"
 
 # otherwise 5.2.22 builds just vboxguest
 MAKE_TARGETS = "all"