Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

selftests: drop khdr make target

Drop the "khdr" make target as it fails when the build directory is a
sub-directory of the source tree. Rely on the "headers_install"
target to have been run first instead.

For example, here's a typical error this patch is addressing:

$ make O=build -j32 kselftest-gen_tar
make[1]: Entering directory '/home/kernelci/linux/build'
make --no-builtin-rules INSTALL_HDR_PATH=/home/kernelci/linux/build/usr \
ARCH=x86 -C ../../.. headers_install
make[3]: Entering directory '/home/kernelci/linux'
Makefile:1022: ../scripts/Makefile.extrawarn: No such file or directory

The source directory is determined in the top-level Makefile as ".."
relatively to the "build" directory, but then the kselftest Makefile
switches to "-C ../../.." so "../scripts" then points one level higher
than the source tree e.g. "linux/../scripts" - which fails obviously.
There is no other use-case in the kernel tree where a sub-directory
Makefile tries to call a top-level make target, and it appears this
isn't really a valid thing to do.

Signed-off-by: Guillaume Tucker <guillaume.tucker@collabora.com>
Tested-by: Anders Roxell <anders.roxell@linaro.org>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>

authored by

Guillaume Tucker and committed by
Shuah Khan
3bb267a3 dbeb2327

+2 -25
+2 -25
tools/testing/selftests/Makefile
··· 151 151 # all isn't the first target in the file. 152 152 .DEFAULT_GOAL := all 153 153 154 - # Install headers here once for all tests. KSFT_KHDR_INSTALL_DONE 155 - # is used to avoid running headers_install from lib.mk. 156 - # Invoke headers install with --no-builtin-rules to avoid circular 157 - # dependency in "make kselftest" case. In this case, second level 158 - # make inherits builtin-rules which will use the rule generate 159 - # Makefile.o and runs into 160 - # "Circular Makefile.o <- prepare dependency dropped." 161 - # and headers_install fails and test compile fails. 162 - # 163 - # O= KBUILD_OUTPUT cases don't run into this error, since main Makefile 164 - # invokes them as sub-makes and --no-builtin-rules is not necessary, 165 - # but doesn't cause any failures. Keep it simple and use the same 166 - # flags in both cases. 167 - # Local build cases: "make kselftest", "make -C" - headers are installed 168 - # in the default INSTALL_HDR_PATH usr/include. 169 - khdr: 170 - ifeq (1,$(DEFAULT_INSTALL_HDR_PATH)) 171 - $(MAKE) --no-builtin-rules ARCH=$(ARCH) -C $(top_srcdir) headers_install 172 - else 173 - $(MAKE) --no-builtin-rules INSTALL_HDR_PATH=$(abs_objtree)/usr \ 174 - ARCH=$(ARCH) -C $(top_srcdir) headers_install 175 - endif 176 - 177 - all: khdr 154 + all: 178 155 @ret=1; \ 179 156 for TARGET in $(TARGETS); do \ 180 157 BUILD_TARGET=$$BUILD/$$TARGET; \ ··· 251 274 $(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET clean;\ 252 275 done; 253 276 254 - .PHONY: khdr all run_tests hotplug run_hotplug clean_hotplug run_pstore_crash install clean gen_tar 277 + .PHONY: all run_tests hotplug run_hotplug clean_hotplug run_pstore_crash install clean gen_tar