* [PATCH] selftests: add headers_install to lib.mk @ 2018-04-12 10:23 Anders Roxell 2018-04-13 9:03 ` [PATCH v2] " Anders Roxell 0 siblings, 1 reply; 21+ messages in thread From: Anders Roxell @ 2018-04-12 10:23 UTC (permalink / raw) To: shuah Cc: linux-kselftest, linux-kernel, netdev, linux-gpio, fathi.boudra, Anders Roxell If the kernel headers aren't installed we can't build all the tests. Add a new make target rule 'khdr' in the file lib.mk to generate the kernel headers and that gets include for every test-dir Makefile that includes lib.mk If the testdir in turn have its own sub-dirs the top_srcdir needs to be set to the linux-rootdir to be able to generate the kernel headers. Signed-off-by: Anders Roxell <anders.roxell@linaro.org> Reviewed-by: Fathi Boudra <fathi.boudra@linaro.org> --- tools/testing/selftests/android/Makefile | 2 +- tools/testing/selftests/android/ion/Makefile | 1 + tools/testing/selftests/bpf/Makefile | 5 ++--- tools/testing/selftests/futex/functional/Makefile | 1 + tools/testing/selftests/gpio/Makefile | 4 ---- tools/testing/selftests/kvm/Makefile | 6 +----- tools/testing/selftests/lib.mk | 8 ++++++++ tools/testing/selftests/vm/Makefile | 3 --- 8 files changed, 14 insertions(+), 16 deletions(-) diff --git a/tools/testing/selftests/android/Makefile b/tools/testing/selftests/android/Makefile index f6304d2be90c..087390bbad68 100644 --- a/tools/testing/selftests/android/Makefile +++ b/tools/testing/selftests/android/Makefile @@ -6,7 +6,7 @@ TEST_PROGS := run.sh include ../lib.mk -all: +all: khdr @for DIR in $(SUBDIRS); do \ BUILD_TARGET=$(OUTPUT)/$$DIR; \ mkdir $$BUILD_TARGET -p; \ diff --git a/tools/testing/selftests/android/ion/Makefile b/tools/testing/selftests/android/ion/Makefile index e03695287f76..14ecd9805748 100644 --- a/tools/testing/selftests/android/ion/Makefile +++ b/tools/testing/selftests/android/ion/Makefile @@ -11,6 +11,7 @@ $(TEST_GEN_FILES): ipcsocket.c ionutils.c TEST_PROGS := ion_test.sh include ../../lib.mk +top_srcdir = ../../../../../ $(OUTPUT)/ionapp_export: ionapp_export.c ipcsocket.c ionutils.c $(OUTPUT)/ionapp_import: ionapp_import.c ipcsocket.c ionutils.c diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests/bpf/Makefile index 0a315ddabbf4..cc611a284087 100644 --- a/tools/testing/selftests/bpf/Makefile +++ b/tools/testing/selftests/bpf/Makefile @@ -16,9 +16,8 @@ LDLIBS += -lcap -lelf -lrt -lpthread TEST_CUSTOM_PROGS = $(OUTPUT)/urandom_read all: $(TEST_CUSTOM_PROGS) -$(TEST_CUSTOM_PROGS): urandom_read - -urandom_read: urandom_read.c +$(TEST_CUSTOM_PROGS):| khdr +$(TEST_CUSTOM_PROGS): urandom_read.c $(CC) -o $(TEST_CUSTOM_PROGS) -static $< # Order correspond to 'make run_tests' order diff --git a/tools/testing/selftests/futex/functional/Makefile b/tools/testing/selftests/futex/functional/Makefile index ff8feca49746..9f602fb40241 100644 --- a/tools/testing/selftests/futex/functional/Makefile +++ b/tools/testing/selftests/futex/functional/Makefile @@ -19,5 +19,6 @@ TEST_GEN_FILES := \ TEST_PROGS := run.sh include ../../lib.mk +top_srcdir = ../../../../../ $(TEST_GEN_FILES): $(HEADERS) diff --git a/tools/testing/selftests/gpio/Makefile b/tools/testing/selftests/gpio/Makefile index 1bbb47565c55..768b2be010db 100644 --- a/tools/testing/selftests/gpio/Makefile +++ b/tools/testing/selftests/gpio/Makefile @@ -25,7 +25,3 @@ $(BINARIES): ../../../gpio/gpio-utils.o ../../../../usr/include/linux/gpio.h ../../../gpio/gpio-utils.o: make ARCH=$(ARCH) CROSS_COMPILE=$(CROSS_COMPILE) -C ../../../gpio - -../../../../usr/include/linux/gpio.h: - make -C ../../../.. headers_install INSTALL_HDR_PATH=$(shell pwd)/../../../../usr/ - diff --git a/tools/testing/selftests/kvm/Makefile b/tools/testing/selftests/kvm/Makefile index dc44de904797..ba03ce334212 100644 --- a/tools/testing/selftests/kvm/Makefile +++ b/tools/testing/selftests/kvm/Makefile @@ -31,9 +31,5 @@ $(LIBKVM_OBJ): $(OUTPUT)/%.o: %.c $(OUTPUT)/libkvm.a: $(LIBKVM_OBJ) $(AR) crs $@ $^ -$(LINUX_HDR_PATH): - make -C $(top_srcdir) headers_install - -all: $(STATIC_LIBS) $(LINUX_HDR_PATH) +all: $(STATIC_LIBS) $(TEST_GEN_PROGS): $(STATIC_LIBS) -$(TEST_GEN_PROGS) $(LIBKVM_OBJ): | $(LINUX_HDR_PATH) diff --git a/tools/testing/selftests/lib.mk b/tools/testing/selftests/lib.mk index 195e9d4739a9..e0bfbc5b1f1f 100644 --- a/tools/testing/selftests/lib.mk +++ b/tools/testing/selftests/lib.mk @@ -16,8 +16,16 @@ TEST_GEN_PROGS := $(patsubst %,$(OUTPUT)/%,$(TEST_GEN_PROGS)) TEST_GEN_PROGS_EXTENDED := $(patsubst %,$(OUTPUT)/%,$(TEST_GEN_PROGS_EXTENDED)) TEST_GEN_FILES := $(patsubst %,$(OUTPUT)/%,$(TEST_GEN_FILES)) +top_srcdir ?= ../../../../ + all: $(TEST_GEN_PROGS) $(TEST_GEN_PROGS_EXTENDED) $(TEST_GEN_FILES) +.PHONY: khdr +khdr: + make -C $(top_srcdir) headers_install + +$(TEST_GEN_PROGS) $(TEST_GEN_PROGS_EXTENDED) $(TEST_GEN_FILES):| khdr + .ONESHELL: define RUN_TESTS @export KSFT_TAP_LEVEL=`echo 1`; diff --git a/tools/testing/selftests/vm/Makefile b/tools/testing/selftests/vm/Makefile index fdefa2295ddc..1e34a40745ef 100644 --- a/tools/testing/selftests/vm/Makefile +++ b/tools/testing/selftests/vm/Makefile @@ -29,6 +29,3 @@ $(OUTPUT)/userfaultfd: ../../../../usr/include/linux/kernel.h $(OUTPUT)/userfaultfd: LDLIBS += -lpthread $(OUTPUT)/mlock-random-test: LDLIBS += -lcap - -../../../../usr/include/linux/kernel.h: - make -C ../../../.. headers_install -- 2.16.3 ^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH v2] selftests: add headers_install to lib.mk 2018-04-12 10:23 [PATCH] selftests: add headers_install to lib.mk Anders Roxell @ 2018-04-13 9:03 ` Anders Roxell 2018-05-14 11:58 ` [PATCH v3] " Anders Roxell 2018-06-07 11:09 ` [PATCH v4] " Anders Roxell 0 siblings, 2 replies; 21+ messages in thread From: Anders Roxell @ 2018-04-13 9:03 UTC (permalink / raw) To: shuah, yamada.masahiro, michal.lkml Cc: linux-kselftest, linux-kbuild, linux-kernel, netdev, linux-gpio, fathi.boudra, Anders Roxell If the kernel headers aren't installed we can't build all the tests. Add a new make target rule 'khdr' in the file lib.mk to generate the kernel headers and that gets include for every test-dir Makefile that includes lib.mk If the testdir in turn have its own sub-dirs the top_srcdir needs to be set to the linux-rootdir to be able to generate the kernel headers. Signed-off-by: Anders Roxell <anders.roxell@linaro.org> Reviewed-by: Fathi Boudra <fathi.boudra@linaro.org> --- Makefile | 14 +------------- scripts/subarch.include | 13 +++++++++++++ tools/testing/selftests/android/Makefile | 2 +- tools/testing/selftests/android/ion/Makefile | 1 + tools/testing/selftests/bpf/Makefile | 5 ++--- tools/testing/selftests/futex/functional/Makefile | 1 + tools/testing/selftests/gpio/Makefile | 4 ---- tools/testing/selftests/kvm/Makefile | 6 +----- tools/testing/selftests/lib.mk | 10 ++++++++++ tools/testing/selftests/vm/Makefile | 3 --- 10 files changed, 30 insertions(+), 29 deletions(-) create mode 100644 scripts/subarch.include diff --git a/Makefile b/Makefile index 74567b0ec2f0..0c47935d48a2 100644 --- a/Makefile +++ b/Makefile @@ -286,19 +286,7 @@ KERNELRELEASE = $(shell cat include/config/kernel.release 2> /dev/null) KERNELVERSION = $(VERSION)$(if $(PATCHLEVEL),.$(PATCHLEVEL)$(if $(SUBLEVEL),.$(SUBLEVEL)))$(EXTRAVERSION) export VERSION PATCHLEVEL SUBLEVEL KERNELRELEASE KERNELVERSION -# SUBARCH tells the usermode build what the underlying arch is. That is set -# first, and if a usermode build is happening, the "ARCH=um" on the command -# line overrides the setting of ARCH below. If a native build is happening, -# then ARCH is assigned, getting whatever value it gets normally, and -# SUBARCH is subsequently ignored. - -SUBARCH := $(shell uname -m | sed -e s/i.86/x86/ -e s/x86_64/x86/ \ - -e s/sun4u/sparc64/ \ - -e s/arm.*/arm/ -e s/sa110/arm/ \ - -e s/s390x/s390/ -e s/parisc64/parisc/ \ - -e s/ppc.*/powerpc/ -e s/mips.*/mips/ \ - -e s/sh[234].*/sh/ -e s/aarch64.*/arm64/ \ - -e s/riscv.*/riscv/) +include scripts/subarch.include # Cross compiling and selecting different set of gcc/bin-utils # --------------------------------------------------------------------------- diff --git a/scripts/subarch.include b/scripts/subarch.include new file mode 100644 index 000000000000..650682821126 --- /dev/null +++ b/scripts/subarch.include @@ -0,0 +1,13 @@ +# SUBARCH tells the usermode build what the underlying arch is. That is set +# first, and if a usermode build is happening, the "ARCH=um" on the command +# line overrides the setting of ARCH below. If a native build is happening, +# then ARCH is assigned, getting whatever value it gets normally, and +# SUBARCH is subsequently ignored. + +SUBARCH := $(shell uname -m | sed -e s/i.86/x86/ -e s/x86_64/x86/ \ + -e s/sun4u/sparc64/ \ + -e s/arm.*/arm/ -e s/sa110/arm/ \ + -e s/s390x/s390/ -e s/parisc64/parisc/ \ + -e s/ppc.*/powerpc/ -e s/mips.*/mips/ \ + -e s/sh[234].*/sh/ -e s/aarch64.*/arm64/ \ + -e s/riscv.*/riscv/) diff --git a/tools/testing/selftests/android/Makefile b/tools/testing/selftests/android/Makefile index f6304d2be90c..087390bbad68 100644 --- a/tools/testing/selftests/android/Makefile +++ b/tools/testing/selftests/android/Makefile @@ -6,7 +6,7 @@ TEST_PROGS := run.sh include ../lib.mk -all: +all: khdr @for DIR in $(SUBDIRS); do \ BUILD_TARGET=$(OUTPUT)/$$DIR; \ mkdir $$BUILD_TARGET -p; \ diff --git a/tools/testing/selftests/android/ion/Makefile b/tools/testing/selftests/android/ion/Makefile index e03695287f76..14ecd9805748 100644 --- a/tools/testing/selftests/android/ion/Makefile +++ b/tools/testing/selftests/android/ion/Makefile @@ -11,6 +11,7 @@ $(TEST_GEN_FILES): ipcsocket.c ionutils.c TEST_PROGS := ion_test.sh include ../../lib.mk +top_srcdir = ../../../../../ $(OUTPUT)/ionapp_export: ionapp_export.c ipcsocket.c ionutils.c $(OUTPUT)/ionapp_import: ionapp_import.c ipcsocket.c ionutils.c diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests/bpf/Makefile index 0a315ddabbf4..cc611a284087 100644 --- a/tools/testing/selftests/bpf/Makefile +++ b/tools/testing/selftests/bpf/Makefile @@ -16,9 +16,8 @@ LDLIBS += -lcap -lelf -lrt -lpthread TEST_CUSTOM_PROGS = $(OUTPUT)/urandom_read all: $(TEST_CUSTOM_PROGS) -$(TEST_CUSTOM_PROGS): urandom_read - -urandom_read: urandom_read.c +$(TEST_CUSTOM_PROGS):| khdr +$(TEST_CUSTOM_PROGS): urandom_read.c $(CC) -o $(TEST_CUSTOM_PROGS) -static $< # Order correspond to 'make run_tests' order diff --git a/tools/testing/selftests/futex/functional/Makefile b/tools/testing/selftests/futex/functional/Makefile index ff8feca49746..9f602fb40241 100644 --- a/tools/testing/selftests/futex/functional/Makefile +++ b/tools/testing/selftests/futex/functional/Makefile @@ -19,5 +19,6 @@ TEST_GEN_FILES := \ TEST_PROGS := run.sh include ../../lib.mk +top_srcdir = ../../../../../ $(TEST_GEN_FILES): $(HEADERS) diff --git a/tools/testing/selftests/gpio/Makefile b/tools/testing/selftests/gpio/Makefile index 1bbb47565c55..768b2be010db 100644 --- a/tools/testing/selftests/gpio/Makefile +++ b/tools/testing/selftests/gpio/Makefile @@ -25,7 +25,3 @@ $(BINARIES): ../../../gpio/gpio-utils.o ../../../../usr/include/linux/gpio.h ../../../gpio/gpio-utils.o: make ARCH=$(ARCH) CROSS_COMPILE=$(CROSS_COMPILE) -C ../../../gpio - -../../../../usr/include/linux/gpio.h: - make -C ../../../.. headers_install INSTALL_HDR_PATH=$(shell pwd)/../../../../usr/ - diff --git a/tools/testing/selftests/kvm/Makefile b/tools/testing/selftests/kvm/Makefile index dc44de904797..ba03ce334212 100644 --- a/tools/testing/selftests/kvm/Makefile +++ b/tools/testing/selftests/kvm/Makefile @@ -31,9 +31,5 @@ $(LIBKVM_OBJ): $(OUTPUT)/%.o: %.c $(OUTPUT)/libkvm.a: $(LIBKVM_OBJ) $(AR) crs $@ $^ -$(LINUX_HDR_PATH): - make -C $(top_srcdir) headers_install - -all: $(STATIC_LIBS) $(LINUX_HDR_PATH) +all: $(STATIC_LIBS) $(TEST_GEN_PROGS): $(STATIC_LIBS) -$(TEST_GEN_PROGS) $(LIBKVM_OBJ): | $(LINUX_HDR_PATH) diff --git a/tools/testing/selftests/lib.mk b/tools/testing/selftests/lib.mk index 195e9d4739a9..1b1e8135715e 100644 --- a/tools/testing/selftests/lib.mk +++ b/tools/testing/selftests/lib.mk @@ -16,8 +16,18 @@ TEST_GEN_PROGS := $(patsubst %,$(OUTPUT)/%,$(TEST_GEN_PROGS)) TEST_GEN_PROGS_EXTENDED := $(patsubst %,$(OUTPUT)/%,$(TEST_GEN_PROGS_EXTENDED)) TEST_GEN_FILES := $(patsubst %,$(OUTPUT)/%,$(TEST_GEN_FILES)) +top_srcdir ?= ../../../../ +include $(top_srcdir)/scripts/subarch.include +ARCH ?= $(SUBARCH) + all: $(TEST_GEN_PROGS) $(TEST_GEN_PROGS_EXTENDED) $(TEST_GEN_FILES) +.PHONY: khdr +khdr: + make ARCH=$(ARCH) -C $(top_srcdir) headers_install + +$(TEST_GEN_PROGS) $(TEST_GEN_PROGS_EXTENDED) $(TEST_GEN_FILES):| khdr + .ONESHELL: define RUN_TESTS @export KSFT_TAP_LEVEL=`echo 1`; diff --git a/tools/testing/selftests/vm/Makefile b/tools/testing/selftests/vm/Makefile index fdefa2295ddc..1e34a40745ef 100644 --- a/tools/testing/selftests/vm/Makefile +++ b/tools/testing/selftests/vm/Makefile @@ -29,6 +29,3 @@ $(OUTPUT)/userfaultfd: ../../../../usr/include/linux/kernel.h $(OUTPUT)/userfaultfd: LDLIBS += -lpthread $(OUTPUT)/mlock-random-test: LDLIBS += -lcap - -../../../../usr/include/linux/kernel.h: - make -C ../../../.. headers_install -- 2.16.3 ^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH v3] selftests: add headers_install to lib.mk 2018-04-13 9:03 ` [PATCH v2] " Anders Roxell @ 2018-05-14 11:58 ` Anders Roxell 2018-05-14 17:16 ` Paolo Bonzini ` (2 more replies) 2018-06-07 11:09 ` [PATCH v4] " Anders Roxell 1 sibling, 3 replies; 21+ messages in thread From: Anders Roxell @ 2018-05-14 11:58 UTC (permalink / raw) To: yamada.masahiro, michal.lkml, shuah, bamv2005, brgl, pbonzini, akpm, rppt, aarcange Cc: linux-kbuild, linux-kernel, linux-kselftest, netdev, Anders Roxell If the kernel headers aren't installed we can't build all the tests. Add a new make target rule 'khdr' in the file lib.mk to generate the kernel headers and that gets include for every test-dir Makefile that includes lib.mk If the testdir in turn have its own sub-dirs the top_srcdir needs to be set to the linux-rootdir to be able to generate the kernel headers. Signed-off-by: Anders Roxell <anders.roxell@linaro.org> Reviewed-by: Fathi Boudra <fathi.boudra@linaro.org> --- Makefile | 14 +------------- scripts/subarch.include | 13 +++++++++++++ tools/testing/selftests/android/Makefile | 2 +- tools/testing/selftests/android/ion/Makefile | 1 + tools/testing/selftests/bpf/Makefile | 5 ++--- tools/testing/selftests/futex/functional/Makefile | 1 + tools/testing/selftests/gpio/Makefile | 7 ++----- tools/testing/selftests/kvm/Makefile | 7 ++----- tools/testing/selftests/lib.mk | 10 ++++++++++ tools/testing/selftests/vm/Makefile | 4 ---- 10 files changed, 33 insertions(+), 31 deletions(-) create mode 100644 scripts/subarch.include diff --git a/Makefile b/Makefile index 6395c79ffe40..bad0a8f6e874 100644 --- a/Makefile +++ b/Makefile @@ -286,19 +286,7 @@ KERNELRELEASE = $(shell cat include/config/kernel.release 2> /dev/null) KERNELVERSION = $(VERSION)$(if $(PATCHLEVEL),.$(PATCHLEVEL)$(if $(SUBLEVEL),.$(SUBLEVEL)))$(EXTRAVERSION) export VERSION PATCHLEVEL SUBLEVEL KERNELRELEASE KERNELVERSION -# SUBARCH tells the usermode build what the underlying arch is. That is set -# first, and if a usermode build is happening, the "ARCH=um" on the command -# line overrides the setting of ARCH below. If a native build is happening, -# then ARCH is assigned, getting whatever value it gets normally, and -# SUBARCH is subsequently ignored. - -SUBARCH := $(shell uname -m | sed -e s/i.86/x86/ -e s/x86_64/x86/ \ - -e s/sun4u/sparc64/ \ - -e s/arm.*/arm/ -e s/sa110/arm/ \ - -e s/s390x/s390/ -e s/parisc64/parisc/ \ - -e s/ppc.*/powerpc/ -e s/mips.*/mips/ \ - -e s/sh[234].*/sh/ -e s/aarch64.*/arm64/ \ - -e s/riscv.*/riscv/) +include scripts/subarch.include # Cross compiling and selecting different set of gcc/bin-utils # --------------------------------------------------------------------------- diff --git a/scripts/subarch.include b/scripts/subarch.include new file mode 100644 index 000000000000..650682821126 --- /dev/null +++ b/scripts/subarch.include @@ -0,0 +1,13 @@ +# SUBARCH tells the usermode build what the underlying arch is. That is set +# first, and if a usermode build is happening, the "ARCH=um" on the command +# line overrides the setting of ARCH below. If a native build is happening, +# then ARCH is assigned, getting whatever value it gets normally, and +# SUBARCH is subsequently ignored. + +SUBARCH := $(shell uname -m | sed -e s/i.86/x86/ -e s/x86_64/x86/ \ + -e s/sun4u/sparc64/ \ + -e s/arm.*/arm/ -e s/sa110/arm/ \ + -e s/s390x/s390/ -e s/parisc64/parisc/ \ + -e s/ppc.*/powerpc/ -e s/mips.*/mips/ \ + -e s/sh[234].*/sh/ -e s/aarch64.*/arm64/ \ + -e s/riscv.*/riscv/) diff --git a/tools/testing/selftests/android/Makefile b/tools/testing/selftests/android/Makefile index 72c25a3cb658..d9a725478375 100644 --- a/tools/testing/selftests/android/Makefile +++ b/tools/testing/selftests/android/Makefile @@ -6,7 +6,7 @@ TEST_PROGS := run.sh include ../lib.mk -all: +all: khdr @for DIR in $(SUBDIRS); do \ BUILD_TARGET=$(OUTPUT)/$$DIR; \ mkdir $$BUILD_TARGET -p; \ diff --git a/tools/testing/selftests/android/ion/Makefile b/tools/testing/selftests/android/ion/Makefile index e03695287f76..f3be7dcc060a 100644 --- a/tools/testing/selftests/android/ion/Makefile +++ b/tools/testing/selftests/android/ion/Makefile @@ -10,6 +10,7 @@ $(TEST_GEN_FILES): ipcsocket.c ionutils.c TEST_PROGS := ion_test.sh +top_srcdir = ../../../../.. include ../../lib.mk $(OUTPUT)/ionapp_export: ionapp_export.c ipcsocket.c ionutils.c diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests/bpf/Makefile index 438d4f93875b..9741609a0eb1 100644 --- a/tools/testing/selftests/bpf/Makefile +++ b/tools/testing/selftests/bpf/Makefile @@ -16,9 +16,8 @@ LDLIBS += -lcap -lelf -lrt -lpthread TEST_CUSTOM_PROGS = $(OUTPUT)/urandom_read all: $(TEST_CUSTOM_PROGS) -$(TEST_CUSTOM_PROGS): urandom_read - -urandom_read: urandom_read.c +$(TEST_CUSTOM_PROGS):| khdr +$(TEST_CUSTOM_PROGS): urandom_read.c $(CC) -o $(TEST_CUSTOM_PROGS) -static $< # Order correspond to 'make run_tests' order diff --git a/tools/testing/selftests/futex/functional/Makefile b/tools/testing/selftests/futex/functional/Makefile index ff8feca49746..ad1eeb14fda7 100644 --- a/tools/testing/selftests/futex/functional/Makefile +++ b/tools/testing/selftests/futex/functional/Makefile @@ -18,6 +18,7 @@ TEST_GEN_FILES := \ TEST_PROGS := run.sh +top_srcdir = ../../../../.. include ../../lib.mk $(TEST_GEN_FILES): $(HEADERS) diff --git a/tools/testing/selftests/gpio/Makefile b/tools/testing/selftests/gpio/Makefile index 1bbb47565c55..4665cdbf1a8d 100644 --- a/tools/testing/selftests/gpio/Makefile +++ b/tools/testing/selftests/gpio/Makefile @@ -21,11 +21,8 @@ endef CFLAGS += -O2 -g -std=gnu99 -Wall -I../../../../usr/include/ LDLIBS += -lmount -I/usr/include/libmount -$(BINARIES): ../../../gpio/gpio-utils.o ../../../../usr/include/linux/gpio.h +$(BINARIES):| khdr +$(BINARIES): ../../../gpio/gpio-utils.o ../../../gpio/gpio-utils.o: make ARCH=$(ARCH) CROSS_COMPILE=$(CROSS_COMPILE) -C ../../../gpio - -../../../../usr/include/linux/gpio.h: - make -C ../../../.. headers_install INSTALL_HDR_PATH=$(shell pwd)/../../../../usr/ - diff --git a/tools/testing/selftests/kvm/Makefile b/tools/testing/selftests/kvm/Makefile index d9d00319b07c..bcb69380bbab 100644 --- a/tools/testing/selftests/kvm/Makefile +++ b/tools/testing/selftests/kvm/Makefile @@ -32,9 +32,6 @@ $(LIBKVM_OBJ): $(OUTPUT)/%.o: %.c $(OUTPUT)/libkvm.a: $(LIBKVM_OBJ) $(AR) crs $@ $^ -$(LINUX_HDR_PATH): - make -C $(top_srcdir) headers_install - -all: $(STATIC_LIBS) $(LINUX_HDR_PATH) +all: $(STATIC_LIBS) $(TEST_GEN_PROGS): $(STATIC_LIBS) -$(TEST_GEN_PROGS) $(LIBKVM_OBJ): | $(LINUX_HDR_PATH) +$(STATIC_LIBS):| khdr diff --git a/tools/testing/selftests/lib.mk b/tools/testing/selftests/lib.mk index 6466294366dc..9515af872e16 100644 --- a/tools/testing/selftests/lib.mk +++ b/tools/testing/selftests/lib.mk @@ -16,8 +16,18 @@ TEST_GEN_PROGS := $(patsubst %,$(OUTPUT)/%,$(TEST_GEN_PROGS)) TEST_GEN_PROGS_EXTENDED := $(patsubst %,$(OUTPUT)/%,$(TEST_GEN_PROGS_EXTENDED)) TEST_GEN_FILES := $(patsubst %,$(OUTPUT)/%,$(TEST_GEN_FILES)) +top_srcdir ?= ../../../.. +include $(top_srcdir)/scripts/subarch.include +ARCH ?= $(SUBARCH) + all: $(TEST_GEN_PROGS) $(TEST_GEN_PROGS_EXTENDED) $(TEST_GEN_FILES) +.PHONY: khdr +khdr: + make ARCH=$(ARCH) -C $(top_srcdir) headers_install + +$(TEST_GEN_PROGS) $(TEST_GEN_PROGS_EXTENDED) $(TEST_GEN_FILES):| khdr + .ONESHELL: define RUN_TEST_PRINT_RESULT TEST_HDR_MSG="selftests: "`basename $$PWD`:" $$BASENAME_TEST"; \ diff --git a/tools/testing/selftests/vm/Makefile b/tools/testing/selftests/vm/Makefile index fdefa2295ddc..58759454b1d0 100644 --- a/tools/testing/selftests/vm/Makefile +++ b/tools/testing/selftests/vm/Makefile @@ -25,10 +25,6 @@ TEST_PROGS := run_vmtests include ../lib.mk -$(OUTPUT)/userfaultfd: ../../../../usr/include/linux/kernel.h $(OUTPUT)/userfaultfd: LDLIBS += -lpthread $(OUTPUT)/mlock-random-test: LDLIBS += -lcap - -../../../../usr/include/linux/kernel.h: - make -C ../../../.. headers_install -- 2.17.0 ^ permalink raw reply related [flat|nested] 21+ messages in thread
* Re: [PATCH v3] selftests: add headers_install to lib.mk 2018-05-14 11:58 ` [PATCH v3] " Anders Roxell @ 2018-05-14 17:16 ` Paolo Bonzini 2018-05-14 18:44 ` Mike Rapoport 2018-05-14 19:20 ` Daniel Borkmann 2 siblings, 0 replies; 21+ messages in thread From: Paolo Bonzini @ 2018-05-14 17:16 UTC (permalink / raw) To: Anders Roxell, yamada.masahiro, michal.lkml, shuah, bamv2005, brgl, akpm, rppt, aarcange Cc: linux-kbuild, linux-kernel, linux-kselftest, netdev On 14/05/2018 13:58, Anders Roxell wrote: > If the kernel headers aren't installed we can't build all the tests. > Add a new make target rule 'khdr' in the file lib.mk to generate the > kernel headers and that gets include for every test-dir Makefile that > includes lib.mk If the testdir in turn have its own sub-dirs the > top_srcdir needs to be set to the linux-rootdir to be able to generate > the kernel headers. > > Signed-off-by: Anders Roxell <anders.roxell@linaro.org> > Reviewed-by: Fathi Boudra <fathi.boudra@linaro.org> Ack for KVM parts. Paolo ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH v3] selftests: add headers_install to lib.mk 2018-05-14 11:58 ` [PATCH v3] " Anders Roxell 2018-05-14 17:16 ` Paolo Bonzini @ 2018-05-14 18:44 ` Mike Rapoport 2018-05-14 19:20 ` Daniel Borkmann 2 siblings, 0 replies; 21+ messages in thread From: Mike Rapoport @ 2018-05-14 18:44 UTC (permalink / raw) To: Anders Roxell Cc: yamada.masahiro, michal.lkml, shuah, bamv2005, brgl, pbonzini, akpm, aarcange, linux-kbuild, linux-kernel, linux-kselftest, netdev On Mon, May 14, 2018 at 01:58:09PM +0200, Anders Roxell wrote: > If the kernel headers aren't installed we can't build all the tests. > Add a new make target rule 'khdr' in the file lib.mk to generate the > kernel headers and that gets include for every test-dir Makefile that > includes lib.mk If the testdir in turn have its own sub-dirs the > top_srcdir needs to be set to the linux-rootdir to be able to generate > the kernel headers. > > Signed-off-by: Anders Roxell <anders.roxell@linaro.org> > Reviewed-by: Fathi Boudra <fathi.boudra@linaro.org> Ack for the userfaultfd part. > --- > Makefile | 14 +------------- > scripts/subarch.include | 13 +++++++++++++ > tools/testing/selftests/android/Makefile | 2 +- > tools/testing/selftests/android/ion/Makefile | 1 + > tools/testing/selftests/bpf/Makefile | 5 ++--- > tools/testing/selftests/futex/functional/Makefile | 1 + > tools/testing/selftests/gpio/Makefile | 7 ++----- > tools/testing/selftests/kvm/Makefile | 7 ++----- > tools/testing/selftests/lib.mk | 10 ++++++++++ > tools/testing/selftests/vm/Makefile | 4 ---- > 10 files changed, 33 insertions(+), 31 deletions(-) > create mode 100644 scripts/subarch.include > > diff --git a/Makefile b/Makefile > index 6395c79ffe40..bad0a8f6e874 100644 > --- a/Makefile > +++ b/Makefile > @@ -286,19 +286,7 @@ KERNELRELEASE = $(shell cat include/config/kernel.release 2> /dev/null) > KERNELVERSION = $(VERSION)$(if $(PATCHLEVEL),.$(PATCHLEVEL)$(if $(SUBLEVEL),.$(SUBLEVEL)))$(EXTRAVERSION) > export VERSION PATCHLEVEL SUBLEVEL KERNELRELEASE KERNELVERSION > > -# SUBARCH tells the usermode build what the underlying arch is. That is set > -# first, and if a usermode build is happening, the "ARCH=um" on the command > -# line overrides the setting of ARCH below. If a native build is happening, > -# then ARCH is assigned, getting whatever value it gets normally, and > -# SUBARCH is subsequently ignored. > - > -SUBARCH := $(shell uname -m | sed -e s/i.86/x86/ -e s/x86_64/x86/ \ > - -e s/sun4u/sparc64/ \ > - -e s/arm.*/arm/ -e s/sa110/arm/ \ > - -e s/s390x/s390/ -e s/parisc64/parisc/ \ > - -e s/ppc.*/powerpc/ -e s/mips.*/mips/ \ > - -e s/sh[234].*/sh/ -e s/aarch64.*/arm64/ \ > - -e s/riscv.*/riscv/) > +include scripts/subarch.include > > # Cross compiling and selecting different set of gcc/bin-utils > # --------------------------------------------------------------------------- > diff --git a/scripts/subarch.include b/scripts/subarch.include > new file mode 100644 > index 000000000000..650682821126 > --- /dev/null > +++ b/scripts/subarch.include > @@ -0,0 +1,13 @@ > +# SUBARCH tells the usermode build what the underlying arch is. That is set > +# first, and if a usermode build is happening, the "ARCH=um" on the command > +# line overrides the setting of ARCH below. If a native build is happening, > +# then ARCH is assigned, getting whatever value it gets normally, and > +# SUBARCH is subsequently ignored. > + > +SUBARCH := $(shell uname -m | sed -e s/i.86/x86/ -e s/x86_64/x86/ \ > + -e s/sun4u/sparc64/ \ > + -e s/arm.*/arm/ -e s/sa110/arm/ \ > + -e s/s390x/s390/ -e s/parisc64/parisc/ \ > + -e s/ppc.*/powerpc/ -e s/mips.*/mips/ \ > + -e s/sh[234].*/sh/ -e s/aarch64.*/arm64/ \ > + -e s/riscv.*/riscv/) > diff --git a/tools/testing/selftests/android/Makefile b/tools/testing/selftests/android/Makefile > index 72c25a3cb658..d9a725478375 100644 > --- a/tools/testing/selftests/android/Makefile > +++ b/tools/testing/selftests/android/Makefile > @@ -6,7 +6,7 @@ TEST_PROGS := run.sh > > include ../lib.mk > > -all: > +all: khdr > @for DIR in $(SUBDIRS); do \ > BUILD_TARGET=$(OUTPUT)/$$DIR; \ > mkdir $$BUILD_TARGET -p; \ > diff --git a/tools/testing/selftests/android/ion/Makefile b/tools/testing/selftests/android/ion/Makefile > index e03695287f76..f3be7dcc060a 100644 > --- a/tools/testing/selftests/android/ion/Makefile > +++ b/tools/testing/selftests/android/ion/Makefile > @@ -10,6 +10,7 @@ $(TEST_GEN_FILES): ipcsocket.c ionutils.c > > TEST_PROGS := ion_test.sh > > +top_srcdir = ../../../../.. > include ../../lib.mk > > $(OUTPUT)/ionapp_export: ionapp_export.c ipcsocket.c ionutils.c > diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests/bpf/Makefile > index 438d4f93875b..9741609a0eb1 100644 > --- a/tools/testing/selftests/bpf/Makefile > +++ b/tools/testing/selftests/bpf/Makefile > @@ -16,9 +16,8 @@ LDLIBS += -lcap -lelf -lrt -lpthread > TEST_CUSTOM_PROGS = $(OUTPUT)/urandom_read > all: $(TEST_CUSTOM_PROGS) > > -$(TEST_CUSTOM_PROGS): urandom_read > - > -urandom_read: urandom_read.c > +$(TEST_CUSTOM_PROGS):| khdr > +$(TEST_CUSTOM_PROGS): urandom_read.c > $(CC) -o $(TEST_CUSTOM_PROGS) -static $< > > # Order correspond to 'make run_tests' order > diff --git a/tools/testing/selftests/futex/functional/Makefile b/tools/testing/selftests/futex/functional/Makefile > index ff8feca49746..ad1eeb14fda7 100644 > --- a/tools/testing/selftests/futex/functional/Makefile > +++ b/tools/testing/selftests/futex/functional/Makefile > @@ -18,6 +18,7 @@ TEST_GEN_FILES := \ > > TEST_PROGS := run.sh > > +top_srcdir = ../../../../.. > include ../../lib.mk > > $(TEST_GEN_FILES): $(HEADERS) > diff --git a/tools/testing/selftests/gpio/Makefile b/tools/testing/selftests/gpio/Makefile > index 1bbb47565c55..4665cdbf1a8d 100644 > --- a/tools/testing/selftests/gpio/Makefile > +++ b/tools/testing/selftests/gpio/Makefile > @@ -21,11 +21,8 @@ endef > CFLAGS += -O2 -g -std=gnu99 -Wall -I../../../../usr/include/ > LDLIBS += -lmount -I/usr/include/libmount > > -$(BINARIES): ../../../gpio/gpio-utils.o ../../../../usr/include/linux/gpio.h > +$(BINARIES):| khdr > +$(BINARIES): ../../../gpio/gpio-utils.o > > ../../../gpio/gpio-utils.o: > make ARCH=$(ARCH) CROSS_COMPILE=$(CROSS_COMPILE) -C ../../../gpio > - > -../../../../usr/include/linux/gpio.h: > - make -C ../../../.. headers_install INSTALL_HDR_PATH=$(shell pwd)/../../../../usr/ > - > diff --git a/tools/testing/selftests/kvm/Makefile b/tools/testing/selftests/kvm/Makefile > index d9d00319b07c..bcb69380bbab 100644 > --- a/tools/testing/selftests/kvm/Makefile > +++ b/tools/testing/selftests/kvm/Makefile > @@ -32,9 +32,6 @@ $(LIBKVM_OBJ): $(OUTPUT)/%.o: %.c > $(OUTPUT)/libkvm.a: $(LIBKVM_OBJ) > $(AR) crs $@ $^ > > -$(LINUX_HDR_PATH): > - make -C $(top_srcdir) headers_install > - > -all: $(STATIC_LIBS) $(LINUX_HDR_PATH) > +all: $(STATIC_LIBS) > $(TEST_GEN_PROGS): $(STATIC_LIBS) > -$(TEST_GEN_PROGS) $(LIBKVM_OBJ): | $(LINUX_HDR_PATH) > +$(STATIC_LIBS):| khdr > diff --git a/tools/testing/selftests/lib.mk b/tools/testing/selftests/lib.mk > index 6466294366dc..9515af872e16 100644 > --- a/tools/testing/selftests/lib.mk > +++ b/tools/testing/selftests/lib.mk > @@ -16,8 +16,18 @@ TEST_GEN_PROGS := $(patsubst %,$(OUTPUT)/%,$(TEST_GEN_PROGS)) > TEST_GEN_PROGS_EXTENDED := $(patsubst %,$(OUTPUT)/%,$(TEST_GEN_PROGS_EXTENDED)) > TEST_GEN_FILES := $(patsubst %,$(OUTPUT)/%,$(TEST_GEN_FILES)) > > +top_srcdir ?= ../../../.. > +include $(top_srcdir)/scripts/subarch.include > +ARCH ?= $(SUBARCH) > + > all: $(TEST_GEN_PROGS) $(TEST_GEN_PROGS_EXTENDED) $(TEST_GEN_FILES) > > +.PHONY: khdr > +khdr: > + make ARCH=$(ARCH) -C $(top_srcdir) headers_install > + > +$(TEST_GEN_PROGS) $(TEST_GEN_PROGS_EXTENDED) $(TEST_GEN_FILES):| khdr > + > .ONESHELL: > define RUN_TEST_PRINT_RESULT > TEST_HDR_MSG="selftests: "`basename $$PWD`:" $$BASENAME_TEST"; \ > diff --git a/tools/testing/selftests/vm/Makefile b/tools/testing/selftests/vm/Makefile > index fdefa2295ddc..58759454b1d0 100644 > --- a/tools/testing/selftests/vm/Makefile > +++ b/tools/testing/selftests/vm/Makefile > @@ -25,10 +25,6 @@ TEST_PROGS := run_vmtests > > include ../lib.mk > > -$(OUTPUT)/userfaultfd: ../../../../usr/include/linux/kernel.h > $(OUTPUT)/userfaultfd: LDLIBS += -lpthread > > $(OUTPUT)/mlock-random-test: LDLIBS += -lcap > - > -../../../../usr/include/linux/kernel.h: > - make -C ../../../.. headers_install > -- > 2.17.0 > -- Sincerely yours, Mike. ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH v3] selftests: add headers_install to lib.mk 2018-05-14 11:58 ` [PATCH v3] " Anders Roxell 2018-05-14 17:16 ` Paolo Bonzini 2018-05-14 18:44 ` Mike Rapoport @ 2018-05-14 19:20 ` Daniel Borkmann 2018-06-07 11:07 ` Anders Roxell 2 siblings, 1 reply; 21+ messages in thread From: Daniel Borkmann @ 2018-05-14 19:20 UTC (permalink / raw) To: Anders Roxell, yamada.masahiro, michal.lkml, shuah, bamv2005, brgl, pbonzini, akpm, rppt, aarcange Cc: linux-kbuild, linux-kernel, linux-kselftest, netdev, alexei.starovoitov On 05/14/2018 01:58 PM, Anders Roxell wrote: > If the kernel headers aren't installed we can't build all the tests. > Add a new make target rule 'khdr' in the file lib.mk to generate the > kernel headers and that gets include for every test-dir Makefile that > includes lib.mk If the testdir in turn have its own sub-dirs the > top_srcdir needs to be set to the linux-rootdir to be able to generate > the kernel headers. > > Signed-off-by: Anders Roxell <anders.roxell@linaro.org> > Reviewed-by: Fathi Boudra <fathi.boudra@linaro.org> > --- > Makefile | 14 +------------- > scripts/subarch.include | 13 +++++++++++++ > tools/testing/selftests/android/Makefile | 2 +- > tools/testing/selftests/android/ion/Makefile | 1 + > tools/testing/selftests/bpf/Makefile | 5 ++--- > tools/testing/selftests/futex/functional/Makefile | 1 + > tools/testing/selftests/gpio/Makefile | 7 ++----- > tools/testing/selftests/kvm/Makefile | 7 ++----- > tools/testing/selftests/lib.mk | 10 ++++++++++ > tools/testing/selftests/vm/Makefile | 4 ---- > 10 files changed, 33 insertions(+), 31 deletions(-) > create mode 100644 scripts/subarch.include [...] > diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests/bpf/Makefile > index 438d4f93875b..9741609a0eb1 100644 > --- a/tools/testing/selftests/bpf/Makefile > +++ b/tools/testing/selftests/bpf/Makefile > @@ -16,9 +16,8 @@ LDLIBS += -lcap -lelf -lrt -lpthread > TEST_CUSTOM_PROGS = $(OUTPUT)/urandom_read > all: $(TEST_CUSTOM_PROGS) > > -$(TEST_CUSTOM_PROGS): urandom_read > - > -urandom_read: urandom_read.c > +$(TEST_CUSTOM_PROGS):| khdr > +$(TEST_CUSTOM_PROGS): urandom_read.c > $(CC) -o $(TEST_CUSTOM_PROGS) -static $< > > # Order correspond to 'make run_tests' order Can you elaborate on the error in BPF you're seeing that would force a headers_install for it? Some people are running the tools/ infrastructure (incl. BPF kselftests) outside of kernel tree where this dependency would break their setup. Why BPF bits cannot be fixed otherwise? Thanks, Daniel ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH v3] selftests: add headers_install to lib.mk 2018-05-14 19:20 ` Daniel Borkmann @ 2018-06-07 11:07 ` Anders Roxell 0 siblings, 0 replies; 21+ messages in thread From: Anders Roxell @ 2018-06-07 11:07 UTC (permalink / raw) To: Daniel Borkmann Cc: Masahiro Yamada, Michal Marek, Shuah Khan, Bamvor Zhang, brgl, Paolo Bonzini, Andrew Morton, Mike Rapoport, aarcange, linux-kbuild, Linux Kernel Mailing List, linux-kselftest, Networking, alexei.starovoitov On 14 May 2018 at 21:20, Daniel Borkmann <daniel@iogearbox.net> wrote: > On 05/14/2018 01:58 PM, Anders Roxell wrote: >> If the kernel headers aren't installed we can't build all the tests. >> Add a new make target rule 'khdr' in the file lib.mk to generate the >> kernel headers and that gets include for every test-dir Makefile that >> includes lib.mk If the testdir in turn have its own sub-dirs the >> top_srcdir needs to be set to the linux-rootdir to be able to generate >> the kernel headers. >> >> Signed-off-by: Anders Roxell <anders.roxell@linaro.org> >> Reviewed-by: Fathi Boudra <fathi.boudra@linaro.org> >> --- >> Makefile | 14 +------------- >> scripts/subarch.include | 13 +++++++++++++ >> tools/testing/selftests/android/Makefile | 2 +- >> tools/testing/selftests/android/ion/Makefile | 1 + >> tools/testing/selftests/bpf/Makefile | 5 ++--- >> tools/testing/selftests/futex/functional/Makefile | 1 + >> tools/testing/selftests/gpio/Makefile | 7 ++----- >> tools/testing/selftests/kvm/Makefile | 7 ++----- >> tools/testing/selftests/lib.mk | 10 ++++++++++ >> tools/testing/selftests/vm/Makefile | 4 ---- >> 10 files changed, 33 insertions(+), 31 deletions(-) >> create mode 100644 scripts/subarch.include > [...] >> diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests/bpf/Makefile >> index 438d4f93875b..9741609a0eb1 100644 >> --- a/tools/testing/selftests/bpf/Makefile >> +++ b/tools/testing/selftests/bpf/Makefile >> @@ -16,9 +16,8 @@ LDLIBS += -lcap -lelf -lrt -lpthread >> TEST_CUSTOM_PROGS = $(OUTPUT)/urandom_read >> all: $(TEST_CUSTOM_PROGS) >> >> -$(TEST_CUSTOM_PROGS): urandom_read >> - >> -urandom_read: urandom_read.c >> +$(TEST_CUSTOM_PROGS):| khdr >> +$(TEST_CUSTOM_PROGS): urandom_read.c >> $(CC) -o $(TEST_CUSTOM_PROGS) -static $< >> >> # Order correspond to 'make run_tests' order > > Can you elaborate on the error in BPF you're seeing that would force a > headers_install for it? BPF shouldn't be affected, a new revision of the patch does not touch the bpf/Makefile. I will send out a patch soon. Cheers, Anders > Some people are running the tools/ infrastructure > (incl. BPF kselftests) outside of kernel tree where this dependency would > break their setup. Why BPF bits cannot be fixed otherwise? > > Thanks, > Daniel ^ permalink raw reply [flat|nested] 21+ messages in thread
* [PATCH v4] selftests: add headers_install to lib.mk 2018-04-13 9:03 ` [PATCH v2] " Anders Roxell 2018-05-14 11:58 ` [PATCH v3] " Anders Roxell @ 2018-06-07 11:09 ` Anders Roxell 2018-07-23 20:49 ` Anders Roxell 1 sibling, 1 reply; 21+ messages in thread From: Anders Roxell @ 2018-06-07 11:09 UTC (permalink / raw) To: yamada.masahiro, michal.lkml, shuah, bamv2005, brgl, pbonzini, akpm, rppt, aarcange Cc: linux-kbuild, linux-kernel, linux-kselftest, netdev, Anders Roxell If the kernel headers aren't installed we can't build all the tests. Add a new make target rule 'khdr' in the file lib.mk to generate the kernel headers and that gets include for every test-dir Makefile that includes lib.mk If the testdir in turn have its own sub-dirs the top_srcdir needs to be set to the linux-rootdir to be able to generate the kernel headers. Signed-off-by: Anders Roxell <anders.roxell@linaro.org> Reviewed-by: Fathi Boudra <fathi.boudra@linaro.org> --- Makefile | 14 +------------- scripts/subarch.include | 13 +++++++++++++ tools/testing/selftests/android/Makefile | 2 +- tools/testing/selftests/android/ion/Makefile | 2 ++ tools/testing/selftests/futex/functional/Makefile | 1 + tools/testing/selftests/gpio/Makefile | 7 ++----- tools/testing/selftests/kvm/Makefile | 7 ++----- tools/testing/selftests/lib.mk | 12 ++++++++++++ tools/testing/selftests/net/Makefile | 1 + .../selftests/networking/timestamping/Makefile | 1 + tools/testing/selftests/vm/Makefile | 4 ---- 11 files changed, 36 insertions(+), 28 deletions(-) create mode 100644 scripts/subarch.include diff --git a/Makefile b/Makefile index 6b9aea95ae3a..8050072300fa 100644 --- a/Makefile +++ b/Makefile @@ -286,19 +286,7 @@ KERNELRELEASE = $(shell cat include/config/kernel.release 2> /dev/null) KERNELVERSION = $(VERSION)$(if $(PATCHLEVEL),.$(PATCHLEVEL)$(if $(SUBLEVEL),.$(SUBLEVEL)))$(EXTRAVERSION) export VERSION PATCHLEVEL SUBLEVEL KERNELRELEASE KERNELVERSION -# SUBARCH tells the usermode build what the underlying arch is. That is set -# first, and if a usermode build is happening, the "ARCH=um" on the command -# line overrides the setting of ARCH below. If a native build is happening, -# then ARCH is assigned, getting whatever value it gets normally, and -# SUBARCH is subsequently ignored. - -SUBARCH := $(shell uname -m | sed -e s/i.86/x86/ -e s/x86_64/x86/ \ - -e s/sun4u/sparc64/ \ - -e s/arm.*/arm/ -e s/sa110/arm/ \ - -e s/s390x/s390/ -e s/parisc64/parisc/ \ - -e s/ppc.*/powerpc/ -e s/mips.*/mips/ \ - -e s/sh[234].*/sh/ -e s/aarch64.*/arm64/ \ - -e s/riscv.*/riscv/) +include scripts/subarch.include # Cross compiling and selecting different set of gcc/bin-utils # --------------------------------------------------------------------------- diff --git a/scripts/subarch.include b/scripts/subarch.include new file mode 100644 index 000000000000..650682821126 --- /dev/null +++ b/scripts/subarch.include @@ -0,0 +1,13 @@ +# SUBARCH tells the usermode build what the underlying arch is. That is set +# first, and if a usermode build is happening, the "ARCH=um" on the command +# line overrides the setting of ARCH below. If a native build is happening, +# then ARCH is assigned, getting whatever value it gets normally, and +# SUBARCH is subsequently ignored. + +SUBARCH := $(shell uname -m | sed -e s/i.86/x86/ -e s/x86_64/x86/ \ + -e s/sun4u/sparc64/ \ + -e s/arm.*/arm/ -e s/sa110/arm/ \ + -e s/s390x/s390/ -e s/parisc64/parisc/ \ + -e s/ppc.*/powerpc/ -e s/mips.*/mips/ \ + -e s/sh[234].*/sh/ -e s/aarch64.*/arm64/ \ + -e s/riscv.*/riscv/) diff --git a/tools/testing/selftests/android/Makefile b/tools/testing/selftests/android/Makefile index 72c25a3cb658..d9a725478375 100644 --- a/tools/testing/selftests/android/Makefile +++ b/tools/testing/selftests/android/Makefile @@ -6,7 +6,7 @@ TEST_PROGS := run.sh include ../lib.mk -all: +all: khdr @for DIR in $(SUBDIRS); do \ BUILD_TARGET=$(OUTPUT)/$$DIR; \ mkdir $$BUILD_TARGET -p; \ diff --git a/tools/testing/selftests/android/ion/Makefile b/tools/testing/selftests/android/ion/Makefile index e03695287f76..88cfe88e466f 100644 --- a/tools/testing/selftests/android/ion/Makefile +++ b/tools/testing/selftests/android/ion/Makefile @@ -10,6 +10,8 @@ $(TEST_GEN_FILES): ipcsocket.c ionutils.c TEST_PROGS := ion_test.sh +KSFT_KHDR_INSTALL := 1 +top_srcdir = ../../../../.. include ../../lib.mk $(OUTPUT)/ionapp_export: ionapp_export.c ipcsocket.c ionutils.c diff --git a/tools/testing/selftests/futex/functional/Makefile b/tools/testing/selftests/futex/functional/Makefile index ff8feca49746..ad1eeb14fda7 100644 --- a/tools/testing/selftests/futex/functional/Makefile +++ b/tools/testing/selftests/futex/functional/Makefile @@ -18,6 +18,7 @@ TEST_GEN_FILES := \ TEST_PROGS := run.sh +top_srcdir = ../../../../.. include ../../lib.mk $(TEST_GEN_FILES): $(HEADERS) diff --git a/tools/testing/selftests/gpio/Makefile b/tools/testing/selftests/gpio/Makefile index 1bbb47565c55..4665cdbf1a8d 100644 --- a/tools/testing/selftests/gpio/Makefile +++ b/tools/testing/selftests/gpio/Makefile @@ -21,11 +21,8 @@ endef CFLAGS += -O2 -g -std=gnu99 -Wall -I../../../../usr/include/ LDLIBS += -lmount -I/usr/include/libmount -$(BINARIES): ../../../gpio/gpio-utils.o ../../../../usr/include/linux/gpio.h +$(BINARIES):| khdr +$(BINARIES): ../../../gpio/gpio-utils.o ../../../gpio/gpio-utils.o: make ARCH=$(ARCH) CROSS_COMPILE=$(CROSS_COMPILE) -C ../../../gpio - -../../../../usr/include/linux/gpio.h: - make -C ../../../.. headers_install INSTALL_HDR_PATH=$(shell pwd)/../../../../usr/ - diff --git a/tools/testing/selftests/kvm/Makefile b/tools/testing/selftests/kvm/Makefile index d9d00319b07c..bcb69380bbab 100644 --- a/tools/testing/selftests/kvm/Makefile +++ b/tools/testing/selftests/kvm/Makefile @@ -32,9 +32,6 @@ $(LIBKVM_OBJ): $(OUTPUT)/%.o: %.c $(OUTPUT)/libkvm.a: $(LIBKVM_OBJ) $(AR) crs $@ $^ -$(LINUX_HDR_PATH): - make -C $(top_srcdir) headers_install - -all: $(STATIC_LIBS) $(LINUX_HDR_PATH) +all: $(STATIC_LIBS) $(TEST_GEN_PROGS): $(STATIC_LIBS) -$(TEST_GEN_PROGS) $(LIBKVM_OBJ): | $(LINUX_HDR_PATH) +$(STATIC_LIBS):| khdr diff --git a/tools/testing/selftests/lib.mk b/tools/testing/selftests/lib.mk index 17ab36605a8e..0a8e75886224 100644 --- a/tools/testing/selftests/lib.mk +++ b/tools/testing/selftests/lib.mk @@ -16,8 +16,20 @@ TEST_GEN_PROGS := $(patsubst %,$(OUTPUT)/%,$(TEST_GEN_PROGS)) TEST_GEN_PROGS_EXTENDED := $(patsubst %,$(OUTPUT)/%,$(TEST_GEN_PROGS_EXTENDED)) TEST_GEN_FILES := $(patsubst %,$(OUTPUT)/%,$(TEST_GEN_FILES)) +top_srcdir ?= ../../../.. +include $(top_srcdir)/scripts/subarch.include +ARCH ?= $(SUBARCH) + all: $(TEST_GEN_PROGS) $(TEST_GEN_PROGS_EXTENDED) $(TEST_GEN_FILES) +.PHONY: khdr +khdr: + make ARCH=$(ARCH) -C $(top_srcdir) headers_install + +ifdef KSFT_KHDR_INSTALL +$(TEST_GEN_PROGS) $(TEST_GEN_PROGS_EXTENDED) $(TEST_GEN_FILES):| khdr +endif + .ONESHELL: define RUN_TEST_PRINT_RESULT TEST_HDR_MSG="selftests: "`basename $$PWD`:" $$BASENAME_TEST"; \ diff --git a/tools/testing/selftests/net/Makefile b/tools/testing/selftests/net/Makefile index 663e11e85727..d515dabc6b0d 100644 --- a/tools/testing/selftests/net/Makefile +++ b/tools/testing/selftests/net/Makefile @@ -15,6 +15,7 @@ TEST_GEN_FILES += udpgso udpgso_bench_tx udpgso_bench_rx TEST_GEN_PROGS = reuseport_bpf reuseport_bpf_cpu reuseport_bpf_numa TEST_GEN_PROGS += reuseport_dualstack reuseaddr_conflict +KSFT_KHDR_INSTALL := 1 include ../lib.mk $(OUTPUT)/reuseport_bpf_numa: LDFLAGS += -lnuma diff --git a/tools/testing/selftests/networking/timestamping/Makefile b/tools/testing/selftests/networking/timestamping/Makefile index a728040edbe1..14cfcf006936 100644 --- a/tools/testing/selftests/networking/timestamping/Makefile +++ b/tools/testing/selftests/networking/timestamping/Makefile @@ -5,6 +5,7 @@ TEST_PROGS := hwtstamp_config rxtimestamp timestamping txtimestamp all: $(TEST_PROGS) +top_srcdir = ../../../../.. include ../../lib.mk clean: diff --git a/tools/testing/selftests/vm/Makefile b/tools/testing/selftests/vm/Makefile index fdefa2295ddc..58759454b1d0 100644 --- a/tools/testing/selftests/vm/Makefile +++ b/tools/testing/selftests/vm/Makefile @@ -25,10 +25,6 @@ TEST_PROGS := run_vmtests include ../lib.mk -$(OUTPUT)/userfaultfd: ../../../../usr/include/linux/kernel.h $(OUTPUT)/userfaultfd: LDLIBS += -lpthread $(OUTPUT)/mlock-random-test: LDLIBS += -lcap - -../../../../usr/include/linux/kernel.h: - make -C ../../../.. headers_install -- 2.17.1 ^ permalink raw reply related [flat|nested] 21+ messages in thread
* Re: [PATCH v4] selftests: add headers_install to lib.mk 2018-06-07 11:09 ` [PATCH v4] " Anders Roxell @ 2018-07-23 20:49 ` Anders Roxell 2018-07-24 17:10 ` Shuah Khan 0 siblings, 1 reply; 21+ messages in thread From: Anders Roxell @ 2018-07-23 20:49 UTC (permalink / raw) To: Masahiro Yamada, Michal Marek, Shuah Khan, Bamvor Zhang, brgl, Paolo Bonzini, Andrew Morton, Mike Rapoport, aarcange Cc: linux-kbuild, Linux Kernel Mailing List, open list:KERNEL SELFTEST FRAMEWORK, Networking On Thu, 7 Jun 2018 at 13:09, Anders Roxell <anders.roxell@linaro.org> wrote: > > If the kernel headers aren't installed we can't build all the tests. > Add a new make target rule 'khdr' in the file lib.mk to generate the > kernel headers and that gets include for every test-dir Makefile that > includes lib.mk If the testdir in turn have its own sub-dirs the > top_srcdir needs to be set to the linux-rootdir to be able to generate > the kernel headers. > > Signed-off-by: Anders Roxell <anders.roxell@linaro.org> > Reviewed-by: Fathi Boudra <fathi.boudra@linaro.org> > --- > Makefile | 14 +------------- > scripts/subarch.include | 13 +++++++++++++ > tools/testing/selftests/android/Makefile | 2 +- > tools/testing/selftests/android/ion/Makefile | 2 ++ > tools/testing/selftests/futex/functional/Makefile | 1 + > tools/testing/selftests/gpio/Makefile | 7 ++----- > tools/testing/selftests/kvm/Makefile | 7 ++----- > tools/testing/selftests/lib.mk | 12 ++++++++++++ > tools/testing/selftests/net/Makefile | 1 + > .../selftests/networking/timestamping/Makefile | 1 + > tools/testing/selftests/vm/Makefile | 4 ---- > 11 files changed, 36 insertions(+), 28 deletions(-) > create mode 100644 scripts/subarch.include > > diff --git a/Makefile b/Makefile > index 6b9aea95ae3a..8050072300fa 100644 > --- a/Makefile > +++ b/Makefile > @@ -286,19 +286,7 @@ KERNELRELEASE = $(shell cat include/config/kernel.release 2> /dev/null) > KERNELVERSION = $(VERSION)$(if $(PATCHLEVEL),.$(PATCHLEVEL)$(if $(SUBLEVEL),.$(SUBLEVEL)))$(EXTRAVERSION) > export VERSION PATCHLEVEL SUBLEVEL KERNELRELEASE KERNELVERSION > > -# SUBARCH tells the usermode build what the underlying arch is. That is set > -# first, and if a usermode build is happening, the "ARCH=um" on the command > -# line overrides the setting of ARCH below. If a native build is happening, > -# then ARCH is assigned, getting whatever value it gets normally, and > -# SUBARCH is subsequently ignored. > - > -SUBARCH := $(shell uname -m | sed -e s/i.86/x86/ -e s/x86_64/x86/ \ > - -e s/sun4u/sparc64/ \ > - -e s/arm.*/arm/ -e s/sa110/arm/ \ > - -e s/s390x/s390/ -e s/parisc64/parisc/ \ > - -e s/ppc.*/powerpc/ -e s/mips.*/mips/ \ > - -e s/sh[234].*/sh/ -e s/aarch64.*/arm64/ \ > - -e s/riscv.*/riscv/) > +include scripts/subarch.include > > # Cross compiling and selecting different set of gcc/bin-utils > # --------------------------------------------------------------------------- > diff --git a/scripts/subarch.include b/scripts/subarch.include > new file mode 100644 > index 000000000000..650682821126 > --- /dev/null > +++ b/scripts/subarch.include > @@ -0,0 +1,13 @@ > +# SUBARCH tells the usermode build what the underlying arch is. That is set > +# first, and if a usermode build is happening, the "ARCH=um" on the command > +# line overrides the setting of ARCH below. If a native build is happening, > +# then ARCH is assigned, getting whatever value it gets normally, and > +# SUBARCH is subsequently ignored. > + > +SUBARCH := $(shell uname -m | sed -e s/i.86/x86/ -e s/x86_64/x86/ \ > + -e s/sun4u/sparc64/ \ > + -e s/arm.*/arm/ -e s/sa110/arm/ \ > + -e s/s390x/s390/ -e s/parisc64/parisc/ \ > + -e s/ppc.*/powerpc/ -e s/mips.*/mips/ \ > + -e s/sh[234].*/sh/ -e s/aarch64.*/arm64/ \ > + -e s/riscv.*/riscv/) > diff --git a/tools/testing/selftests/android/Makefile b/tools/testing/selftests/android/Makefile > index 72c25a3cb658..d9a725478375 100644 > --- a/tools/testing/selftests/android/Makefile > +++ b/tools/testing/selftests/android/Makefile > @@ -6,7 +6,7 @@ TEST_PROGS := run.sh > > include ../lib.mk > > -all: > +all: khdr > @for DIR in $(SUBDIRS); do \ > BUILD_TARGET=$(OUTPUT)/$$DIR; \ > mkdir $$BUILD_TARGET -p; \ > diff --git a/tools/testing/selftests/android/ion/Makefile b/tools/testing/selftests/android/ion/Makefile > index e03695287f76..88cfe88e466f 100644 > --- a/tools/testing/selftests/android/ion/Makefile > +++ b/tools/testing/selftests/android/ion/Makefile > @@ -10,6 +10,8 @@ $(TEST_GEN_FILES): ipcsocket.c ionutils.c > > TEST_PROGS := ion_test.sh > > +KSFT_KHDR_INSTALL := 1 > +top_srcdir = ../../../../.. > include ../../lib.mk > > $(OUTPUT)/ionapp_export: ionapp_export.c ipcsocket.c ionutils.c > diff --git a/tools/testing/selftests/futex/functional/Makefile b/tools/testing/selftests/futex/functional/Makefile > index ff8feca49746..ad1eeb14fda7 100644 > --- a/tools/testing/selftests/futex/functional/Makefile > +++ b/tools/testing/selftests/futex/functional/Makefile > @@ -18,6 +18,7 @@ TEST_GEN_FILES := \ > > TEST_PROGS := run.sh > > +top_srcdir = ../../../../.. > include ../../lib.mk > > $(TEST_GEN_FILES): $(HEADERS) > diff --git a/tools/testing/selftests/gpio/Makefile b/tools/testing/selftests/gpio/Makefile > index 1bbb47565c55..4665cdbf1a8d 100644 > --- a/tools/testing/selftests/gpio/Makefile > +++ b/tools/testing/selftests/gpio/Makefile > @@ -21,11 +21,8 @@ endef > CFLAGS += -O2 -g -std=gnu99 -Wall -I../../../../usr/include/ > LDLIBS += -lmount -I/usr/include/libmount > > -$(BINARIES): ../../../gpio/gpio-utils.o ../../../../usr/include/linux/gpio.h > +$(BINARIES):| khdr > +$(BINARIES): ../../../gpio/gpio-utils.o > > ../../../gpio/gpio-utils.o: > make ARCH=$(ARCH) CROSS_COMPILE=$(CROSS_COMPILE) -C ../../../gpio > - > -../../../../usr/include/linux/gpio.h: > - make -C ../../../.. headers_install INSTALL_HDR_PATH=$(shell pwd)/../../../../usr/ > - > diff --git a/tools/testing/selftests/kvm/Makefile b/tools/testing/selftests/kvm/Makefile > index d9d00319b07c..bcb69380bbab 100644 > --- a/tools/testing/selftests/kvm/Makefile > +++ b/tools/testing/selftests/kvm/Makefile > @@ -32,9 +32,6 @@ $(LIBKVM_OBJ): $(OUTPUT)/%.o: %.c > $(OUTPUT)/libkvm.a: $(LIBKVM_OBJ) > $(AR) crs $@ $^ > > -$(LINUX_HDR_PATH): > - make -C $(top_srcdir) headers_install > - > -all: $(STATIC_LIBS) $(LINUX_HDR_PATH) > +all: $(STATIC_LIBS) > $(TEST_GEN_PROGS): $(STATIC_LIBS) > -$(TEST_GEN_PROGS) $(LIBKVM_OBJ): | $(LINUX_HDR_PATH) > +$(STATIC_LIBS):| khdr > diff --git a/tools/testing/selftests/lib.mk b/tools/testing/selftests/lib.mk > index 17ab36605a8e..0a8e75886224 100644 > --- a/tools/testing/selftests/lib.mk > +++ b/tools/testing/selftests/lib.mk > @@ -16,8 +16,20 @@ TEST_GEN_PROGS := $(patsubst %,$(OUTPUT)/%,$(TEST_GEN_PROGS)) > TEST_GEN_PROGS_EXTENDED := $(patsubst %,$(OUTPUT)/%,$(TEST_GEN_PROGS_EXTENDED)) > TEST_GEN_FILES := $(patsubst %,$(OUTPUT)/%,$(TEST_GEN_FILES)) > > +top_srcdir ?= ../../../.. > +include $(top_srcdir)/scripts/subarch.include > +ARCH ?= $(SUBARCH) > + > all: $(TEST_GEN_PROGS) $(TEST_GEN_PROGS_EXTENDED) $(TEST_GEN_FILES) > > +.PHONY: khdr > +khdr: > + make ARCH=$(ARCH) -C $(top_srcdir) headers_install > + > +ifdef KSFT_KHDR_INSTALL > +$(TEST_GEN_PROGS) $(TEST_GEN_PROGS_EXTENDED) $(TEST_GEN_FILES):| khdr > +endif > + > .ONESHELL: > define RUN_TEST_PRINT_RESULT > TEST_HDR_MSG="selftests: "`basename $$PWD`:" $$BASENAME_TEST"; \ > diff --git a/tools/testing/selftests/net/Makefile b/tools/testing/selftests/net/Makefile > index 663e11e85727..d515dabc6b0d 100644 > --- a/tools/testing/selftests/net/Makefile > +++ b/tools/testing/selftests/net/Makefile > @@ -15,6 +15,7 @@ TEST_GEN_FILES += udpgso udpgso_bench_tx udpgso_bench_rx > TEST_GEN_PROGS = reuseport_bpf reuseport_bpf_cpu reuseport_bpf_numa > TEST_GEN_PROGS += reuseport_dualstack reuseaddr_conflict > > +KSFT_KHDR_INSTALL := 1 > include ../lib.mk > > $(OUTPUT)/reuseport_bpf_numa: LDFLAGS += -lnuma > diff --git a/tools/testing/selftests/networking/timestamping/Makefile b/tools/testing/selftests/networking/timestamping/Makefile > index a728040edbe1..14cfcf006936 100644 > --- a/tools/testing/selftests/networking/timestamping/Makefile > +++ b/tools/testing/selftests/networking/timestamping/Makefile > @@ -5,6 +5,7 @@ TEST_PROGS := hwtstamp_config rxtimestamp timestamping txtimestamp > > all: $(TEST_PROGS) > > +top_srcdir = ../../../../.. > include ../../lib.mk > > clean: > diff --git a/tools/testing/selftests/vm/Makefile b/tools/testing/selftests/vm/Makefile > index fdefa2295ddc..58759454b1d0 100644 > --- a/tools/testing/selftests/vm/Makefile > +++ b/tools/testing/selftests/vm/Makefile > @@ -25,10 +25,6 @@ TEST_PROGS := run_vmtests > > include ../lib.mk > > -$(OUTPUT)/userfaultfd: ../../../../usr/include/linux/kernel.h > $(OUTPUT)/userfaultfd: LDLIBS += -lpthread > > $(OUTPUT)/mlock-random-test: LDLIBS += -lcap > - > -../../../../usr/include/linux/kernel.h: > - make -C ../../../.. headers_install > -- > 2.17.1 > Ping. ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH v4] selftests: add headers_install to lib.mk 2018-07-23 20:49 ` Anders Roxell @ 2018-07-24 17:10 ` Shuah Khan 2018-07-25 16:08 ` Anders Roxell 0 siblings, 1 reply; 21+ messages in thread From: Shuah Khan @ 2018-07-24 17:10 UTC (permalink / raw) To: Anders Roxell, Masahiro Yamada, Michal Marek, Bamvor Zhang, brgl, Paolo Bonzini, Andrew Morton, Mike Rapoport, aarcange Cc: linux-kbuild, Linux Kernel Mailing List, open list:KERNEL SELFTEST FRAMEWORK, Networking, Shuah Khan On 07/23/2018 02:49 PM, Anders Roxell wrote: > On Thu, 7 Jun 2018 at 13:09, Anders Roxell <anders.roxell@linaro.org> wrote: >> >> If the kernel headers aren't installed we can't build all the tests. >> Add a new make target rule 'khdr' in the file lib.mk to generate the >> kernel headers and that gets include for every test-dir Makefile that >> includes lib.mk If the testdir in turn have its own sub-dirs the >> top_srcdir needs to be set to the linux-rootdir to be able to generate >> the kernel headers. >> >> Signed-off-by: Anders Roxell <anders.roxell@linaro.org> >> Reviewed-by: Fathi Boudra <fathi.boudra@linaro.org> >> --- >> Makefile | 14 +------------- >> scripts/subarch.include | 13 +++++++++++++ >> tools/testing/selftests/android/Makefile | 2 +- >> tools/testing/selftests/android/ion/Makefile | 2 ++ >> tools/testing/selftests/futex/functional/Makefile | 1 + >> tools/testing/selftests/gpio/Makefile | 7 ++----- >> tools/testing/selftests/kvm/Makefile | 7 ++----- >> tools/testing/selftests/lib.mk | 12 ++++++++++++ >> tools/testing/selftests/net/Makefile | 1 + >> .../selftests/networking/timestamping/Makefile | 1 + >> tools/testing/selftests/vm/Makefile | 4 ---- >> 11 files changed, 36 insertions(+), 28 deletions(-) >> create mode 100644 scripts/subarch.include >> >> diff --git a/Makefile b/Makefile >> index 6b9aea95ae3a..8050072300fa 100644 >> --- a/Makefile >> +++ b/Makefile >> @@ -286,19 +286,7 @@ KERNELRELEASE = $(shell cat include/config/kernel.release 2> /dev/null) >> KERNELVERSION = $(VERSION)$(if $(PATCHLEVEL),.$(PATCHLEVEL)$(if $(SUBLEVEL),.$(SUBLEVEL)))$(EXTRAVERSION) >> export VERSION PATCHLEVEL SUBLEVEL KERNELRELEASE KERNELVERSION >> >> -# SUBARCH tells the usermode build what the underlying arch is. That is set >> -# first, and if a usermode build is happening, the "ARCH=um" on the command >> -# line overrides the setting of ARCH below. If a native build is happening, >> -# then ARCH is assigned, getting whatever value it gets normally, and >> -# SUBARCH is subsequently ignored. >> - >> -SUBARCH := $(shell uname -m | sed -e s/i.86/x86/ -e s/x86_64/x86/ \ >> - -e s/sun4u/sparc64/ \ >> - -e s/arm.*/arm/ -e s/sa110/arm/ \ >> - -e s/s390x/s390/ -e s/parisc64/parisc/ \ >> - -e s/ppc.*/powerpc/ -e s/mips.*/mips/ \ >> - -e s/sh[234].*/sh/ -e s/aarch64.*/arm64/ \ >> - -e s/riscv.*/riscv/) >> +include scripts/subarch.include What is the reason for this SUBARCH block move to to scripts/subarch.include? Is this necessary for adding headers install dependency to lib.mk? >> >> # Cross compiling and selecting different set of gcc/bin-utils >> # --------------------------------------------------------------------------- >> diff --git a/scripts/subarch.include b/scripts/subarch.include >> new file mode 100644 >> index 000000000000..650682821126 >> --- /dev/null >> +++ b/scripts/subarch.include >> @@ -0,0 +1,13 @@ >> +# SUBARCH tells the usermode build what the underlying arch is. That is set >> +# first, and if a usermode build is happening, the "ARCH=um" on the command >> +# line overrides the setting of ARCH below. If a native build is happening, >> +# then ARCH is assigned, getting whatever value it gets normally, and >> +# SUBARCH is subsequently ignored. >> + >> +SUBARCH := $(shell uname -m | sed -e s/i.86/x86/ -e s/x86_64/x86/ \ >> + -e s/sun4u/sparc64/ \ >> + -e s/arm.*/arm/ -e s/sa110/arm/ \ >> + -e s/s390x/s390/ -e s/parisc64/parisc/ \ >> + -e s/ppc.*/powerpc/ -e s/mips.*/mips/ \ >> + -e s/sh[234].*/sh/ -e s/aarch64.*/arm64/ \ >> + -e s/riscv.*/riscv/) thanks, -- Shuah ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH v4] selftests: add headers_install to lib.mk 2018-07-24 17:10 ` Shuah Khan @ 2018-07-25 16:08 ` Anders Roxell 2018-08-06 17:03 ` Shuah Khan 0 siblings, 1 reply; 21+ messages in thread From: Anders Roxell @ 2018-07-25 16:08 UTC (permalink / raw) To: Shuah Khan Cc: Masahiro Yamada, Michal Marek, Bamvor Zhang, brgl, Paolo Bonzini, Andrew Morton, Mike Rapoport, aarcange, linux-kbuild, Linux Kernel Mailing List, open list:KERNEL SELFTEST FRAMEWORK, Networking On Tue, 24 Jul 2018 at 19:11, Shuah Khan <shuah@kernel.org> wrote: > > On 07/23/2018 02:49 PM, Anders Roxell wrote: > > On Thu, 7 Jun 2018 at 13:09, Anders Roxell <anders.roxell@linaro.org> wrote: > >> > >> If the kernel headers aren't installed we can't build all the tests. > >> Add a new make target rule 'khdr' in the file lib.mk to generate the > >> kernel headers and that gets include for every test-dir Makefile that > >> includes lib.mk If the testdir in turn have its own sub-dirs the > >> top_srcdir needs to be set to the linux-rootdir to be able to generate > >> the kernel headers. > >> > >> Signed-off-by: Anders Roxell <anders.roxell@linaro.org> > >> Reviewed-by: Fathi Boudra <fathi.boudra@linaro.org> > >> --- > >> Makefile | 14 +------------- > >> scripts/subarch.include | 13 +++++++++++++ > >> tools/testing/selftests/android/Makefile | 2 +- > >> tools/testing/selftests/android/ion/Makefile | 2 ++ > >> tools/testing/selftests/futex/functional/Makefile | 1 + > >> tools/testing/selftests/gpio/Makefile | 7 ++----- > >> tools/testing/selftests/kvm/Makefile | 7 ++----- > >> tools/testing/selftests/lib.mk | 12 ++++++++++++ > >> tools/testing/selftests/net/Makefile | 1 + > >> .../selftests/networking/timestamping/Makefile | 1 + > >> tools/testing/selftests/vm/Makefile | 4 ---- > >> 11 files changed, 36 insertions(+), 28 deletions(-) > >> create mode 100644 scripts/subarch.include > >> > >> diff --git a/Makefile b/Makefile > >> index 6b9aea95ae3a..8050072300fa 100644 > >> --- a/Makefile > >> +++ b/Makefile > >> @@ -286,19 +286,7 @@ KERNELRELEASE = $(shell cat include/config/kernel.release 2> /dev/null) > >> KERNELVERSION = $(VERSION)$(if $(PATCHLEVEL),.$(PATCHLEVEL)$(if $(SUBLEVEL),.$(SUBLEVEL)))$(EXTRAVERSION) > >> export VERSION PATCHLEVEL SUBLEVEL KERNELRELEASE KERNELVERSION > >> > >> -# SUBARCH tells the usermode build what the underlying arch is. That is set > >> -# first, and if a usermode build is happening, the "ARCH=um" on the command > >> -# line overrides the setting of ARCH below. If a native build is happening, > >> -# then ARCH is assigned, getting whatever value it gets normally, and > >> -# SUBARCH is subsequently ignored. > >> - > >> -SUBARCH := $(shell uname -m | sed -e s/i.86/x86/ -e s/x86_64/x86/ \ > >> - -e s/sun4u/sparc64/ \ > >> - -e s/arm.*/arm/ -e s/sa110/arm/ \ > >> - -e s/s390x/s390/ -e s/parisc64/parisc/ \ > >> - -e s/ppc.*/powerpc/ -e s/mips.*/mips/ \ > >> - -e s/sh[234].*/sh/ -e s/aarch64.*/arm64/ \ > >> - -e s/riscv.*/riscv/) > >> +include scripts/subarch.include > > What is the reason for this SUBARCH block move to to scripts/subarch.include? > Is this necessary for adding headers install dependency to lib.mk? This is needed to create headers for cross build. Cheers, Anders ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH v4] selftests: add headers_install to lib.mk 2018-07-25 16:08 ` Anders Roxell @ 2018-08-06 17:03 ` Shuah Khan 2018-08-07 2:32 ` Masahiro Yamada 2018-08-09 8:04 ` [PATCH v5] " Anders Roxell 0 siblings, 2 replies; 21+ messages in thread From: Shuah Khan @ 2018-08-06 17:03 UTC (permalink / raw) To: Anders Roxell Cc: Masahiro Yamada, Michal Marek, Bamvor Zhang, brgl, Paolo Bonzini, Andrew Morton, Mike Rapoport, aarcange, linux-kbuild, Linux Kernel Mailing List, open list:KERNEL SELFTEST FRAMEWORK, Networking, Shuah Khan Hi Anders, On 07/25/2018 10:08 AM, Anders Roxell wrote: > On Tue, 24 Jul 2018 at 19:11, Shuah Khan <shuah@kernel.org> wrote: >> >> On 07/23/2018 02:49 PM, Anders Roxell wrote: >>> On Thu, 7 Jun 2018 at 13:09, Anders Roxell <anders.roxell@linaro.org> wrote: >>>> >>>> If the kernel headers aren't installed we can't build all the tests. >>>> Add a new make target rule 'khdr' in the file lib.mk to generate the >>>> kernel headers and that gets include for every test-dir Makefile that >>>> includes lib.mk If the testdir in turn have its own sub-dirs the >>>> top_srcdir needs to be set to the linux-rootdir to be able to generate >>>> the kernel headers. >>>> >>>> Signed-off-by: Anders Roxell <anders.roxell@linaro.org> >>>> Reviewed-by: Fathi Boudra <fathi.boudra@linaro.org> >>>> --- >>>> Makefile | 14 +------------- >>>> scripts/subarch.include | 13 +++++++++++++ >>>> tools/testing/selftests/android/Makefile | 2 +- >>>> tools/testing/selftests/android/ion/Makefile | 2 ++ >>>> tools/testing/selftests/futex/functional/Makefile | 1 + >>>> tools/testing/selftests/gpio/Makefile | 7 ++----- >>>> tools/testing/selftests/kvm/Makefile | 7 ++----- >>>> tools/testing/selftests/lib.mk | 12 ++++++++++++ >>>> tools/testing/selftests/net/Makefile | 1 + >>>> .../selftests/networking/timestamping/Makefile | 1 + >>>> tools/testing/selftests/vm/Makefile | 4 ---- >>>> 11 files changed, 36 insertions(+), 28 deletions(-) >>>> create mode 100644 scripts/subarch.include >>>> >>>> diff --git a/Makefile b/Makefile >>>> index 6b9aea95ae3a..8050072300fa 100644 >>>> --- a/Makefile >>>> +++ b/Makefile >>>> @@ -286,19 +286,7 @@ KERNELRELEASE = $(shell cat include/config/kernel.release 2> /dev/null) >>>> KERNELVERSION = $(VERSION)$(if $(PATCHLEVEL),.$(PATCHLEVEL)$(if $(SUBLEVEL),.$(SUBLEVEL)))$(EXTRAVERSION) >>>> export VERSION PATCHLEVEL SUBLEVEL KERNELRELEASE KERNELVERSION >>>> >>>> -# SUBARCH tells the usermode build what the underlying arch is. That is set >>>> -# first, and if a usermode build is happening, the "ARCH=um" on the command >>>> -# line overrides the setting of ARCH below. If a native build is happening, >>>> -# then ARCH is assigned, getting whatever value it gets normally, and >>>> -# SUBARCH is subsequently ignored. >>>> - >>>> -SUBARCH := $(shell uname -m | sed -e s/i.86/x86/ -e s/x86_64/x86/ \ >>>> - -e s/sun4u/sparc64/ \ >>>> - -e s/arm.*/arm/ -e s/sa110/arm/ \ >>>> - -e s/s390x/s390/ -e s/parisc64/parisc/ \ >>>> - -e s/ppc.*/powerpc/ -e s/mips.*/mips/ \ >>>> - -e s/sh[234].*/sh/ -e s/aarch64.*/arm64/ \ >>>> - -e s/riscv.*/riscv/) >>>> +include scripts/subarch.include >> >> What is the reason for this SUBARCH block move to to scripts/subarch.include? >> Is this necessary for adding headers install dependency to lib.mk? > > This is needed to create headers for cross build. > I am sorry for the delay on this patch. I am going to get this into 4.19. If anybody has objections, please let me. Anders! Will be able to rebase the patch and send me the latest. I think I have Acks from kvm, android, and vm so far. thanks, -- Shuah ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH v4] selftests: add headers_install to lib.mk 2018-08-06 17:03 ` Shuah Khan @ 2018-08-07 2:32 ` Masahiro Yamada 2018-08-08 10:44 ` Anders Roxell 2018-08-09 8:04 ` [PATCH v5] " Anders Roxell 1 sibling, 1 reply; 21+ messages in thread From: Masahiro Yamada @ 2018-08-07 2:32 UTC (permalink / raw) To: Shuah Khan Cc: Anders Roxell, Michal Marek, Bamvor Zhang, brgl, Paolo Bonzini, Andrew Morton, Mike Rapoport, Andrea Arcangeli, Linux Kbuild mailing list, Linux Kernel Mailing List, open list:KERNEL SELFTEST FRAMEWORK, Networking 2018-08-07 2:03 GMT+09:00 Shuah Khan <shuah@kernel.org>: > Hi Anders, > > On 07/25/2018 10:08 AM, Anders Roxell wrote: >> On Tue, 24 Jul 2018 at 19:11, Shuah Khan <shuah@kernel.org> wrote: >>> >>> On 07/23/2018 02:49 PM, Anders Roxell wrote: >>>> On Thu, 7 Jun 2018 at 13:09, Anders Roxell <anders.roxell@linaro.org> wrote: >>>>> >>>>> If the kernel headers aren't installed we can't build all the tests. >>>>> Add a new make target rule 'khdr' in the file lib.mk to generate the >>>>> kernel headers and that gets include for every test-dir Makefile that >>>>> includes lib.mk If the testdir in turn have its own sub-dirs the >>>>> top_srcdir needs to be set to the linux-rootdir to be able to generate >>>>> the kernel headers. >>>>> >>>>> Signed-off-by: Anders Roxell <anders.roxell@linaro.org> >>>>> Reviewed-by: Fathi Boudra <fathi.boudra@linaro.org> >>>>> --- >>>>> Makefile | 14 +------------- >>>>> scripts/subarch.include | 13 +++++++++++++ >>>>> tools/testing/selftests/android/Makefile | 2 +- >>>>> tools/testing/selftests/android/ion/Makefile | 2 ++ >>>>> tools/testing/selftests/futex/functional/Makefile | 1 + >>>>> tools/testing/selftests/gpio/Makefile | 7 ++----- >>>>> tools/testing/selftests/kvm/Makefile | 7 ++----- >>>>> tools/testing/selftests/lib.mk | 12 ++++++++++++ >>>>> tools/testing/selftests/net/Makefile | 1 + >>>>> .../selftests/networking/timestamping/Makefile | 1 + >>>>> tools/testing/selftests/vm/Makefile | 4 ---- >>>>> 11 files changed, 36 insertions(+), 28 deletions(-) >>>>> create mode 100644 scripts/subarch.include >>>>> >>>>> diff --git a/Makefile b/Makefile >>>>> index 6b9aea95ae3a..8050072300fa 100644 >>>>> --- a/Makefile >>>>> +++ b/Makefile >>>>> @@ -286,19 +286,7 @@ KERNELRELEASE = $(shell cat include/config/kernel.release 2> /dev/null) >>>>> KERNELVERSION = $(VERSION)$(if $(PATCHLEVEL),.$(PATCHLEVEL)$(if $(SUBLEVEL),.$(SUBLEVEL)))$(EXTRAVERSION) >>>>> export VERSION PATCHLEVEL SUBLEVEL KERNELRELEASE KERNELVERSION >>>>> >>>>> -# SUBARCH tells the usermode build what the underlying arch is. That is set >>>>> -# first, and if a usermode build is happening, the "ARCH=um" on the command >>>>> -# line overrides the setting of ARCH below. If a native build is happening, >>>>> -# then ARCH is assigned, getting whatever value it gets normally, and >>>>> -# SUBARCH is subsequently ignored. >>>>> - >>>>> -SUBARCH := $(shell uname -m | sed -e s/i.86/x86/ -e s/x86_64/x86/ \ >>>>> - -e s/sun4u/sparc64/ \ >>>>> - -e s/arm.*/arm/ -e s/sa110/arm/ \ >>>>> - -e s/s390x/s390/ -e s/parisc64/parisc/ \ >>>>> - -e s/ppc.*/powerpc/ -e s/mips.*/mips/ \ >>>>> - -e s/sh[234].*/sh/ -e s/aarch64.*/arm64/ \ >>>>> - -e s/riscv.*/riscv/) >>>>> +include scripts/subarch.include >>> >>> What is the reason for this SUBARCH block move to to scripts/subarch.include? >>> Is this necessary for adding headers install dependency to lib.mk? >> >> This is needed to create headers for cross build. >> > > I am sorry for the delay on this patch. I am going to get this into 4.19. > If anybody has objections, please let me. > > Anders! Will be able to rebase the patch and send me the latest. I think > I have Acks from kvm, android, and vm so far. > I may be missing something about the tools/ directory, but why isn't it like this? kselftest: headers_install $(Q)$(MAKE) -C $(srctree)/tools/testing/selftests run_tests -- Best Regards Masahiro Yamada ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH v4] selftests: add headers_install to lib.mk 2018-08-07 2:32 ` Masahiro Yamada @ 2018-08-08 10:44 ` Anders Roxell 2019-01-04 13:15 ` Geert Uytterhoeven 0 siblings, 1 reply; 21+ messages in thread From: Anders Roxell @ 2018-08-08 10:44 UTC (permalink / raw) To: Masahiro Yamada Cc: Shuah Khan, Michal Marek, Bamvor Zhang, brgl, Paolo Bonzini, Andrew Morton, Mike Rapoport, aarcange, linux-kbuild, Linux Kernel Mailing List, open list:KERNEL SELFTEST FRAMEWORK, Networking On Tue, 7 Aug 2018 at 04:33, Masahiro Yamada <yamada.masahiro@socionext.com> wrote: > > 2018-08-07 2:03 GMT+09:00 Shuah Khan <shuah@kernel.org>: > > Hi Anders, > > > > On 07/25/2018 10:08 AM, Anders Roxell wrote: > >> On Tue, 24 Jul 2018 at 19:11, Shuah Khan <shuah@kernel.org> wrote: > >>> > >>> On 07/23/2018 02:49 PM, Anders Roxell wrote: > >>>> On Thu, 7 Jun 2018 at 13:09, Anders Roxell <anders.roxell@linaro.org> wrote: > >>>>> > >>>>> If the kernel headers aren't installed we can't build all the tests. > >>>>> Add a new make target rule 'khdr' in the file lib.mk to generate the > >>>>> kernel headers and that gets include for every test-dir Makefile that > >>>>> includes lib.mk If the testdir in turn have its own sub-dirs the > >>>>> top_srcdir needs to be set to the linux-rootdir to be able to generate > >>>>> the kernel headers. > >>>>> > >>>>> Signed-off-by: Anders Roxell <anders.roxell@linaro.org> > >>>>> Reviewed-by: Fathi Boudra <fathi.boudra@linaro.org> > >>>>> --- > >>>>> Makefile | 14 +------------- > >>>>> scripts/subarch.include | 13 +++++++++++++ > >>>>> tools/testing/selftests/android/Makefile | 2 +- > >>>>> tools/testing/selftests/android/ion/Makefile | 2 ++ > >>>>> tools/testing/selftests/futex/functional/Makefile | 1 + > >>>>> tools/testing/selftests/gpio/Makefile | 7 ++----- > >>>>> tools/testing/selftests/kvm/Makefile | 7 ++----- > >>>>> tools/testing/selftests/lib.mk | 12 ++++++++++++ > >>>>> tools/testing/selftests/net/Makefile | 1 + > >>>>> .../selftests/networking/timestamping/Makefile | 1 + > >>>>> tools/testing/selftests/vm/Makefile | 4 ---- > >>>>> 11 files changed, 36 insertions(+), 28 deletions(-) > >>>>> create mode 100644 scripts/subarch.include > >>>>> > >>>>> diff --git a/Makefile b/Makefile > >>>>> index 6b9aea95ae3a..8050072300fa 100644 > >>>>> --- a/Makefile > >>>>> +++ b/Makefile > >>>>> @@ -286,19 +286,7 @@ KERNELRELEASE = $(shell cat include/config/kernel.release 2> /dev/null) > >>>>> KERNELVERSION = $(VERSION)$(if $(PATCHLEVEL),.$(PATCHLEVEL)$(if $(SUBLEVEL),.$(SUBLEVEL)))$(EXTRAVERSION) > >>>>> export VERSION PATCHLEVEL SUBLEVEL KERNELRELEASE KERNELVERSION > >>>>> > >>>>> -# SUBARCH tells the usermode build what the underlying arch is. That is set > >>>>> -# first, and if a usermode build is happening, the "ARCH=um" on the command > >>>>> -# line overrides the setting of ARCH below. If a native build is happening, > >>>>> -# then ARCH is assigned, getting whatever value it gets normally, and > >>>>> -# SUBARCH is subsequently ignored. > >>>>> - > >>>>> -SUBARCH := $(shell uname -m | sed -e s/i.86/x86/ -e s/x86_64/x86/ \ > >>>>> - -e s/sun4u/sparc64/ \ > >>>>> - -e s/arm.*/arm/ -e s/sa110/arm/ \ > >>>>> - -e s/s390x/s390/ -e s/parisc64/parisc/ \ > >>>>> - -e s/ppc.*/powerpc/ -e s/mips.*/mips/ \ > >>>>> - -e s/sh[234].*/sh/ -e s/aarch64.*/arm64/ \ > >>>>> - -e s/riscv.*/riscv/) > >>>>> +include scripts/subarch.include > >>> > >>> What is the reason for this SUBARCH block move to to scripts/subarch.include? > >>> Is this necessary for adding headers install dependency to lib.mk? > >> > >> This is needed to create headers for cross build. > >> > > > > I am sorry for the delay on this patch. I am going to get this into 4.19. > > If anybody has objections, please let me. > > > > Anders! Will be able to rebase the patch and send me the latest. I think > > I have Acks from kvm, android, and vm so far. > > > > > I may be missing something about the tools/ directory, > but why isn't it like this? > > > kselftest: headers_install > $(Q)$(MAKE) -C $(srctree)/tools/testing/selftests run_tests That wont work if you cross compile, since you wont run the tests where you build them. Then you can argue that we should break it up in a build and run rule. However, my understanding how people just build and run the the tests for that particular subsystem that they develop for, like: make -C tools/testing/selftests/<subsystem>/ Cheers, Anders ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH v4] selftests: add headers_install to lib.mk 2018-08-08 10:44 ` Anders Roxell @ 2019-01-04 13:15 ` Geert Uytterhoeven 0 siblings, 0 replies; 21+ messages in thread From: Geert Uytterhoeven @ 2019-01-04 13:15 UTC (permalink / raw) To: Anders Roxell Cc: Masahiro Yamada, Shuah Khan, Michal Marek, Bamvor Zhang, Bartosz Golaszewski, Paolo Bonzini, Andrew Morton, Mike Rapoport, Andrea Arcangeli, linux-kbuild, Linux Kernel Mailing List, open list:KERNEL SELFTEST FRAMEWORK, Networking Hi Anders, On Wed, Aug 8, 2018 at 12:46 PM Anders Roxell <anders.roxell@linaro.org> wrote: > On Tue, 7 Aug 2018 at 04:33, Masahiro Yamada > <yamada.masahiro@socionext.com> wrote: > > 2018-08-07 2:03 GMT+09:00 Shuah Khan <shuah@kernel.org>: > > > On 07/25/2018 10:08 AM, Anders Roxell wrote: > > >> On Tue, 24 Jul 2018 at 19:11, Shuah Khan <shuah@kernel.org> wrote: > > >>> On 07/23/2018 02:49 PM, Anders Roxell wrote: > > >>>> On Thu, 7 Jun 2018 at 13:09, Anders Roxell <anders.roxell@linaro.org> wrote: > > >>>>> > > >>>>> If the kernel headers aren't installed we can't build all the tests. > > >>>>> Add a new make target rule 'khdr' in the file lib.mk to generate the > > >>>>> kernel headers and that gets include for every test-dir Makefile that > > >>>>> includes lib.mk If the testdir in turn have its own sub-dirs the > > >>>>> top_srcdir needs to be set to the linux-rootdir to be able to generate > > >>>>> the kernel headers. > > >>>>> > > >>>>> Signed-off-by: Anders Roxell <anders.roxell@linaro.org> > > >>>>> Reviewed-by: Fathi Boudra <fathi.boudra@linaro.org> > > >>>>> --- > > >>>>> Makefile | 14 +------------- > > >>>>> scripts/subarch.include | 13 +++++++++++++ > > >>>>> tools/testing/selftests/android/Makefile | 2 +- > > >>>>> tools/testing/selftests/android/ion/Makefile | 2 ++ > > >>>>> tools/testing/selftests/futex/functional/Makefile | 1 + > > >>>>> tools/testing/selftests/gpio/Makefile | 7 ++----- > > >>>>> tools/testing/selftests/kvm/Makefile | 7 ++----- > > >>>>> tools/testing/selftests/lib.mk | 12 ++++++++++++ > > >>>>> tools/testing/selftests/net/Makefile | 1 + > > >>>>> .../selftests/networking/timestamping/Makefile | 1 + > > >>>>> tools/testing/selftests/vm/Makefile | 4 ---- > > >>>>> 11 files changed, 36 insertions(+), 28 deletions(-) > > >>>>> create mode 100644 scripts/subarch.include > > >>>>> > > >>>>> diff --git a/Makefile b/Makefile > > >>>>> index 6b9aea95ae3a..8050072300fa 100644 > > >>>>> --- a/Makefile > > >>>>> +++ b/Makefile > > >>>>> @@ -286,19 +286,7 @@ KERNELRELEASE = $(shell cat include/config/kernel.release 2> /dev/null) > > >>>>> KERNELVERSION = $(VERSION)$(if $(PATCHLEVEL),.$(PATCHLEVEL)$(if $(SUBLEVEL),.$(SUBLEVEL)))$(EXTRAVERSION) > > >>>>> export VERSION PATCHLEVEL SUBLEVEL KERNELRELEASE KERNELVERSION > > >>>>> > > >>>>> -# SUBARCH tells the usermode build what the underlying arch is. That is set > > >>>>> -# first, and if a usermode build is happening, the "ARCH=um" on the command > > >>>>> -# line overrides the setting of ARCH below. If a native build is happening, > > >>>>> -# then ARCH is assigned, getting whatever value it gets normally, and > > >>>>> -# SUBARCH is subsequently ignored. > > >>>>> - > > >>>>> -SUBARCH := $(shell uname -m | sed -e s/i.86/x86/ -e s/x86_64/x86/ \ > > >>>>> - -e s/sun4u/sparc64/ \ > > >>>>> - -e s/arm.*/arm/ -e s/sa110/arm/ \ > > >>>>> - -e s/s390x/s390/ -e s/parisc64/parisc/ \ > > >>>>> - -e s/ppc.*/powerpc/ -e s/mips.*/mips/ \ > > >>>>> - -e s/sh[234].*/sh/ -e s/aarch64.*/arm64/ \ > > >>>>> - -e s/riscv.*/riscv/) > > >>>>> +include scripts/subarch.include > > >>> > > >>> What is the reason for this SUBARCH block move to to scripts/subarch.include? > > >>> Is this necessary for adding headers install dependency to lib.mk? > > >> > > >> This is needed to create headers for cross build. > > > > > > I am sorry for the delay on this patch. I am going to get this into 4.19. > > > If anybody has objections, please let me. > > > > > > Anders! Will be able to rebase the patch and send me the latest. I think > > > I have Acks from kvm, android, and vm so far. > > > > I may be missing something about the tools/ directory, > > but why isn't it like this? > > > > > > kselftest: headers_install > > $(Q)$(MAKE) -C $(srctree)/tools/testing/selftests run_tests > > That wont work if you cross compile, since you wont run the tests > where you build them. So why does a similar dependency work for samples in the main Makefile (even listed twice!)? Documentation/ samples/: headers_install samples: headers_install Or perhaps this also doesn't work? > Then you can argue that we should break it up in a build and run rule. > However, my understanding how people just build and run the the tests > for that particular subsystem that they develop for, like: > make -C tools/testing/selftests/<subsystem>/ I'm still a bit puzzled: how can you "build and run" the tests when cross-compiling, as you don't run the tests where you build them? Thanks! Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds ^ permalink raw reply [flat|nested] 21+ messages in thread
* [PATCH v5] selftests: add headers_install to lib.mk 2018-08-06 17:03 ` Shuah Khan 2018-08-07 2:32 ` Masahiro Yamada @ 2018-08-09 8:04 ` Anders Roxell 2018-09-04 10:47 ` [PATCH v6] " Anders Roxell 1 sibling, 1 reply; 21+ messages in thread From: Anders Roxell @ 2018-08-09 8:04 UTC (permalink / raw) To: yamada.masahiro, michal.lkml, shuah, bamv2005, brgl, pbonzini, akpm, rppt, aarcange Cc: linux-kbuild, linux-kernel, linux-kselftest, netdev, Anders Roxell If the kernel headers aren't installed we can't build all the tests. Add a new make target rule 'khdr' in the file lib.mk to generate the kernel headers and that gets include for every test-dir Makefile that includes lib.mk If the testdir in turn have its own sub-dirs the top_srcdir needs to be set to the linux-rootdir to be able to generate the kernel headers. Signed-off-by: Anders Roxell <anders.roxell@linaro.org> Reviewed-by: Fathi Boudra <fathi.boudra@linaro.org> --- Rebased onto next-20180808 Cheers, Anders Makefile | 14 +------------- scripts/subarch.include | 13 +++++++++++++ tools/testing/selftests/android/Makefile | 2 +- tools/testing/selftests/android/ion/Makefile | 2 ++ tools/testing/selftests/futex/functional/Makefile | 1 + tools/testing/selftests/gpio/Makefile | 7 ++----- tools/testing/selftests/kvm/Makefile | 7 ++----- tools/testing/selftests/lib.mk | 12 ++++++++++++ tools/testing/selftests/net/Makefile | 1 + .../selftests/networking/timestamping/Makefile | 1 + tools/testing/selftests/vm/Makefile | 4 ---- 11 files changed, 36 insertions(+), 28 deletions(-) create mode 100644 scripts/subarch.include diff --git a/Makefile b/Makefile index c88d56de7fda..49dc0c6e1f23 100644 --- a/Makefile +++ b/Makefile @@ -299,19 +299,7 @@ KERNELRELEASE = $(shell cat include/config/kernel.release 2> /dev/null) KERNELVERSION = $(VERSION)$(if $(PATCHLEVEL),.$(PATCHLEVEL)$(if $(SUBLEVEL),.$(SUBLEVEL)))$(EXTRAVERSION) export VERSION PATCHLEVEL SUBLEVEL KERNELRELEASE KERNELVERSION -# SUBARCH tells the usermode build what the underlying arch is. That is set -# first, and if a usermode build is happening, the "ARCH=um" on the command -# line overrides the setting of ARCH below. If a native build is happening, -# then ARCH is assigned, getting whatever value it gets normally, and -# SUBARCH is subsequently ignored. - -SUBARCH := $(shell uname -m | sed -e s/i.86/x86/ -e s/x86_64/x86/ \ - -e s/sun4u/sparc64/ \ - -e s/arm.*/arm/ -e s/sa110/arm/ \ - -e s/s390x/s390/ -e s/parisc64/parisc/ \ - -e s/ppc.*/powerpc/ -e s/mips.*/mips/ \ - -e s/sh[234].*/sh/ -e s/aarch64.*/arm64/ \ - -e s/riscv.*/riscv/) +include scripts/subarch.include # Cross compiling and selecting different set of gcc/bin-utils # --------------------------------------------------------------------------- diff --git a/scripts/subarch.include b/scripts/subarch.include new file mode 100644 index 000000000000..650682821126 --- /dev/null +++ b/scripts/subarch.include @@ -0,0 +1,13 @@ +# SUBARCH tells the usermode build what the underlying arch is. That is set +# first, and if a usermode build is happening, the "ARCH=um" on the command +# line overrides the setting of ARCH below. If a native build is happening, +# then ARCH is assigned, getting whatever value it gets normally, and +# SUBARCH is subsequently ignored. + +SUBARCH := $(shell uname -m | sed -e s/i.86/x86/ -e s/x86_64/x86/ \ + -e s/sun4u/sparc64/ \ + -e s/arm.*/arm/ -e s/sa110/arm/ \ + -e s/s390x/s390/ -e s/parisc64/parisc/ \ + -e s/ppc.*/powerpc/ -e s/mips.*/mips/ \ + -e s/sh[234].*/sh/ -e s/aarch64.*/arm64/ \ + -e s/riscv.*/riscv/) diff --git a/tools/testing/selftests/android/Makefile b/tools/testing/selftests/android/Makefile index 72c25a3cb658..d9a725478375 100644 --- a/tools/testing/selftests/android/Makefile +++ b/tools/testing/selftests/android/Makefile @@ -6,7 +6,7 @@ TEST_PROGS := run.sh include ../lib.mk -all: +all: khdr @for DIR in $(SUBDIRS); do \ BUILD_TARGET=$(OUTPUT)/$$DIR; \ mkdir $$BUILD_TARGET -p; \ diff --git a/tools/testing/selftests/android/ion/Makefile b/tools/testing/selftests/android/ion/Makefile index e03695287f76..88cfe88e466f 100644 --- a/tools/testing/selftests/android/ion/Makefile +++ b/tools/testing/selftests/android/ion/Makefile @@ -10,6 +10,8 @@ $(TEST_GEN_FILES): ipcsocket.c ionutils.c TEST_PROGS := ion_test.sh +KSFT_KHDR_INSTALL := 1 +top_srcdir = ../../../../.. include ../../lib.mk $(OUTPUT)/ionapp_export: ionapp_export.c ipcsocket.c ionutils.c diff --git a/tools/testing/selftests/futex/functional/Makefile b/tools/testing/selftests/futex/functional/Makefile index ff8feca49746..ad1eeb14fda7 100644 --- a/tools/testing/selftests/futex/functional/Makefile +++ b/tools/testing/selftests/futex/functional/Makefile @@ -18,6 +18,7 @@ TEST_GEN_FILES := \ TEST_PROGS := run.sh +top_srcdir = ../../../../.. include ../../lib.mk $(TEST_GEN_FILES): $(HEADERS) diff --git a/tools/testing/selftests/gpio/Makefile b/tools/testing/selftests/gpio/Makefile index 1bbb47565c55..4665cdbf1a8d 100644 --- a/tools/testing/selftests/gpio/Makefile +++ b/tools/testing/selftests/gpio/Makefile @@ -21,11 +21,8 @@ endef CFLAGS += -O2 -g -std=gnu99 -Wall -I../../../../usr/include/ LDLIBS += -lmount -I/usr/include/libmount -$(BINARIES): ../../../gpio/gpio-utils.o ../../../../usr/include/linux/gpio.h +$(BINARIES):| khdr +$(BINARIES): ../../../gpio/gpio-utils.o ../../../gpio/gpio-utils.o: make ARCH=$(ARCH) CROSS_COMPILE=$(CROSS_COMPILE) -C ../../../gpio - -../../../../usr/include/linux/gpio.h: - make -C ../../../.. headers_install INSTALL_HDR_PATH=$(shell pwd)/../../../../usr/ - diff --git a/tools/testing/selftests/kvm/Makefile b/tools/testing/selftests/kvm/Makefile index dd0e5163f01f..34d492b77a7c 100644 --- a/tools/testing/selftests/kvm/Makefile +++ b/tools/testing/selftests/kvm/Makefile @@ -34,9 +34,6 @@ $(LIBKVM_OBJ): $(OUTPUT)/%.o: %.c $(OUTPUT)/libkvm.a: $(LIBKVM_OBJ) $(AR) crs $@ $^ -$(LINUX_HDR_PATH): - make -C $(top_srcdir) headers_install - -all: $(STATIC_LIBS) $(LINUX_HDR_PATH) +all: $(STATIC_LIBS) $(TEST_GEN_PROGS): $(STATIC_LIBS) -$(TEST_GEN_PROGS) $(LIBKVM_OBJ): | $(LINUX_HDR_PATH) +$(STATIC_LIBS):| khdr diff --git a/tools/testing/selftests/lib.mk b/tools/testing/selftests/lib.mk index 17ab36605a8e..0a8e75886224 100644 --- a/tools/testing/selftests/lib.mk +++ b/tools/testing/selftests/lib.mk @@ -16,8 +16,20 @@ TEST_GEN_PROGS := $(patsubst %,$(OUTPUT)/%,$(TEST_GEN_PROGS)) TEST_GEN_PROGS_EXTENDED := $(patsubst %,$(OUTPUT)/%,$(TEST_GEN_PROGS_EXTENDED)) TEST_GEN_FILES := $(patsubst %,$(OUTPUT)/%,$(TEST_GEN_FILES)) +top_srcdir ?= ../../../.. +include $(top_srcdir)/scripts/subarch.include +ARCH ?= $(SUBARCH) + all: $(TEST_GEN_PROGS) $(TEST_GEN_PROGS_EXTENDED) $(TEST_GEN_FILES) +.PHONY: khdr +khdr: + make ARCH=$(ARCH) -C $(top_srcdir) headers_install + +ifdef KSFT_KHDR_INSTALL +$(TEST_GEN_PROGS) $(TEST_GEN_PROGS_EXTENDED) $(TEST_GEN_FILES):| khdr +endif + .ONESHELL: define RUN_TEST_PRINT_RESULT TEST_HDR_MSG="selftests: "`basename $$PWD`:" $$BASENAME_TEST"; \ diff --git a/tools/testing/selftests/net/Makefile b/tools/testing/selftests/net/Makefile index 9cca68e440a0..919aa2ac00af 100644 --- a/tools/testing/selftests/net/Makefile +++ b/tools/testing/selftests/net/Makefile @@ -15,6 +15,7 @@ TEST_GEN_FILES += udpgso udpgso_bench_tx udpgso_bench_rx TEST_GEN_PROGS = reuseport_bpf reuseport_bpf_cpu reuseport_bpf_numa TEST_GEN_PROGS += reuseport_dualstack reuseaddr_conflict tls +KSFT_KHDR_INSTALL := 1 include ../lib.mk $(OUTPUT)/reuseport_bpf_numa: LDFLAGS += -lnuma diff --git a/tools/testing/selftests/networking/timestamping/Makefile b/tools/testing/selftests/networking/timestamping/Makefile index a728040edbe1..14cfcf006936 100644 --- a/tools/testing/selftests/networking/timestamping/Makefile +++ b/tools/testing/selftests/networking/timestamping/Makefile @@ -5,6 +5,7 @@ TEST_PROGS := hwtstamp_config rxtimestamp timestamping txtimestamp all: $(TEST_PROGS) +top_srcdir = ../../../../.. include ../../lib.mk clean: diff --git a/tools/testing/selftests/vm/Makefile b/tools/testing/selftests/vm/Makefile index 9881876d2aa0..e94b7b14bcb2 100644 --- a/tools/testing/selftests/vm/Makefile +++ b/tools/testing/selftests/vm/Makefile @@ -26,10 +26,6 @@ TEST_PROGS := run_vmtests include ../lib.mk -$(OUTPUT)/userfaultfd: ../../../../usr/include/linux/kernel.h $(OUTPUT)/userfaultfd: LDLIBS += -lpthread $(OUTPUT)/mlock-random-test: LDLIBS += -lcap - -../../../../usr/include/linux/kernel.h: - make -C ../../../.. headers_install -- 2.18.0 ^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH v6] selftests: add headers_install to lib.mk 2018-08-09 8:04 ` [PATCH v5] " Anders Roxell @ 2018-09-04 10:47 ` Anders Roxell 2018-09-05 14:13 ` Shuah Khan 2018-09-28 4:52 ` Michael Ellerman 0 siblings, 2 replies; 21+ messages in thread From: Anders Roxell @ 2018-09-04 10:47 UTC (permalink / raw) To: yamada.masahiro, michal.lkml, shuah, bamv2005, brgl, pbonzini, akpm, rppt, aarcange Cc: linux-kbuild, linux-kernel, linux-kselftest, netdev, Anders Roxell If the kernel headers aren't installed we can't build all the tests. Add a new make target rule 'khdr' in the file lib.mk to generate the kernel headers and that gets include for every test-dir Makefile that includes lib.mk If the testdir in turn have its own sub-dirs the top_srcdir needs to be set to the linux-rootdir to be able to generate the kernel headers. Signed-off-by: Anders Roxell <anders.roxell@linaro.org> Reviewed-by: Fathi Boudra <fathi.boudra@linaro.org> --- I sent this (v5) a month ago and wondered if it got lost. Resending unchanged. Cheers, Anders Makefile | 14 +------------- scripts/subarch.include | 13 +++++++++++++ tools/testing/selftests/android/Makefile | 2 +- tools/testing/selftests/android/ion/Makefile | 2 ++ tools/testing/selftests/futex/functional/Makefile | 1 + tools/testing/selftests/gpio/Makefile | 7 ++----- tools/testing/selftests/kvm/Makefile | 7 ++----- tools/testing/selftests/lib.mk | 12 ++++++++++++ tools/testing/selftests/net/Makefile | 1 + .../selftests/networking/timestamping/Makefile | 1 + tools/testing/selftests/vm/Makefile | 4 ---- 11 files changed, 36 insertions(+), 28 deletions(-) create mode 100644 scripts/subarch.include diff --git a/Makefile b/Makefile index 19948e556941..9c781e77fa24 100644 --- a/Makefile +++ b/Makefile @@ -299,19 +299,7 @@ KERNELRELEASE = $(shell cat include/config/kernel.release 2> /dev/null) KERNELVERSION = $(VERSION)$(if $(PATCHLEVEL),.$(PATCHLEVEL)$(if $(SUBLEVEL),.$(SUBLEVEL)))$(EXTRAVERSION) export VERSION PATCHLEVEL SUBLEVEL KERNELRELEASE KERNELVERSION -# SUBARCH tells the usermode build what the underlying arch is. That is set -# first, and if a usermode build is happening, the "ARCH=um" on the command -# line overrides the setting of ARCH below. If a native build is happening, -# then ARCH is assigned, getting whatever value it gets normally, and -# SUBARCH is subsequently ignored. - -SUBARCH := $(shell uname -m | sed -e s/i.86/x86/ -e s/x86_64/x86/ \ - -e s/sun4u/sparc64/ \ - -e s/arm.*/arm/ -e s/sa110/arm/ \ - -e s/s390x/s390/ -e s/parisc64/parisc/ \ - -e s/ppc.*/powerpc/ -e s/mips.*/mips/ \ - -e s/sh[234].*/sh/ -e s/aarch64.*/arm64/ \ - -e s/riscv.*/riscv/) +include scripts/subarch.include # Cross compiling and selecting different set of gcc/bin-utils # --------------------------------------------------------------------------- diff --git a/scripts/subarch.include b/scripts/subarch.include new file mode 100644 index 000000000000..650682821126 --- /dev/null +++ b/scripts/subarch.include @@ -0,0 +1,13 @@ +# SUBARCH tells the usermode build what the underlying arch is. That is set +# first, and if a usermode build is happening, the "ARCH=um" on the command +# line overrides the setting of ARCH below. If a native build is happening, +# then ARCH is assigned, getting whatever value it gets normally, and +# SUBARCH is subsequently ignored. + +SUBARCH := $(shell uname -m | sed -e s/i.86/x86/ -e s/x86_64/x86/ \ + -e s/sun4u/sparc64/ \ + -e s/arm.*/arm/ -e s/sa110/arm/ \ + -e s/s390x/s390/ -e s/parisc64/parisc/ \ + -e s/ppc.*/powerpc/ -e s/mips.*/mips/ \ + -e s/sh[234].*/sh/ -e s/aarch64.*/arm64/ \ + -e s/riscv.*/riscv/) diff --git a/tools/testing/selftests/android/Makefile b/tools/testing/selftests/android/Makefile index 72c25a3cb658..d9a725478375 100644 --- a/tools/testing/selftests/android/Makefile +++ b/tools/testing/selftests/android/Makefile @@ -6,7 +6,7 @@ TEST_PROGS := run.sh include ../lib.mk -all: +all: khdr @for DIR in $(SUBDIRS); do \ BUILD_TARGET=$(OUTPUT)/$$DIR; \ mkdir $$BUILD_TARGET -p; \ diff --git a/tools/testing/selftests/android/ion/Makefile b/tools/testing/selftests/android/ion/Makefile index e03695287f76..88cfe88e466f 100644 --- a/tools/testing/selftests/android/ion/Makefile +++ b/tools/testing/selftests/android/ion/Makefile @@ -10,6 +10,8 @@ $(TEST_GEN_FILES): ipcsocket.c ionutils.c TEST_PROGS := ion_test.sh +KSFT_KHDR_INSTALL := 1 +top_srcdir = ../../../../.. include ../../lib.mk $(OUTPUT)/ionapp_export: ionapp_export.c ipcsocket.c ionutils.c diff --git a/tools/testing/selftests/futex/functional/Makefile b/tools/testing/selftests/futex/functional/Makefile index ff8feca49746..ad1eeb14fda7 100644 --- a/tools/testing/selftests/futex/functional/Makefile +++ b/tools/testing/selftests/futex/functional/Makefile @@ -18,6 +18,7 @@ TEST_GEN_FILES := \ TEST_PROGS := run.sh +top_srcdir = ../../../../.. include ../../lib.mk $(TEST_GEN_FILES): $(HEADERS) diff --git a/tools/testing/selftests/gpio/Makefile b/tools/testing/selftests/gpio/Makefile index 1bbb47565c55..4665cdbf1a8d 100644 --- a/tools/testing/selftests/gpio/Makefile +++ b/tools/testing/selftests/gpio/Makefile @@ -21,11 +21,8 @@ endef CFLAGS += -O2 -g -std=gnu99 -Wall -I../../../../usr/include/ LDLIBS += -lmount -I/usr/include/libmount -$(BINARIES): ../../../gpio/gpio-utils.o ../../../../usr/include/linux/gpio.h +$(BINARIES):| khdr +$(BINARIES): ../../../gpio/gpio-utils.o ../../../gpio/gpio-utils.o: make ARCH=$(ARCH) CROSS_COMPILE=$(CROSS_COMPILE) -C ../../../gpio - -../../../../usr/include/linux/gpio.h: - make -C ../../../.. headers_install INSTALL_HDR_PATH=$(shell pwd)/../../../../usr/ - diff --git a/tools/testing/selftests/kvm/Makefile b/tools/testing/selftests/kvm/Makefile index 03b0f551bedf..87d1a8488af8 100644 --- a/tools/testing/selftests/kvm/Makefile +++ b/tools/testing/selftests/kvm/Makefile @@ -37,9 +37,6 @@ $(LIBKVM_OBJ): $(OUTPUT)/%.o: %.c $(OUTPUT)/libkvm.a: $(LIBKVM_OBJ) $(AR) crs $@ $^ -$(LINUX_HDR_PATH): - make -C $(top_srcdir) headers_install - -all: $(STATIC_LIBS) $(LINUX_HDR_PATH) +all: $(STATIC_LIBS) $(TEST_GEN_PROGS): $(STATIC_LIBS) -$(TEST_GEN_PROGS) $(LIBKVM_OBJ): | $(LINUX_HDR_PATH) +$(STATIC_LIBS):| khdr diff --git a/tools/testing/selftests/lib.mk b/tools/testing/selftests/lib.mk index 17ab36605a8e..0a8e75886224 100644 --- a/tools/testing/selftests/lib.mk +++ b/tools/testing/selftests/lib.mk @@ -16,8 +16,20 @@ TEST_GEN_PROGS := $(patsubst %,$(OUTPUT)/%,$(TEST_GEN_PROGS)) TEST_GEN_PROGS_EXTENDED := $(patsubst %,$(OUTPUT)/%,$(TEST_GEN_PROGS_EXTENDED)) TEST_GEN_FILES := $(patsubst %,$(OUTPUT)/%,$(TEST_GEN_FILES)) +top_srcdir ?= ../../../.. +include $(top_srcdir)/scripts/subarch.include +ARCH ?= $(SUBARCH) + all: $(TEST_GEN_PROGS) $(TEST_GEN_PROGS_EXTENDED) $(TEST_GEN_FILES) +.PHONY: khdr +khdr: + make ARCH=$(ARCH) -C $(top_srcdir) headers_install + +ifdef KSFT_KHDR_INSTALL +$(TEST_GEN_PROGS) $(TEST_GEN_PROGS_EXTENDED) $(TEST_GEN_FILES):| khdr +endif + .ONESHELL: define RUN_TEST_PRINT_RESULT TEST_HDR_MSG="selftests: "`basename $$PWD`:" $$BASENAME_TEST"; \ diff --git a/tools/testing/selftests/net/Makefile b/tools/testing/selftests/net/Makefile index cccdb2295567..256d82d5fa87 100644 --- a/tools/testing/selftests/net/Makefile +++ b/tools/testing/selftests/net/Makefile @@ -15,6 +15,7 @@ TEST_GEN_FILES += udpgso udpgso_bench_tx udpgso_bench_rx ip_defrag TEST_GEN_PROGS = reuseport_bpf reuseport_bpf_cpu reuseport_bpf_numa TEST_GEN_PROGS += reuseport_dualstack reuseaddr_conflict tls +KSFT_KHDR_INSTALL := 1 include ../lib.mk $(OUTPUT)/reuseport_bpf_numa: LDFLAGS += -lnuma diff --git a/tools/testing/selftests/networking/timestamping/Makefile b/tools/testing/selftests/networking/timestamping/Makefile index a728040edbe1..14cfcf006936 100644 --- a/tools/testing/selftests/networking/timestamping/Makefile +++ b/tools/testing/selftests/networking/timestamping/Makefile @@ -5,6 +5,7 @@ TEST_PROGS := hwtstamp_config rxtimestamp timestamping txtimestamp all: $(TEST_PROGS) +top_srcdir = ../../../../.. include ../../lib.mk clean: diff --git a/tools/testing/selftests/vm/Makefile b/tools/testing/selftests/vm/Makefile index 9881876d2aa0..e94b7b14bcb2 100644 --- a/tools/testing/selftests/vm/Makefile +++ b/tools/testing/selftests/vm/Makefile @@ -26,10 +26,6 @@ TEST_PROGS := run_vmtests include ../lib.mk -$(OUTPUT)/userfaultfd: ../../../../usr/include/linux/kernel.h $(OUTPUT)/userfaultfd: LDLIBS += -lpthread $(OUTPUT)/mlock-random-test: LDLIBS += -lcap - -../../../../usr/include/linux/kernel.h: - make -C ../../../.. headers_install -- 2.18.0 ^ permalink raw reply related [flat|nested] 21+ messages in thread
* Re: [PATCH v6] selftests: add headers_install to lib.mk 2018-09-04 10:47 ` [PATCH v6] " Anders Roxell @ 2018-09-05 14:13 ` Shuah Khan 2018-09-28 4:52 ` Michael Ellerman 1 sibling, 0 replies; 21+ messages in thread From: Shuah Khan @ 2018-09-05 14:13 UTC (permalink / raw) To: Anders Roxell, yamada.masahiro, michal.lkml, bamv2005, brgl, pbonzini, akpm, rppt, aarcange Cc: linux-kbuild, linux-kernel, linux-kselftest, netdev, Shuah Khan On 09/04/2018 04:47 AM, Anders Roxell wrote: > If the kernel headers aren't installed we can't build all the tests. > Add a new make target rule 'khdr' in the file lib.mk to generate the > kernel headers and that gets include for every test-dir Makefile that > includes lib.mk If the testdir in turn have its own sub-dirs the > top_srcdir needs to be set to the linux-rootdir to be able to generate > the kernel headers. > > Signed-off-by: Anders Roxell <anders.roxell@linaro.org> > Reviewed-by: Fathi Boudra <fathi.boudra@linaro.org> > --- > > I sent this (v5) a month ago and wondered if it got lost. Resending > unchanged. > > Cheers, > Anders > > Makefile | 14 +------------- > scripts/subarch.include | 13 +++++++++++++ > tools/testing/selftests/android/Makefile | 2 +- > tools/testing/selftests/android/ion/Makefile | 2 ++ > tools/testing/selftests/futex/functional/Makefile | 1 + > tools/testing/selftests/gpio/Makefile | 7 ++----- > tools/testing/selftests/kvm/Makefile | 7 ++----- > tools/testing/selftests/lib.mk | 12 ++++++++++++ > tools/testing/selftests/net/Makefile | 1 + > .../selftests/networking/timestamping/Makefile | 1 + > tools/testing/selftests/vm/Makefile | 4 ---- > 11 files changed, 36 insertions(+), 28 deletions(-) > create mode 100644 scripts/subarch.include > > diff --git a/Makefile b/Makefile > index 19948e556941..9c781e77fa24 100644 > --- a/Makefile > +++ b/Makefile > @@ -299,19 +299,7 @@ KERNELRELEASE = $(shell cat include/config/kernel.release 2> /dev/null) > KERNELVERSION = $(VERSION)$(if $(PATCHLEVEL),.$(PATCHLEVEL)$(if $(SUBLEVEL),.$(SUBLEVEL)))$(EXTRAVERSION) > export VERSION PATCHLEVEL SUBLEVEL KERNELRELEASE KERNELVERSION > > -# SUBARCH tells the usermode build what the underlying arch is. That is set > -# first, and if a usermode build is happening, the "ARCH=um" on the command > -# line overrides the setting of ARCH below. If a native build is happening, > -# then ARCH is assigned, getting whatever value it gets normally, and > -# SUBARCH is subsequently ignored. > - > -SUBARCH := $(shell uname -m | sed -e s/i.86/x86/ -e s/x86_64/x86/ \ > - -e s/sun4u/sparc64/ \ > - -e s/arm.*/arm/ -e s/sa110/arm/ \ > - -e s/s390x/s390/ -e s/parisc64/parisc/ \ > - -e s/ppc.*/powerpc/ -e s/mips.*/mips/ \ > - -e s/sh[234].*/sh/ -e s/aarch64.*/arm64/ \ > - -e s/riscv.*/riscv/) > +include scripts/subarch.include > > # Cross compiling and selecting different set of gcc/bin-utils > # --------------------------------------------------------------------------- > diff --git a/scripts/subarch.include b/scripts/subarch.include > new file mode 100644 > index 000000000000..650682821126 > --- /dev/null > +++ b/scripts/subarch.include > @@ -0,0 +1,13 @@ > +# SUBARCH tells the usermode build what the underlying arch is. That is set > +# first, and if a usermode build is happening, the "ARCH=um" on the command > +# line overrides the setting of ARCH below. If a native build is happening, > +# then ARCH is assigned, getting whatever value it gets normally, and > +# SUBARCH is subsequently ignored. > + > +SUBARCH := $(shell uname -m | sed -e s/i.86/x86/ -e s/x86_64/x86/ \ > + -e s/sun4u/sparc64/ \ > + -e s/arm.*/arm/ -e s/sa110/arm/ \ > + -e s/s390x/s390/ -e s/parisc64/parisc/ \ > + -e s/ppc.*/powerpc/ -e s/mips.*/mips/ \ > + -e s/sh[234].*/sh/ -e s/aarch64.*/arm64/ \ > + -e s/riscv.*/riscv/) > diff --git a/tools/testing/selftests/android/Makefile b/tools/testing/selftests/android/Makefile > index 72c25a3cb658..d9a725478375 100644 > --- a/tools/testing/selftests/android/Makefile > +++ b/tools/testing/selftests/android/Makefile > @@ -6,7 +6,7 @@ TEST_PROGS := run.sh > > include ../lib.mk > > -all: > +all: khdr > @for DIR in $(SUBDIRS); do \ > BUILD_TARGET=$(OUTPUT)/$$DIR; \ > mkdir $$BUILD_TARGET -p; \ > diff --git a/tools/testing/selftests/android/ion/Makefile b/tools/testing/selftests/android/ion/Makefile > index e03695287f76..88cfe88e466f 100644 > --- a/tools/testing/selftests/android/ion/Makefile > +++ b/tools/testing/selftests/android/ion/Makefile > @@ -10,6 +10,8 @@ $(TEST_GEN_FILES): ipcsocket.c ionutils.c > > TEST_PROGS := ion_test.sh > > +KSFT_KHDR_INSTALL := 1 > +top_srcdir = ../../../../.. > include ../../lib.mk > > $(OUTPUT)/ionapp_export: ionapp_export.c ipcsocket.c ionutils.c > diff --git a/tools/testing/selftests/futex/functional/Makefile b/tools/testing/selftests/futex/functional/Makefile > index ff8feca49746..ad1eeb14fda7 100644 > --- a/tools/testing/selftests/futex/functional/Makefile > +++ b/tools/testing/selftests/futex/functional/Makefile > @@ -18,6 +18,7 @@ TEST_GEN_FILES := \ > > TEST_PROGS := run.sh > > +top_srcdir = ../../../../.. > include ../../lib.mk > > $(TEST_GEN_FILES): $(HEADERS) > diff --git a/tools/testing/selftests/gpio/Makefile b/tools/testing/selftests/gpio/Makefile > index 1bbb47565c55..4665cdbf1a8d 100644 > --- a/tools/testing/selftests/gpio/Makefile > +++ b/tools/testing/selftests/gpio/Makefile > @@ -21,11 +21,8 @@ endef > CFLAGS += -O2 -g -std=gnu99 -Wall -I../../../../usr/include/ > LDLIBS += -lmount -I/usr/include/libmount > > -$(BINARIES): ../../../gpio/gpio-utils.o ../../../../usr/include/linux/gpio.h > +$(BINARIES):| khdr > +$(BINARIES): ../../../gpio/gpio-utils.o > > ../../../gpio/gpio-utils.o: > make ARCH=$(ARCH) CROSS_COMPILE=$(CROSS_COMPILE) -C ../../../gpio > - > -../../../../usr/include/linux/gpio.h: > - make -C ../../../.. headers_install INSTALL_HDR_PATH=$(shell pwd)/../../../../usr/ > - > diff --git a/tools/testing/selftests/kvm/Makefile b/tools/testing/selftests/kvm/Makefile > index 03b0f551bedf..87d1a8488af8 100644 > --- a/tools/testing/selftests/kvm/Makefile > +++ b/tools/testing/selftests/kvm/Makefile > @@ -37,9 +37,6 @@ $(LIBKVM_OBJ): $(OUTPUT)/%.o: %.c > $(OUTPUT)/libkvm.a: $(LIBKVM_OBJ) > $(AR) crs $@ $^ > > -$(LINUX_HDR_PATH): > - make -C $(top_srcdir) headers_install > - > -all: $(STATIC_LIBS) $(LINUX_HDR_PATH) > +all: $(STATIC_LIBS) > $(TEST_GEN_PROGS): $(STATIC_LIBS) > -$(TEST_GEN_PROGS) $(LIBKVM_OBJ): | $(LINUX_HDR_PATH) > +$(STATIC_LIBS):| khdr > diff --git a/tools/testing/selftests/lib.mk b/tools/testing/selftests/lib.mk > index 17ab36605a8e..0a8e75886224 100644 > --- a/tools/testing/selftests/lib.mk > +++ b/tools/testing/selftests/lib.mk > @@ -16,8 +16,20 @@ TEST_GEN_PROGS := $(patsubst %,$(OUTPUT)/%,$(TEST_GEN_PROGS)) > TEST_GEN_PROGS_EXTENDED := $(patsubst %,$(OUTPUT)/%,$(TEST_GEN_PROGS_EXTENDED)) > TEST_GEN_FILES := $(patsubst %,$(OUTPUT)/%,$(TEST_GEN_FILES)) > > +top_srcdir ?= ../../../.. > +include $(top_srcdir)/scripts/subarch.include > +ARCH ?= $(SUBARCH) > + > all: $(TEST_GEN_PROGS) $(TEST_GEN_PROGS_EXTENDED) $(TEST_GEN_FILES) > > +.PHONY: khdr > +khdr: > + make ARCH=$(ARCH) -C $(top_srcdir) headers_install > + > +ifdef KSFT_KHDR_INSTALL > +$(TEST_GEN_PROGS) $(TEST_GEN_PROGS_EXTENDED) $(TEST_GEN_FILES):| khdr > +endif > + > .ONESHELL: > define RUN_TEST_PRINT_RESULT > TEST_HDR_MSG="selftests: "`basename $$PWD`:" $$BASENAME_TEST"; \ > diff --git a/tools/testing/selftests/net/Makefile b/tools/testing/selftests/net/Makefile > index cccdb2295567..256d82d5fa87 100644 > --- a/tools/testing/selftests/net/Makefile > +++ b/tools/testing/selftests/net/Makefile > @@ -15,6 +15,7 @@ TEST_GEN_FILES += udpgso udpgso_bench_tx udpgso_bench_rx ip_defrag > TEST_GEN_PROGS = reuseport_bpf reuseport_bpf_cpu reuseport_bpf_numa > TEST_GEN_PROGS += reuseport_dualstack reuseaddr_conflict tls > > +KSFT_KHDR_INSTALL := 1 > include ../lib.mk > > $(OUTPUT)/reuseport_bpf_numa: LDFLAGS += -lnuma > diff --git a/tools/testing/selftests/networking/timestamping/Makefile b/tools/testing/selftests/networking/timestamping/Makefile > index a728040edbe1..14cfcf006936 100644 > --- a/tools/testing/selftests/networking/timestamping/Makefile > +++ b/tools/testing/selftests/networking/timestamping/Makefile > @@ -5,6 +5,7 @@ TEST_PROGS := hwtstamp_config rxtimestamp timestamping txtimestamp > > all: $(TEST_PROGS) > > +top_srcdir = ../../../../.. > include ../../lib.mk > > clean: > diff --git a/tools/testing/selftests/vm/Makefile b/tools/testing/selftests/vm/Makefile > index 9881876d2aa0..e94b7b14bcb2 100644 > --- a/tools/testing/selftests/vm/Makefile > +++ b/tools/testing/selftests/vm/Makefile > @@ -26,10 +26,6 @@ TEST_PROGS := run_vmtests > > include ../lib.mk > > -$(OUTPUT)/userfaultfd: ../../../../usr/include/linux/kernel.h > $(OUTPUT)/userfaultfd: LDLIBS += -lpthread > > $(OUTPUT)/mlock-random-test: LDLIBS += -lcap > - > -../../../../usr/include/linux/kernel.h: > - make -C ../../../.. headers_install > I queued this up in linux-kselftest next to be included in my next pull request. thanks, -- Shuah ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH v6] selftests: add headers_install to lib.mk 2018-09-04 10:47 ` [PATCH v6] " Anders Roxell 2018-09-05 14:13 ` Shuah Khan @ 2018-09-28 4:52 ` Michael Ellerman 2018-09-28 13:52 ` Shuah Khan 1 sibling, 1 reply; 21+ messages in thread From: Michael Ellerman @ 2018-09-28 4:52 UTC (permalink / raw) To: Anders Roxell, yamada.masahiro, michal.lkml, shuah, bamv2005, brgl, pbonzini, akpm, rppt, aarcange Cc: linux-kbuild, linux-kernel, linux-kselftest, netdev, Anders Roxell, linuxppc-dev [ + linuxppc-dev ] Anders Roxell <anders.roxell@linaro.org> writes: > If the kernel headers aren't installed we can't build all the tests. > Add a new make target rule 'khdr' in the file lib.mk to generate the > kernel headers and that gets include for every test-dir Makefile that > includes lib.mk If the testdir in turn have its own sub-dirs the > top_srcdir needs to be set to the linux-rootdir to be able to generate > the kernel headers. > > Signed-off-by: Anders Roxell <anders.roxell@linaro.org> > Reviewed-by: Fathi Boudra <fathi.boudra@linaro.org> > --- > > I sent this (v5) a month ago and wondered if it got lost. Resending > unchanged. > > Cheers, > Anders > > Makefile | 14 +------------- > scripts/subarch.include | 13 +++++++++++++ > tools/testing/selftests/android/Makefile | 2 +- > tools/testing/selftests/android/ion/Makefile | 2 ++ > tools/testing/selftests/futex/functional/Makefile | 1 + > tools/testing/selftests/gpio/Makefile | 7 ++----- > tools/testing/selftests/kvm/Makefile | 7 ++----- > tools/testing/selftests/lib.mk | 12 ++++++++++++ > tools/testing/selftests/net/Makefile | 1 + > .../selftests/networking/timestamping/Makefile | 1 + > tools/testing/selftests/vm/Makefile | 4 ---- > 11 files changed, 36 insertions(+), 28 deletions(-) > create mode 100644 scripts/subarch.include This broke all the powerpc selftests :( Why did it go in at rc5? cheers ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH v6] selftests: add headers_install to lib.mk 2018-09-28 4:52 ` Michael Ellerman @ 2018-09-28 13:52 ` Shuah Khan 2018-10-02 14:12 ` Michael Ellerman 0 siblings, 1 reply; 21+ messages in thread From: Shuah Khan @ 2018-09-28 13:52 UTC (permalink / raw) To: Michael Ellerman, Anders Roxell, yamada.masahiro, michal.lkml, bamv2005, brgl, pbonzini, akpm, rppt, aarcange Cc: linux-kbuild, linux-kernel, linux-kselftest, netdev, linuxppc-dev, Shuah Khan On 09/27/2018 10:52 PM, Michael Ellerman wrote: > [ + linuxppc-dev ] > > Anders Roxell <anders.roxell@linaro.org> writes: >> If the kernel headers aren't installed we can't build all the tests. >> Add a new make target rule 'khdr' in the file lib.mk to generate the >> kernel headers and that gets include for every test-dir Makefile that >> includes lib.mk If the testdir in turn have its own sub-dirs the >> top_srcdir needs to be set to the linux-rootdir to be able to generate >> the kernel headers. >> >> Signed-off-by: Anders Roxell <anders.roxell@linaro.org> >> Reviewed-by: Fathi Boudra <fathi.boudra@linaro.org> >> --- >> >> I sent this (v5) a month ago and wondered if it got lost. Resending >> unchanged. >> >> Cheers, >> Anders >> >> Makefile | 14 +------------- >> scripts/subarch.include | 13 +++++++++++++ >> tools/testing/selftests/android/Makefile | 2 +- >> tools/testing/selftests/android/ion/Makefile | 2 ++ >> tools/testing/selftests/futex/functional/Makefile | 1 + >> tools/testing/selftests/gpio/Makefile | 7 ++----- >> tools/testing/selftests/kvm/Makefile | 7 ++----- >> tools/testing/selftests/lib.mk | 12 ++++++++++++ >> tools/testing/selftests/net/Makefile | 1 + >> .../selftests/networking/timestamping/Makefile | 1 + >> tools/testing/selftests/vm/Makefile | 4 ---- >> 11 files changed, 36 insertions(+), 28 deletions(-) >> create mode 100644 scripts/subarch.include > > This broke all the powerpc selftests :( Sorry for thr breakage. > > Why did it go in at rc5? > This patch has been in linux-next for a sometime before I decided to send this. My original intent was to send this for rc2, and my schedule was messed up with traveling. Since I didn't hear any issues from linux-next soaking, I made a call on sending this in for rc5. On second thought I should have waited until 4.20. Sorry about that. thanks, -- Shuah ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH v6] selftests: add headers_install to lib.mk 2018-09-28 13:52 ` Shuah Khan @ 2018-10-02 14:12 ` Michael Ellerman 0 siblings, 0 replies; 21+ messages in thread From: Michael Ellerman @ 2018-10-02 14:12 UTC (permalink / raw) To: Shuah Khan, Anders Roxell, yamada.masahiro, michal.lkml, bamv2005, brgl, pbonzini, akpm, rppt, aarcange Cc: linux-kbuild, linux-kernel, linux-kselftest, netdev, linuxppc-dev, Shuah Khan Shuah Khan <shuah@kernel.org> writes: > On 09/27/2018 10:52 PM, Michael Ellerman wrote: >> [ + linuxppc-dev ] >> >> Anders Roxell <anders.roxell@linaro.org> writes: >>> If the kernel headers aren't installed we can't build all the tests. >>> Add a new make target rule 'khdr' in the file lib.mk to generate the >>> kernel headers and that gets include for every test-dir Makefile that >>> includes lib.mk If the testdir in turn have its own sub-dirs the >>> top_srcdir needs to be set to the linux-rootdir to be able to generate >>> the kernel headers. >>> >>> Signed-off-by: Anders Roxell <anders.roxell@linaro.org> >>> Reviewed-by: Fathi Boudra <fathi.boudra@linaro.org> >>> --- >>> >>> I sent this (v5) a month ago and wondered if it got lost. Resending >>> unchanged. >>> >>> Cheers, >>> Anders >>> >>> Makefile | 14 +------------- >>> scripts/subarch.include | 13 +++++++++++++ >>> tools/testing/selftests/android/Makefile | 2 +- >>> tools/testing/selftests/android/ion/Makefile | 2 ++ >>> tools/testing/selftests/futex/functional/Makefile | 1 + >>> tools/testing/selftests/gpio/Makefile | 7 ++----- >>> tools/testing/selftests/kvm/Makefile | 7 ++----- >>> tools/testing/selftests/lib.mk | 12 ++++++++++++ >>> tools/testing/selftests/net/Makefile | 1 + >>> .../selftests/networking/timestamping/Makefile | 1 + >>> tools/testing/selftests/vm/Makefile | 4 ---- >>> 11 files changed, 36 insertions(+), 28 deletions(-) >>> create mode 100644 scripts/subarch.include >> >> This broke all the powerpc selftests :( > > Sorry for thr breakage. > >> Why did it go in at rc5? > > This patch has been in linux-next for a sometime before I decided to send this. > My original intent was to send this for rc2, and my schedule was messed up with > traveling. Since I didn't hear any issues from linux-next soaking, I made a call > on sending this in for rc5. OK. And I didn't notice the breakage in linux-next because _I_ was travelling :) > On second thought I should have waited until 4.20. Sorry about that. Yeah that would have been better, no worries. cheers ^ permalink raw reply [flat|nested] 21+ messages in thread
end of thread, other threads:[~2019-01-04 13:16 UTC | newest] Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2018-04-12 10:23 [PATCH] selftests: add headers_install to lib.mk Anders Roxell 2018-04-13 9:03 ` [PATCH v2] " Anders Roxell 2018-05-14 11:58 ` [PATCH v3] " Anders Roxell 2018-05-14 17:16 ` Paolo Bonzini 2018-05-14 18:44 ` Mike Rapoport 2018-05-14 19:20 ` Daniel Borkmann 2018-06-07 11:07 ` Anders Roxell 2018-06-07 11:09 ` [PATCH v4] " Anders Roxell 2018-07-23 20:49 ` Anders Roxell 2018-07-24 17:10 ` Shuah Khan 2018-07-25 16:08 ` Anders Roxell 2018-08-06 17:03 ` Shuah Khan 2018-08-07 2:32 ` Masahiro Yamada 2018-08-08 10:44 ` Anders Roxell 2019-01-04 13:15 ` Geert Uytterhoeven 2018-08-09 8:04 ` [PATCH v5] " Anders Roxell 2018-09-04 10:47 ` [PATCH v6] " Anders Roxell 2018-09-05 14:13 ` Shuah Khan 2018-09-28 4:52 ` Michael Ellerman 2018-09-28 13:52 ` Shuah Khan 2018-10-02 14:12 ` Michael Ellerman
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).