From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from atuin.qyliss.net (localhost [IPv6:::1]) by atuin.qyliss.net (Postfix) with ESMTP id 3999BC88E; Sat, 18 Oct 2025 10:57:23 +0000 (UTC) Received: by atuin.qyliss.net (Postfix, from userid 993) id 51585C90D; Sat, 18 Oct 2025 10:57:20 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on atuin.qyliss.net X-Spam-Level: X-Spam-Status: No, score=-0.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DMARC_MISSING,RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL,SPF_HELO_PASS autolearn=unavailable autolearn_force=no version=4.0.1 Received: from fout-a7-smtp.messagingengine.com (fout-a7-smtp.messagingengine.com [103.168.172.150]) by atuin.qyliss.net (Postfix) with ESMTPS id 591C2C909 for ; Sat, 18 Oct 2025 10:57:18 +0000 (UTC) Received: from phl-compute-09.internal (phl-compute-09.internal [10.202.2.49]) by mailfout.phl.internal (Postfix) with ESMTP id CD9D1EC0041; Sat, 18 Oct 2025 06:57:16 -0400 (EDT) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-09.internal (MEProxy); Sat, 18 Oct 2025 06:57:16 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alyssa.is; h=cc :cc:content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm1; t=1760785036; x=1760871436; bh=BCJDj7onwg zN5aG6Ym6J2VUrz1K/gEgaT5Jg7NuVDOM=; b=A2aOU+/cfGvAxqgwXAO6p0IZEe mhWT6xuvIRcGC4KU2tnHPmlc9KW3h856fC0iaocurN4GJzfGQ/Mfg3V/ZUxNiQsb MBn9IcMmnPv+zWdqS23qZI3AQjT6H5ouIwKJe5YEyOJQ2+hyAXN9QyjuD+w0N+Qi J+nv9z6VkuyNeQvl3pScYuJ20cDT2VjvPjTTPLPCL6rMFjKWQdKdwpo3pRwhjsQE LVE6wSO0jwOgSVNKihw9vnkvU3I8Q29Pmg8x9qwFdfDB/nM1ODZGfgjkgOamAF8b 8z4b2H3Kbv4KjG7eh7ftRKegaMYAgx2NfKf8EKTEwPyBdC4Zn9rdZsgByJ4g== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t= 1760785036; x=1760871436; bh=BCJDj7onwgzN5aG6Ym6J2VUrz1K/gEgaT5J g7NuVDOM=; b=eP6ZRd9xKx5lBliPblIXF2ko9KncQLeUvEr49mqlJTmjeqBvuPa t01VMxZQNLgejSgxGCMI4klPXY6SL8YItDJhcABZTjmzPJWK+cg+W3P20AgqUzHi ygw4xrJSslbVucVDkbcNgsgNYMMv8uiaEYU5hxJBlPpSMKe0NxEbpUKPwW9R0ShX MQscDXFRcuyQWYPX9yn8qAhG80nIlTLIXIh0kI68hE2ZqHhQiFU7uGljHmw77K6V LmMaBXSo4dDBDR9Vhte64n8hCxMuGS33HiuRWghVYcw2J2T2EbEy2QRz0X6cE+Jl /GOoo08KXk9neJKzXa86FTXbeUcVqnOF2/w== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdeggddufedukeejucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujf gurhephffvvefujghffffkgggtsehgtderredttddtnecuhfhrohhmpeetlhihshhsrgcu tfhoshhsuceohhhisegrlhihshhsrgdrihhsqeenucggtffrrghtthgvrhhnpeeuffdthe ehfeevkeffteeitdeijeduhfevgfduheetjedulefftddvheeiueeuvdenucffohhmrghi nheptghlrghnghgpvddurdgttgenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmh epmhgrihhlfhhrohhmpehhihesrghlhihsshgrrdhishdpnhgspghrtghpthhtohepvddp mhhouggvpehsmhhtphhouhhtpdhrtghpthhtohepuggvmhhiohgsvghnohhurhesghhmrg hilhdrtghomhdprhgtphhtthhopeguvghvvghlsehsphgvtghtrhhumhdqohhsrdhorhhg X-ME-Proxy: Feedback-ID: i12284293:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sat, 18 Oct 2025 06:57:15 -0400 (EDT) Received: by mbp.qyliss.net (Postfix, from userid 1000) id 172AE60F93A6; Sat, 18 Oct 2025 12:56:55 +0200 (CEST) From: Alyssa Ross To: Demi Marie Obenour Subject: Re: [PATCH v3] tools/xdp-forwarder: Do not include libc headers in eBPF programs In-Reply-To: <20251008-fix-forwarder-build-v3-1-a93e5156fb6a@gmail.com> References: <20251006-fix-forwarder-build-v2-1-6fdd7e05cb14@gmail.com> <20251008-fix-forwarder-build-v3-1-a93e5156fb6a@gmail.com> Date: Sat, 18 Oct 2025 12:56:53 +0200 Message-ID: <87a51ojx56.fsf@alyssa.is> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" Message-ID-Hash: DAHSW65FWHNBHKBHOFAF6B6GWCJWUS4X X-Message-ID-Hash: DAHSW65FWHNBHKBHOFAF6B6GWCJWUS4X X-MailFrom: hi@alyssa.is X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-devel.spectrum-os.org-0; header-match-devel.spectrum-os.org-1; header-match-devel.spectrum-os.org-2; header-match-devel.spectrum-os.org-3; header-match-devel.spectrum-os.org-4; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Spectrum OS Development X-Mailman-Version: 3.3.9 Precedence: list List-Id: Patches and low-level development discussion Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Demi Marie Obenour writes: > The build happened to work on arm64 because the glibc arm64 headers > don't support multilib. On x86_64, glibc headers assume that BPF is a > 32-bit platform (because __x86_64__ isn't defined) and fail to find the > 32-bit headers. This is not a glibc bug. Rather, BPF programs should > not be including glibc headers. > > Most Linux headers are not trivial to include in BPF programs. The > version of the headers meant for userspace use do include glibc headers, > and that isn't supported in BPF. The version meant for building > kernel modules does not, but using it requires much more complicated > build system. > > Solve this problem by only including headers intended for use in BPF > programs. These headers include declarations explicitly intended for > use in BPF programs, so if they do pull in libc headers that is a bug. > This also allows using an unwrapped clang. Nix's wrapped clang is not > suitable when a target is explicitly specified, so this is another a > bug fix. > > This prevents vendoring the example headers, so replace them with a > header that only includes common functionality common to both eBPF > programs. A single struct including both Ethernet II and 802.1Q headers > is used, massively simplifying the code. Could we put that cleanup into a separate patch, and keep this patch as the smallest change possible necessary to fix the build? > diff --git a/tools/default.nix b/tools/default.nix > index 2c6846c80073e7b64fb7a19488103f6cf97a4420..8fd3491010303f981dac80cd6= 581614d594f993c 100644 > --- a/tools/default.nix > +++ b/tools/default.nix > @@ -6,7 +6,7 @@ import ../lib/call-package.nix ( > { src, lib, stdenv, fetchCrate, fetchurl, runCommand, buildPackages > , meson, ninja, pkg-config, rustc > , clang-tools, clippy, jq > -, dbus > +, dbus, linuxHeaders > # clang 19 (current nixpkgs default) is too old to support -fwrapv-point= er > , clang_21, libbpf > , buildSupport ? false > @@ -88,7 +88,7 @@ stdenv.mkDerivation (finalAttrs: { > ++ lib.optionals (appSupport || driverSupport) [ pkg-config ] > ++ lib.optionals hostSupport [ rustc ] > ++ lib.optionals driverSupport [ clang_21 ]; > - buildInputs =3D lib.optionals appSupport [ dbus ] ++ lib.optionals dri= verSupport [ libbpf ]; > + buildInputs =3D lib.optionals appSupport [ dbus ] ++ lib.optionals dri= verSupport [ libbpf linuxHeaders ]; >=20=20 > postPatch =3D lib.optionals hostSupport (lib.concatMapStringsSep "\n" = (crate: '' > mkdir -p subprojects/packagecache > @@ -104,11 +104,11 @@ stdenv.mkDerivation (finalAttrs: { > "-Dtests=3Dfalse" > "-Dunwind=3Dfalse" > "-Dwerror=3Dtrue" > + ] ++ lib.optionals driverSupport [ > + "-Dclang=3D${clang_21.cc}/bin/clang" llvmPackages_21.clang-unwrapped would prevent having to go through the unwrapped compiler. > + "-Dlinux-headers=3D${linuxHeaders}/include" > ]; >=20=20 > - # Not supported for target bpf > - hardeningDisable =3D lib.optionals driverSupport [ "zerocallusedregs" = ]; > - > passthru.tests =3D { > clang-tidy =3D finalAttrs.finalPackage.overrideAttrs ( > { name, src, nativeBuildInputs ? [], ... }: > diff --git a/tools/meson.options b/tools/meson.options > index 301efb9f677fdec57c8491fd6a6868f2d35cb076..2aa82a3188f2912487d075c8f= 320a63c14878f91 100644 > --- a/tools/meson.options > +++ b/tools/meson.options > @@ -13,6 +13,13 @@ option('driver', type : 'boolean', value : false, > option('hostfsrootdir', type : 'string', value : '/run/host', > description : 'Path where the virtio-fs provided by the host will be m= ounted') >=20=20 > +option('clang', type : 'string', > + description : 'Path to clang') > + > +option('linux-headers', > + type : 'string', > + description : 'Path to Linux kernel headers') Let's make this the package prefix, rather than the include directory. > + > option('tests', > type : 'boolean', > description : 'Build tests') > diff --git a/tools/xdp-forwarder/meson.build b/tools/xdp-forwarder/meson.= build > index b73130eb27b8000a102b0a8847ecb06b93a955d2..dec75c55884c4317af747b9a1= 2e8f791d09d0a19 100644 > --- a/tools/xdp-forwarder/meson.build > +++ b/tools/xdp-forwarder/meson.build > @@ -9,10 +9,18 @@ executable('set-router-iface', 'set_router_iface.c', > dependencies : libbpf, > install : true) >=20=20 > -clang =3D find_program('clang', native : true) > +clang_path =3D get_option('clang') > +if clang_path =3D=3D '' > + error('clang must be provided to build XDP forwarder') > +endif What was wrong with find_program()? --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iHUEARYKAB0WIQRV/neXydHjZma5XLJbRZGEIw/wogUCaPNydQAKCRBbRZGEIw/w ohgQAPwNemIlmKQgNdtxz+/bO0m7ReClG/rIwg/vCkxJ5ZPP1wEA6kagDms0ZieH Wv2Yo27J+ZngDbkDQF/fnWYdegYsjAA= =fOI6 -----END PGP SIGNATURE----- --=-=-=--