From patchwork Sat Oct 5 19:55:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Oliver_K=C3=A4stner?= X-Patchwork-Id: 1993178 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=teMVeID7; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=oliver-kaestner.de header.i=@oliver-kaestner.de header.a=rsa-sha256 header.s=key2 header.b=GbvFA47N; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.openwrt.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=patchwork.ozlabs.org) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4XLcgZ2LDrz1xtN for ; Sun, 6 Oct 2024 07:38:17 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=lhGbTIsZhWjffsP6ApFZDqKhuxC0pHWaCozcXift954=; b=teMVeID7ol+vvR xnR3/b00r4HIweccBCKiV9cGn/8q8Qd0XUCtaDbk/W2AxSu9Eq8GUXd7zf4STGykTTn5VQXWy1TmO VK1OjoNeORdDKYlaYVzHcVdYJMCIN7H8PCPpGVFNtPGgHip1UhbKfl5yj49XMacbhjTxdQuDVRDqk I8Xn3HxGFzS0vSTu62Tvab8dHQJ3oid/Fx4Eg4YrLwLC+5ABRs5g05Is33h+0fqs+oOJS+NBKFt6o kakCPk8ktC8yIZOAxT5ThP9pMsYpmWVF/bsfo9kKeKeIjKEiWw4FX43bgiIPfWmsTgeltFo8QcA0I oaBrrK6kSN4xaG1hi3QQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1sxBVe-0000000FvUx-01Xj; Sat, 05 Oct 2024 20:36:14 +0000 Received: from relay.yourmailgateway.de ([188.68.61.107]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1sxAuB-0000000FqXZ-2OVV for openwrt-devel@lists.openwrt.org; Sat, 05 Oct 2024 19:57:33 +0000 Received: from mors-relay-8405.netcup.net (localhost [127.0.0.1]) by mors-relay-8405.netcup.net (Postfix) with ESMTPS id 4XLbmN0MpWz6yNJ; Sat, 5 Oct 2024 21:57:24 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=oliver-kaestner.de; s=key2; t=1728158244; bh=RVrUlPl3Ct/mJEmTT56M6xnkWFBn5sU63NPUTT9JMAA=; h=From:To:Cc:Subject:Date:From; b=GbvFA47NZgNfBnRXZPGZ4CHLW1pZyz6Jc/yzhYAQGzVrUgQ+D4gWbizPlDcs5SY88 AmgLl0adIEFEFVstWJm5HxeAPWgzuQQADVxmaC87opt38my9CLylPMGpYwFMOrf8Ur EhgRGcUBG319qev5O3wnUUPV0jHr4xMHGinThdCb12/yUsznKtRssA7lzlUqvFj+MX 3BKcwc3tMFyM7J9n5Ig0QgoWdAoIpej/V+VT/DmZMR6ZBxE26L914odfOoOQ2uI1c5 hRMsOhfTw2tyufqYfpRX8INy8JKf7dN8I2x8MSMRyJPil7WUEN0IaisVV665UKi2UB e4i5jt8XVKLOw== Received: from policy01-mors.netcup.net (unknown [46.38.225.35]) by mors-relay-8405.netcup.net (Postfix) with ESMTPS id 4XLbmM6jQcz6yJs; Sat, 5 Oct 2024 21:57:23 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at policy01-mors.netcup.net X-Spam-Flag: NO X-Spam-Score: -2.898 X-Spam-Level: X-Spam-Status: No, score=-2.898 required=6.31 tests=[ALL_TRUSTED=-1, BAYES_00=-1.9, SPF_PASS=-0.001, URIBL_BLOCKED=0.001, URIBL_DBL_BLOCKED_OPENDNS=0.001, URIBL_ZEN_BLOCKED_OPENDNS=0.001] autolearn=ham autolearn_force=no Received: from mx2fa3.netcup.net (unknown [10.243.12.53]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by policy01-mors.netcup.net (Postfix) with ESMTPS id 4XLbmM15WNz8t3S; Sat, 5 Oct 2024 21:57:23 +0200 (CEST) Received: from oliver-pc.home.okaestne.de (p5de75435.dip0.t-ipconnect.de [93.231.84.53]) by mx2fa3.netcup.net (Postfix) with ESMTPSA id 784F8E0227; Sat, 5 Oct 2024 21:57:18 +0200 (CEST) Authentication-Results: mx2fa3; spf=pass (sender IP is 93.231.84.53) smtp.mailfrom=git@oliver-kaestner.de smtp.helo=oliver-pc.home.okaestne.de Received-SPF: pass (mx2fa3: connection is authenticated) From: =?utf-8?q?Oliver_K=C3=A4stner?= To: Daniel Golle Cc: openwrt-devel@lists.openwrt.org, =?utf-8?q?Oliver_K=C3=A4stner?= Subject: [PATCH][23.05] xdp-tools: build with target toolchain headers Date: Sat, 5 Oct 2024 21:55:24 +0200 Message-ID: <20241005195523.85314-2-git@oliver-kaestner.de> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 X-PPP-Message-ID: <172815823877.11375.14006268841841698458@mx2fa3.netcup.net> X-Rspamd-Queue-Id: 784F8E0227 X-Rspamd-Server: rspamd-worker-8404 X-NC-CID: EGt78bXCk9wIflDAAu8dqYd2yhL9dGgjPLyQjz5x2hCLTgCOqdnR X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241005_125732_234051_2EA04012 X-CRM114-Status: GOOD ( 23.51 ) X-Spam-Score: -2.1 (--) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Fix build to lookup headers from the target toolchain instead of the host's. This removes the need for workarounds to make asm/types.h available in the host os, e.g. by installing gcc-multilib. For th [...] Content analysis details: (-2.1 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [188.68.61.107 listed in list.dnswl.org] 0.0 RCVD_IN_VALIDITY_SAFE_BLOCKED RBL: ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. [188.68.61.107 listed in sa-accredit.habeas.com] 0.0 RCVD_IN_VALIDITY_CERTIFIED_BLOCKED RBL: ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. [188.68.61.107 listed in sa-trusted.bondedsender.org] -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.0 SPF_PASS SPF: sender matches SPF record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] 0.0 RCVD_IN_VALIDITY_RPBL_BLOCKED RBL: ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. [188.68.61.107 listed in bl.score.senderscore.com] X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: OpenWrt Development List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org Fix build to lookup headers from the target toolchain instead of the host's. This removes the need for workarounds to make asm/types.h available in the host os, e.g. by installing gcc-multilib. For this, include two cherry-picked commits from upstream. Add a workaround required for the gcc 12.3.0 toolchain to prevent a macro redefinition error of `offsetof`. Also fix building for MIPSEL by defining `__MIPSEL__` like Debian does. Closes: https://github.com/openwrt/openwrt/issues/12239 Signed-off-by: Oliver Kästner --- package/network/utils/xdp-tools/Makefile | 3 + .../011-libxdp-bpf-cflags-arch-includes.patch | 24 ++++++++ .../012-configure-fix-arch-includes.patch | 56 +++++++++++++++++++ ...030-xdp-filter-offsetof-redefinition.patch | 23 ++++++++ 4 files changed, 106 insertions(+) create mode 100644 package/network/utils/xdp-tools/patches/011-libxdp-bpf-cflags-arch-includes.patch create mode 100644 package/network/utils/xdp-tools/patches/012-configure-fix-arch-includes.patch create mode 100644 package/network/utils/xdp-tools/patches/030-xdp-filter-offsetof-redefinition.patch diff --git a/package/network/utils/xdp-tools/Makefile b/package/network/utils/xdp-tools/Makefile index 3cc7980cf6..9f9a20b10b 100644 --- a/package/network/utils/xdp-tools/Makefile +++ b/package/network/utils/xdp-tools/Makefile @@ -95,6 +95,9 @@ MAKE_VARS += \ define Build/Configure $(call Build/Configure/Default) echo "BPF_CFLAGS += -I$(BPF_HEADERS_DIR)/tools/lib" >> $(PKG_BUILD_DIR)/config.mk +ifeq ($(ARCH),mipsel) + echo "BPF_CFLAGS += -D__MIPSEL__" >> $(PKG_BUILD_DIR)/config.mk +endif endef define Build/InstallDev diff --git a/package/network/utils/xdp-tools/patches/011-libxdp-bpf-cflags-arch-includes.patch b/package/network/utils/xdp-tools/patches/011-libxdp-bpf-cflags-arch-includes.patch new file mode 100644 index 0000000000..234bd0a414 --- /dev/null +++ b/package/network/utils/xdp-tools/patches/011-libxdp-bpf-cflags-arch-includes.patch @@ -0,0 +1,24 @@ +From 11356006dff4f902de0a493455ec94461bdd8dbc Mon Sep 17 00:00:00 2001 +From: ami-GS <1991.daiki@gmail.com> +Date: Fri, 22 Mar 2024 16:58:42 -0700 +Subject: [PATCH] Fix include path of libxdp for each arch + +Signed-off-by: ami-GS <1991.daiki@gmail.com> +--- + lib/libxdp/Makefile | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/lib/libxdp/Makefile b/lib/libxdp/Makefile +index cf0afa49..403d5a6e 100644 +--- a/lib/libxdp/Makefile ++++ b/lib/libxdp/Makefile +@@ -28,7 +28,7 @@ PC_FILE := $(OBJDIR)/libxdp.pc + TEMPLATED_SOURCES := xdp-dispatcher.c + + CFLAGS += -I$(HEADER_DIR) +-BPF_CFLAGS += -I$(HEADER_DIR) ++BPF_CFLAGS += -I$(HEADER_DIR) $(ARCH_INCLUDES) + + + ifndef BUILD_STATIC_ONLY + diff --git a/package/network/utils/xdp-tools/patches/012-configure-fix-arch-includes.patch b/package/network/utils/xdp-tools/patches/012-configure-fix-arch-includes.patch new file mode 100644 index 0000000000..61b2d2066a --- /dev/null +++ b/package/network/utils/xdp-tools/patches/012-configure-fix-arch-includes.patch @@ -0,0 +1,56 @@ +From 6ce30637951949212344f1968c3fd5e5adf1ffc3 Mon Sep 17 00:00:00 2001 +From: Sachin Tiptur +Date: Wed, 13 Sep 2023 12:47:31 +0000 +Subject: [PATCH] Fix build on arm64 + +Fix the arm64 build by adding arch specific header files to +CFLAGS and BPF_CFLAGS. Also, use `gcc -print-multiarch` to get +arch name instead of `uname -m` which is not the right way. + +Signed-off-by: Sachin Tiptur +--- + configure | 7 +++++-- + lib/defines.mk | 4 ++-- + 2 files changed, 7 insertions(+), 4 deletions(-) + +--- a/configure ++++ b/configure +@@ -65,6 +65,7 @@ check_toolchain() + : ${M4=m4} + : ${EMACS=emacs} + : ${ARCH_INCLUDES=} ++ : ${ARCH_NAME=} + + CLANG=$(find_tool clang "$CLANG") + LLC=$(find_tool llc "$LLC") +@@ -76,6 +77,8 @@ check_toolchain() + fi; + done + ++ ARCH_NAME=$($CC -print-multiarch 2>/dev/null) ++ + clang_version=$($CLANG --version | grep -Po '(?<=clang version )[[:digit:]]+') + if [ "$?" -ne "0" ]; then + echo "*** ERROR: Couldn't execute '$CLANG --version'" +@@ -109,7 +112,7 @@ check_toolchain() + if [ -z "$ARCH_INCLUDES" ]; then + for dir in $(echo | $CC -Wp,-v -E - 2>&1 | grep '^ '); do + local idir +- idir="${dir}/$(uname -m)-linux-gnu/" ++ idir="${dir}/${ARCH_NAME}/" + [ -d "$idir" ] && ARCH_INCLUDES="-I${idir} $ARCH_INCLUDES" + done + fi +--- a/lib/defines.mk ++++ b/lib/defines.mk +@@ -40,8 +40,8 @@ endif + + DEFINES += -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 + +-CFLAGS += -std=gnu11 -Wextra -Werror $(DEFINES) +-BPF_CFLAGS += $(DEFINES) $(filter -ffile-prefix-map=%,$(CFLAGS)) ++CFLAGS += -std=gnu11 -Wextra -Werror $(DEFINES) $(ARCH_INCLUDES) ++BPF_CFLAGS += $(DEFINES) $(filter -ffile-prefix-map=%,$(CFLAGS)) $(ARCH_INCLUDES) + + CONFIGMK := $(LIB_DIR)/../config.mk + LIBMK := Makefile $(CONFIGMK) $(LIB_DIR)/defines.mk $(LIB_DIR)/common.mk $(LIB_DIR)/../version.mk diff --git a/package/network/utils/xdp-tools/patches/030-xdp-filter-offsetof-redefinition.patch b/package/network/utils/xdp-tools/patches/030-xdp-filter-offsetof-redefinition.patch new file mode 100644 index 0000000000..4546c1538c --- /dev/null +++ b/package/network/utils/xdp-tools/patches/030-xdp-filter-offsetof-redefinition.patch @@ -0,0 +1,23 @@ +From 70422c175abc240b0050f39fe57fab5277d3612a Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Oliver=20K=C3=A4stner?= +Date: Sun, 29 Sep 2024 21:02:03 +0200 +Subject: [PATCH] xdp-filter: fix offsetof redefinition error with gcc 12.3.0 + +This is fixed in gcc 13.2.0 +--- + xdp-filter/xdpfilt_prog.h | 4 ++++ + 1 file changed, 4 insertions(+) + +--- a/xdp-filter/xdpfilt_prog.h ++++ b/xdp-filter/xdpfilt_prog.h +@@ -18,6 +18,10 @@ + + /* Defines xdp_stats_map */ + #include "xdp/xdp_stats_kern.h" ++/* offsetof is already defined in bpf/bpf_helpers.h, ++ * and including stddef.h of gcc 12.3.0 would fail. ++ */ ++#undef offsetof + #include "xdp/parsing_helpers.h" + + #ifdef FILT_MODE_DENY