From a593a3baa44cbfbeb11f0cc3c2a921688fdf09b0 Mon Sep 17 00:00:00 2001 From: Jiri Olsa Date: Sun, 8 Oct 2023 23:22:50 +0200 Subject: [PATCH 1/3] tools/build: Fix -s detection code in tools/build/Makefile.build As Dmitry described in [1] changelog the current way of detecting -s option is broken for new make. Changing the tools/build -s option detection the same way as it was fixed for root Makefile in [1]. [1] 4bf73588165b ("kbuild: Port silent mode detection to future gnu make.") Cc: Dmitry Goncharov Signed-off-by: Jiri Olsa Tested-by: Arnaldo Carvalho de Melo Acked-by: Namhyung Kim Cc: Peter Zijlstra Cc: KP Singh Cc: Martin KaFai Lau Cc: Song Liu Cc: Yonghong Song Cc: John Fastabend Cc: Hao Luo Cc: Ian Rogers Cc: Stanislav Fomichev Cc: Daniel Borkmann Cc: Quentin Monnet Cc: Arnaldo Carvalho de Melo Cc: Andrii Nakryiko Cc: Alexei Starovoitov Cc: Ingo Molnar Cc: Alexander Shishkin Cc: bpf@vger.kernel.org Cc: linux-perf-users@vger.kernel.org Link: https://lore.kernel.org/r/20231008212251.236023-2-jolsa@kernel.org Signed-off-by: Namhyung Kim --- tools/build/Makefile.build | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/tools/build/Makefile.build b/tools/build/Makefile.build index fac42486a8cf0b..5fb3fb3d97e0fd 100644 --- a/tools/build/Makefile.build +++ b/tools/build/Makefile.build @@ -20,7 +20,15 @@ else Q=@ endif -ifneq ($(findstring s,$(filter-out --%,$(MAKEFLAGS))),) +# If the user is running make -s (silent mode), suppress echoing of commands +# make-4.0 (and later) keep single letter options in the 1st word of MAKEFLAGS. +ifeq ($(filter 3.%,$(MAKE_VERSION)),) +short-opts := $(firstword -$(MAKEFLAGS)) +else +short-opts := $(filter-out --%,$(MAKEFLAGS)) +endif + +ifneq ($(findstring s,$(short-opts)),) quiet=silent_ endif From 3c97822a40cb1ee0d27cba5bd0b7468cde2d1fbb Mon Sep 17 00:00:00 2001 From: Octavian Purdila Date: Wed, 5 Feb 2025 16:51:45 -0800 Subject: [PATCH 2/3] lkl: add tests build barrier tools/build does not support parallel builds when objects are shared between build targets. Keep the test that uses the most common object first and insert a build barrier to avoid rebuilding common objects. Signed-off-by: Octavian Purdila --- tools/lkl/Makefile | 14 ++++++++++---- tools/lkl/Targets | 7 ++++++- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/tools/lkl/Makefile b/tools/lkl/Makefile index 17f105ddecb5cf..d2f089d68f1351 100644 --- a/tools/lkl/Makefile +++ b/tools/lkl/Makefile @@ -50,8 +50,14 @@ export CFLAGS += -I$(OUTPUT)/include -Iinclude -Wall -g -O2 -Wextra \ -include Targets -TARGETS := $(progs-y:%=$(OUTPUT)%$(EXESUF)) -TARGETS += $(libs-y:%=$(OUTPUT)%$(SOSUF)) +# Expand targets to output location and suffix but preserve special +# targets (e.g. .WAIT) +# $1 - targets +# $2 - suffix +expand-targets = $(foreach t,$(1),$(if $(filter .%,$(t)),$(t),$(OUTPUT)$(t)$(2))) + +TARGETS := $(call expand-targets,$(progs-y),$(EXESUF)) +TARGETS += $(call expand-targets,$(libs-y),$(SOSUF)) all: $(TARGETS) # this workaround is for FreeBSD @@ -135,7 +141,7 @@ libraries_install: $(libs-y:%=$(OUTPUT)%$(SOSUF)) $(OUTPUT)liblkl.a install -d $(DESTDIR)$(LIBDIR) ; \ install -m 644 $^ $(DESTDIR)$(LIBDIR) -programs_install: $(progs-y:%=$(OUTPUT)%$(EXESUF)) +programs_install: $(call expand-targets,$(progs-y),$(EXESUF)) $(call QUIET_INSTALL, programs) \ install -d $(DESTDIR)$(BINDIR) ; \ install -m 755 $^ $(DESTDIR)$(BINDIR) @@ -157,4 +163,4 @@ FORCE: ; .PHONY: headers_install libraries_install programs_install install .NOTPARALLEL : lib/lkl.o .SECONDARY: - +.WAIT: diff --git a/tools/lkl/Targets b/tools/lkl/Targets index a337224b18ed18..986abf4a2c67a5 100644 --- a/tools/lkl/Targets +++ b/tools/lkl/Targets @@ -25,8 +25,13 @@ progs-$(LKL_HOST_CONFIG_ARCHIVE) += cptofs LDLIBS_cptofs-y := -larchive LDLIBS_cptofs-$(LKL_HOST_CONFIG_NEEDS_LARGP) += -largp -progs-y += tests/boot +# tools/build/Makefile.build does not support parallel builds when +# objects are shared between build objects so keep the test that uses +# the most common object first and insert a build barrier to avoid +# rebuilding common objects progs-y += tests/disk +progs-y += .WAIT +progs-y += tests/boot progs-y += tests/disk-vfio-pci progs-y += tests/net-test progs-y += tests/config From e758fd8b34520d6222523f94e1d1cf079d6ed346 Mon Sep 17 00:00:00 2001 From: Octavian Purdila Date: Thu, 6 Feb 2025 09:06:41 -0800 Subject: [PATCH 3/3] lkl: don't install tests Separate the tests targets in a different set so that we don't install them with make install. Signed-off-by: Octavian Purdila --- tools/lkl/Makefile | 1 + tools/lkl/Targets | 14 +++++++------- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/tools/lkl/Makefile b/tools/lkl/Makefile index d2f089d68f1351..355441f6d5b60e 100644 --- a/tools/lkl/Makefile +++ b/tools/lkl/Makefile @@ -57,6 +57,7 @@ export CFLAGS += -I$(OUTPUT)/include -Iinclude -Wall -g -O2 -Wextra \ expand-targets = $(foreach t,$(1),$(if $(filter .%,$(t)),$(t),$(OUTPUT)$(t)$(2))) TARGETS := $(call expand-targets,$(progs-y),$(EXESUF)) +TARGETS += $(call expand-targets,$(tests-y),$(EXESUF)) TARGETS += $(call expand-targets,$(libs-y),$(SOSUF)) all: $(TARGETS) diff --git a/tools/lkl/Targets b/tools/lkl/Targets index 986abf4a2c67a5..eaf9d892d57a84 100644 --- a/tools/lkl/Targets +++ b/tools/lkl/Targets @@ -29,14 +29,14 @@ LDLIBS_cptofs-$(LKL_HOST_CONFIG_NEEDS_LARGP) += -largp # objects are shared between build objects so keep the test that uses # the most common object first and insert a build barrier to avoid # rebuilding common objects -progs-y += tests/disk -progs-y += .WAIT -progs-y += tests/boot -progs-y += tests/disk-vfio-pci -progs-y += tests/net-test -progs-y += tests/config +tests-y := tests/disk +tests-y += .WAIT +tests-y += tests/boot +tests-y += tests/disk-vfio-pci +tests-y += tests/net-test +tests-y += tests/config ifneq ($(LKL_HOST_CONFIG_BSD),y) -progs-y += tests/test-dlmopen +tests-y += tests/test-dlmopen LDLIBS_tests/test-dlmopen-$(LKL_HOST_CONFIG_POSIX) += -ldl endif