From 917f713b4ec4ffcc068993e8c7a1d93a8457d467 Mon Sep 17 00:00:00 2001 From: "Maxime Chevallier (Netdev Foundation)" Date: Mon, 7 Sep 2026 18:14:35 +0200 Subject: [PATCH 1/2] tools: ynl: Allow cross-compiling ynl and associated tools The ynl tool and libraries may be built standalone or through the drivers/net/hw selftest machinery. This may target a different arch, so we need to take the CROSS_COMPILE variable into account for LLVM and gcc. Let's include the tools/scripts/Makefile.include that deals with the CC/AR resolution. Fixup the ynltool CFLAGS handling to use +=, so that we don't override the ones set in Makefile.include. Makefile.include also sets the Q variable for verbose mode, so we can drop it from the ynltool Makefile. This will allow properly selection the verbosity of ynltool builds with the V=1 make flag. Reviewed-by: Matthieu Baerts (Netdev Foundation) Signed-off-by: Maxime Chevallier (Netdev Foundation) Link: https://patch.msgid.link/20260907161438.755125-2-maxime.chevallier@bootlin.com Signed-off-by: Jakub Kicinski --- tools/net/ynl/Makefile | 1 + tools/net/ynl/generated/Makefile | 3 ++- tools/net/ynl/lib/Makefile | 3 ++- tools/net/ynl/tests/Makefile | 2 +- tools/net/ynl/ynltool/Makefile | 6 ++---- 5 files changed, 8 insertions(+), 7 deletions(-) diff --git a/tools/net/ynl/Makefile b/tools/net/ynl/Makefile index 3cefe4ed96cb..838c465d65aa 100644 --- a/tools/net/ynl/Makefile +++ b/tools/net/ynl/Makefile @@ -1,5 +1,6 @@ # SPDX-License-Identifier: GPL-2.0 +include ../../scripts/Makefile.include include ../../scripts/Makefile.arch INSTALL ?= install diff --git a/tools/net/ynl/generated/Makefile b/tools/net/ynl/generated/Makefile index ea4128f612d6..5a186349b5a8 100644 --- a/tools/net/ynl/generated/Makefile +++ b/tools/net/ynl/generated/Makefile @@ -1,6 +1,7 @@ # SPDX-License-Identifier: GPL-2.0 -CC=gcc +include ../../../scripts/Makefile.include + CFLAGS += -std=gnu11 -O2 -W -Wall -Wextra -Wno-unused-parameter -Wshadow \ -I../lib/ -idirafter $(UAPI_PATH) ifeq ("$(DEBUG)","1") diff --git a/tools/net/ynl/lib/Makefile b/tools/net/ynl/lib/Makefile index 9b98c0599600..7b3eae89982f 100644 --- a/tools/net/ynl/lib/Makefile +++ b/tools/net/ynl/lib/Makefile @@ -1,6 +1,7 @@ # SPDX-License-Identifier: GPL-2.0 -CC=gcc +include ../../../scripts/Makefile.include + CFLAGS += -std=gnu11 -O2 -W -Wall -Wextra -Wno-unused-parameter -Wshadow ifeq ("$(DEBUG)","1") CFLAGS += -g -fsanitize=address -fsanitize=leak -static-libasan diff --git a/tools/net/ynl/tests/Makefile b/tools/net/ynl/tests/Makefile index 40827ca8e579..99ae7dcd6348 100644 --- a/tools/net/ynl/tests/Makefile +++ b/tools/net/ynl/tests/Makefile @@ -2,8 +2,8 @@ # Makefile for YNL tests include ../Makefile.deps +include ../../../scripts/Makefile.include -CC=gcc CFLAGS += -std=gnu11 -O2 -W -Wall -Wextra -Wno-unused-parameter -Wshadow \ -I../lib/ -I../generated/ -I../../../testing/selftests/ \ -idirafter $(UAPI_PATH) diff --git a/tools/net/ynl/ynltool/Makefile b/tools/net/ynl/ynltool/Makefile index 48b0f32050f0..b8c67cdb4fdf 100644 --- a/tools/net/ynl/ynltool/Makefile +++ b/tools/net/ynl/ynltool/Makefile @@ -1,12 +1,12 @@ # SPDX-License-Identifier: GPL-2.0-only include ../Makefile.deps +include ../../../scripts/Makefile.include INSTALL ?= install prefix ?= /usr -CC := gcc -CFLAGS := -Wall -Wextra -Werror -O2 +CFLAGS += -Wall -Wextra -Werror -O2 ifeq ("$(DEBUG)","1") CFLAGS += -g -fsanitize=address -fsanitize=leak -static-libasan endif @@ -27,8 +27,6 @@ include $(wildcard *.d) all: $(YNLTOOL) -Q = @ - $(YNLTOOL): ../libynl.a $(OBJS) $(Q)echo -e "\tLINK $@" $(Q)$(CC) $(CFLAGS) -o $@ $(OBJS) ../libynl.a -lm From 0c5588740e2204b4005a807b6f5a06ae5a2d0b75 Mon Sep 17 00:00:00 2001 From: "Maxime Chevallier (Netdev Foundation)" Date: Mon, 7 Sep 2026 18:14:36 +0200 Subject: [PATCH 2/2] selftests: drv-net: Use cross-compilation environment for the io_uring check To test for the presence of zerocopy support in the available liburing, a small check program is compiled. The CC value used for the io_uring library check defaults to the host compiler, which will incorrectly validate liburing based on the host's sysroot and not the target's. Normally the CC for cross-compile is set in lib.mk, but this also requires the test list to be set when we include it, and this check needs to run first. Note that this doesn't cover the LLVM cross-compiling case though, as with LLVM we may still detect based on the host liburing. Suggested-by: Matthieu Baerts (NGI0) Reviewed-by: Matthieu Baerts (Netdev Foundation) Signed-off-by: Maxime Chevallier (Netdev Foundation) Link: https://patch.msgid.link/20260907161438.755125-3-maxime.chevallier@bootlin.com Signed-off-by: Jakub Kicinski --- tools/testing/selftests/drivers/net/hw/Makefile | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tools/testing/selftests/drivers/net/hw/Makefile b/tools/testing/selftests/drivers/net/hw/Makefile index 6105be8e590f..f9458dc6c150 100644 --- a/tools/testing/selftests/drivers/net/hw/Makefile +++ b/tools/testing/selftests/drivers/net/hw/Makefile @@ -1,5 +1,10 @@ # SPDX-License-Identifier: GPL-2.0+ OR MIT +# Set CC for the io_uring check +ifeq ($(LLVM)$(CC),cc) +CC := $(CROSS_COMPILE)gcc +endif + # Check if io_uring supports zero-copy receive HAS_IOURING_ZCRX := $(shell \ echo -e '#include \n' \