[PATCH] net/tap: fix BPF build failure in cross-compilation environment

Stephen Hemminger stephen at networkplumber.org
Wed Jul 23 16:24:42 CEST 2025


On Wed, 23 Jul 2025 07:57:02 -0500
Ashok Kaladi <ashok.k.kaladi at intel.com> wrote:

> During cross-compilation, BPF build incorrectly includes header files
> from the host system instead of the target sysroot. This leads to
> build failures due to incompatible headers or unavailability of header
> files in the host.
> 
> Fix by using the Meson sysroot property to correctly locate and include
> BPF-related headers from the cross-compilation environment.
> 
> Fixes: d8d065045c4a ("net/tap: rewrite RSS BPF program")
> Cc: stephen at networkplumber.org
> 
> Signed-off-by: Ashok Kaladi <ashok.k.kaladi at intel.com>
> ---
>  drivers/net/tap/bpf/meson.build | 11 ++++++-----
>  1 file changed, 6 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/net/tap/bpf/meson.build b/drivers/net/tap/bpf/meson.build
> index 35d7438c74..1b87d5018e 100644
> --- a/drivers/net/tap/bpf/meson.build
> +++ b/drivers/net/tap/bpf/meson.build
> @@ -39,13 +39,14 @@ endif
>  
>  enable_tap_rss = true
>  
> -libbpf_include_dir = libbpf.get_variable(pkgconfig : 'includedir')
> +# Determine sysroot if cross-compiling and the property exists in the
> +# init files. Note that this environment variable will have to be passed
> +# in as a property during meson setup.
> +sysroot = meson.get_external_property('sysroot', '')
> +libbpf_include_dir = sysroot + libbpf.get_variable(pkgconfig : 'includedir')
>  
> -# The include files <linux/bpf.h> and others include <asm/types.h>
> -# but <asm/types.h> is not defined for multi-lib environment target.
> -# Workaround by using include directoriy from the host build environment.
>  machine_name = run_command('uname', '-m', check: true).stdout().strip()
> -march_include_dir = '/usr/include/' + machine_name + '-linux-gnu'
> +march_include_dir = sysroot + '/usr/include/' + machine_name + '-linux-gnu'

Keep the comment about why uname -m is used.


More information about the dev mailing list