Skip to content

Commit 4f1127e

Browse files
author
Sam Ravnborg
committed
kbuild: fix infinite make recursion
Jan Engelhardt <jengelh@computergmbh.de> reported: You can cause a recursion in kbuild/make with the following: make O=$PWD kernel/time.o make mrproper Of course no one would use O=$PWD (that's just the testcase), but this happened too often: /ws/linux/linux-2.6.23$ make O=/ws/linux/linux-2.6.23 kernel/time.o (Oops - should have been O=/ws/linux/obj-2.6.23!) Fixed by an explicit test for this case - we error out if output directory and source directory are the same. Tested-by: Jan Engelhardt <jengelh@computergmbh.de> Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
1 parent a67cb13 commit 4f1127e

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

‎Makefile‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,9 @@ saved-output := $(KBUILD_OUTPUT)
115115
KBUILD_OUTPUT := $(shell cd $(KBUILD_OUTPUT) && /bin/pwd)
116116
$(if $(KBUILD_OUTPUT),, \
117117
$(error output directory "$(saved-output)" does not exist))
118-
118+
# Check that OUTPUT directory is not the same as where we have kernel src
119+
$(if $(filter-out $(KBUILD_OUTPUT),$(shell /bin/pwd)),, \
120+
$(error Output directory (O=...) specifies kernel src dir))
119121
PHONY += $(MAKECMDGOALS)
120122

121123
$(filter-out _all,$(MAKECMDGOALS)) _all:

0 commit comments

Comments
 (0)