diff mbox series

[meta-oe] vboxguestdrivers: fix build against 5.19 kernel / libc-headers

Message ID 20220804225032.2548994-1-bruce.ashfield@gmail.com
State New
Headers show
Series [meta-oe] vboxguestdrivers: fix build against 5.19 kernel / libc-headers | expand

Commit Message

Bruce Ashfield Aug. 4, 2022, 10:50 p.m. UTC
From: Bruce Ashfield <bruce.ashfield@gmail.com>

We've bounced back and forth with the mixed libc/kernel module structure of
these drivers. In particular the location and content of stdarg.h has caused
compile problems, or can't be located.

In particular kernel versions have issues with stdarg.h and compatibility
with the sysroot and libc-headers/uapi. If we include the file directly from
the kernel source (STAGING_KERNEL_DIR) we get conflicting types on many
structures, due to kernel .h files being found before libc .h files.  if we
grab just this one file from the source, and put it into our file structure,
everything holds together.

Plus, we get to drop a patch we are carrying to change the include of
stdarg.h

Signed-off-by: Bruce Ashfield <bruce.ashfield@gmail.com>
---

Hi all,

I ran into this same problem with working through the 5.19 kernel
integration.

The build of the vbox guest drivers is sufficiently mixed (versus
say lttng-modules) that I just can't see a really clean way to
pick up stdarg.h from the kernel source tree .. while picking up
none of the other headers (chaos and madness ensues with redefined
types, etc).

I also can't justify picking stdarg.h out of the kernel source and
putting it in the build artifacts, since that breaks our separation
of source and outputs, and this is the only package that requires it.

This is a middle ground approach that worked both against 5.19 and
older kernels for me.

Cheers,

Bruce

 ...ld-against-5.15-libc-headers-headers.patch | 62 -------------------
 .../vboxguestdrivers_6.1.36.bb                |  9 ++-
 2 files changed, 8 insertions(+), 63 deletions(-)
 delete mode 100644 meta-oe/recipes-support/vboxguestdrivers/vboxguestdrivers/0001-utils-fix-build-against-5.15-libc-headers-headers.patch
diff mbox series

Patch

diff --git a/meta-oe/recipes-support/vboxguestdrivers/vboxguestdrivers/0001-utils-fix-build-against-5.15-libc-headers-headers.patch b/meta-oe/recipes-support/vboxguestdrivers/vboxguestdrivers/0001-utils-fix-build-against-5.15-libc-headers-headers.patch
deleted file mode 100644
index 203eec6ee..000000000
--- a/meta-oe/recipes-support/vboxguestdrivers/vboxguestdrivers/0001-utils-fix-build-against-5.15-libc-headers-headers.patch
+++ /dev/null
@@ -1,62 +0,0 @@ 
-From 7213a5bfa3bd9f360d6be01e6dbd59d91095a0fd Mon Sep 17 00:00:00 2001
-From: Bruce Ashfield <bruce.ashfield@gmail.com>
-Date: Thu, 4 Nov 2021 14:53:46 -0400
-Subject: [PATCH] utils: fix build against 5.15 libc-headers headers
-
-In kernel v5.15+ stdarg.h is part of the kernel source, and the
-upstream project has a change to prefer that stdarg.h to the
-c-library variant and hence includes it as <linux/stdarg.h>, which
-leads to the following build error:
-
-   | In file included from ../vboxsf/include/iprt/types.h:34,
-   |                  from ../vboxsf/include/iprt/string.h:33,
-   |                  from mount.vboxsf.c:53:
-   | ../vboxsf/include/iprt/stdarg.h:49:13: fatal error: linux/stdarg.h: No such file or directory
-   |    49 | #   include <linux/stdarg.h>
-   |       |             ^~~~~~~~~~~~~~~~
-
-If we modify our build of the vboxdrivers to have the kernel source
-directory on the include path (to find linux/stdarg.h, that leads
-to the following errors:
-
-   In file included from build/tmp/work/qemux86_64-poky-linux/vboxguestdrivers/6.1.28-r0/recipe-sysroot/usr/include/stdlib.h:394,
-   |                  from mount.vboxsf.c:36:
-   | build/tmp/work/qemux86_64-poky-linux/vboxguestdrivers/6.1.28-r0/recipe-sysroot/usr/include/sys/types.h:192:20: note: previous declaration of 'blkcnt_t' with type 'blkcnt_t' {aka 'long int'}
-   |   192 | typedef __blkcnt_t blkcnt_t;     /* Type to count number of disk blocks.  */
-   |       |                    ^~~~~~~~
-   | In file included from build/tmp/work-shared/qemux86-64/kernel-source/include/linux/time.h:5,
-   |                  from poky/build/tmp/work-shared/qemux86-64/kernel-source/include/linux/stat.h:19,
-   |                  from build/tmp/work/qemux86_64-poky-linux/vboxguestdrivers/6.1.28-r0/recipe-sysroot/usr/include/bits/statx.h:31,
-
-Our libc-headers are safe and don't lead to the potential conflicing
-information that the upstream commit is guarding against. The easiest
-solution is to revert the upstream change and trust our headers.
-
-Upstream-Status: Inappropriate [OE specific]
-
-Signed-off-by: Bruce Ashfield <bruce.ashfield@gmail.com>
----
- vboxsf/include/iprt/stdarg.h | 7 +------
- 1 file changed, 1 insertion(+), 6 deletions(-)
-
-diff --git a/include/iprt/stdarg.h b/include/iprt/stdarg.h
-index c73093c..7bffde5 100644
---- a/include/iprt/stdarg.h
-+++ b/include/iprt/stdarg.h
-@@ -44,12 +44,7 @@
- #   define __builtin_stdarg_start __builtin_va_start
- #  endif
- # elif defined(RT_OS_LINUX) && defined(IN_RING0)
--#  include "linux/version.h"
--#  if RTLNX_VER_MIN(5,15,0) || RTLNX_RHEL_MAJ_PREREQ(9,1)
--#   include <linux/stdarg.h>
--#  else
--#   include <stdarg.h>
--#  endif
-+#  include <stdarg.h>
- # else
- #  include <stdarg.h>
- # endif
--- 
-2.19.1
-
diff --git a/meta-oe/recipes-support/vboxguestdrivers/vboxguestdrivers_6.1.36.bb b/meta-oe/recipes-support/vboxguestdrivers/vboxguestdrivers_6.1.36.bb
index 37dd0224d..06dc8a4c8 100644
--- a/meta-oe/recipes-support/vboxguestdrivers/vboxguestdrivers_6.1.36.bb
+++ b/meta-oe/recipes-support/vboxguestdrivers/vboxguestdrivers_6.1.36.bb
@@ -13,7 +13,6 @@  VBOX_NAME = "VirtualBox-${PV}"
 
 SRC_URI = "http://download.virtualbox.org/virtualbox/${PV}/${VBOX_NAME}.tar.bz2 \
     file://Makefile.utils \
-    file://0001-utils-fix-build-against-5.15-libc-headers-headers.patch \
 "
 
 SRC_URI[sha256sum] = "e47942e42892c13c621869865e2b7b320340154f0fa74ecbdaf18fdaf70ef047"
@@ -42,6 +41,14 @@  do_export_sources() {
     install ${WORKDIR}/${VBOX_NAME}/src/VBox/Additions/linux/sharedfolders/vbsfmount.c ${S}/utils
     install ${S}/../Makefile.utils ${S}/utils/Makefile
 
+    # some kernel versions have issues with stdarg.h and compatibility with
+    # the sysroot and libc-headers/uapi. If we include the file directly from
+    # the kernel source (STAGING_KERNEL_DIR) we get conflicting types on many
+    # structures, due to kernel .h files being found before libc .h files.
+    # if we grab just this one file from the source, and put it into our
+    # file structure, everything holds together
+    mkdir -p ${S}/vboxsf/include/linux
+    install ${STAGING_KERNEL_DIR}/include/linux/stdarg.h  ${S}/vboxsf/include/linux
 }
 
 do_configure:prepend() {