Skip to content

Commit 43e8832

Browse files
johnhubbardakpm00
authored andcommitted
Revert "selftests: error out if kernel header files are not yet built"
This reverts commit 9fc96c7 ("selftests: error out if kernel header files are not yet built"). It turns out that requiring the kernel headers to be built as a prerequisite to building selftests, does not work in many cases. For example, Peter Zijlstra writes: "My biggest beef with the whole thing is that I simply do not want to use 'make headers', it doesn't work for me. I have a ton of output directories and I don't care to build tools into the output dirs, in fact some of them flat out refuse to work that way (bpf comes to mind)." [1] Therefore, stop erroring out on the selftests build. Additional patches will be required in order to change over to not requiring the kernel headers. [1] https://lore.kernel.org/20231208221007.GO28727@noisy.programming.kicks-ass.net Link: https://lkml.kernel.org/r/20231209020144.244759-1-jhubbard@nvidia.com Fixes: 9fc96c7 ("selftests: error out if kernel header files are not yet built") Signed-off-by: John Hubbard <jhubbard@nvidia.com> Cc: Anders Roxell <anders.roxell@linaro.org> Cc: Muhammad Usama Anjum <usama.anjum@collabora.com> Cc: David Hildenbrand <david@redhat.com> Cc: Peter Xu <peterx@redhat.com> Cc: Jonathan Corbet <corbet@lwn.net> Cc: Nathan Chancellor <nathan@kernel.org> Cc: Shuah Khan <shuah@kernel.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Marcos Paulo de Souza <mpdesouza@suse.com> Cc: <stable@vger.kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
1 parent 1dd11e9 commit 43e8832

2 files changed

Lines changed: 4 additions & 57 deletions

File tree

tools/testing/selftests/Makefile

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -155,12 +155,10 @@ ifneq ($(KBUILD_OUTPUT),)
155155
abs_objtree := $(realpath $(abs_objtree))
156156
BUILD := $(abs_objtree)/kselftest
157157
KHDR_INCLUDES := -isystem ${abs_objtree}/usr/include
158-
KHDR_DIR := ${abs_objtree}/usr/include
159158
else
160159
BUILD := $(CURDIR)
161160
abs_srctree := $(shell cd $(top_srcdir) && pwd)
162161
KHDR_INCLUDES := -isystem ${abs_srctree}/usr/include
163-
KHDR_DIR := ${abs_srctree}/usr/include
164162
DEFAULT_INSTALL_HDR_PATH := 1
165163
endif
166164

@@ -174,7 +172,7 @@ export KHDR_INCLUDES
174172
# all isn't the first target in the file.
175173
.DEFAULT_GOAL := all
176174

177-
all: kernel_header_files
175+
all:
178176
@ret=1; \
179177
for TARGET in $(TARGETS); do \
180178
BUILD_TARGET=$$BUILD/$$TARGET; \
@@ -185,23 +183,6 @@ all: kernel_header_files
185183
ret=$$((ret * $$?)); \
186184
done; exit $$ret;
187185

188-
kernel_header_files:
189-
@ls $(KHDR_DIR)/linux/*.h >/dev/null 2>/dev/null; \
190-
if [ $$? -ne 0 ]; then \
191-
RED='\033[1;31m'; \
192-
NOCOLOR='\033[0m'; \
193-
echo; \
194-
echo -e "$${RED}error$${NOCOLOR}: missing kernel header files."; \
195-
echo "Please run this and try again:"; \
196-
echo; \
197-
echo " cd $(top_srcdir)"; \
198-
echo " make headers"; \
199-
echo; \
200-
exit 1; \
201-
fi
202-
203-
.PHONY: kernel_header_files
204-
205186
run_tests: all
206187
@for TARGET in $(TARGETS); do \
207188
BUILD_TARGET=$$BUILD/$$TARGET; \

tools/testing/selftests/lib.mk

Lines changed: 3 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -44,26 +44,10 @@ endif
4444
selfdir = $(realpath $(dir $(filter %/lib.mk,$(MAKEFILE_LIST))))
4545
top_srcdir = $(selfdir)/../../..
4646

47-
ifeq ("$(origin O)", "command line")
48-
KBUILD_OUTPUT := $(O)
47+
ifeq ($(KHDR_INCLUDES),)
48+
KHDR_INCLUDES := -isystem $(top_srcdir)/usr/include
4949
endif
5050

51-
ifneq ($(KBUILD_OUTPUT),)
52-
# Make's built-in functions such as $(abspath ...), $(realpath ...) cannot
53-
# expand a shell special character '~'. We use a somewhat tedious way here.
54-
abs_objtree := $(shell cd $(top_srcdir) && mkdir -p $(KBUILD_OUTPUT) && cd $(KBUILD_OUTPUT) && pwd)
55-
$(if $(abs_objtree),, \
56-
$(error failed to create output directory "$(KBUILD_OUTPUT)"))
57-
# $(realpath ...) resolves symlinks
58-
abs_objtree := $(realpath $(abs_objtree))
59-
KHDR_DIR := ${abs_objtree}/usr/include
60-
else
61-
abs_srctree := $(shell cd $(top_srcdir) && pwd)
62-
KHDR_DIR := ${abs_srctree}/usr/include
63-
endif
64-
65-
KHDR_INCLUDES := -isystem $(KHDR_DIR)
66-
6751
# The following are built by lib.mk common compile rules.
6852
# TEST_CUSTOM_PROGS should be used by tests that require
6953
# custom build rule and prevent common build rule use.
@@ -74,25 +58,7 @@ TEST_GEN_PROGS := $(patsubst %,$(OUTPUT)/%,$(TEST_GEN_PROGS))
7458
TEST_GEN_PROGS_EXTENDED := $(patsubst %,$(OUTPUT)/%,$(TEST_GEN_PROGS_EXTENDED))
7559
TEST_GEN_FILES := $(patsubst %,$(OUTPUT)/%,$(TEST_GEN_FILES))
7660

77-
all: kernel_header_files $(TEST_GEN_PROGS) $(TEST_GEN_PROGS_EXTENDED) \
78-
$(TEST_GEN_FILES)
79-
80-
kernel_header_files:
81-
@ls $(KHDR_DIR)/linux/*.h >/dev/null 2>/dev/null; \
82-
if [ $$? -ne 0 ]; then \
83-
RED='\033[1;31m'; \
84-
NOCOLOR='\033[0m'; \
85-
echo; \
86-
echo -e "$${RED}error$${NOCOLOR}: missing kernel header files."; \
87-
echo "Please run this and try again:"; \
88-
echo; \
89-
echo " cd $(top_srcdir)"; \
90-
echo " make headers"; \
91-
echo; \
92-
exit 1; \
93-
fi
94-
95-
.PHONY: kernel_header_files
61+
all: $(TEST_GEN_PROGS) $(TEST_GEN_PROGS_EXTENDED) $(TEST_GEN_FILES)
9662

9763
define RUN_TESTS
9864
BASE_DIR="$(selfdir)"; \

0 commit comments

Comments
 (0)