Skip to contentSkip to conversation

2.6.15 make fails with multiple targets in parallel

DISCUSSION Keith Owens 2 participants 3 messages Jan 11, 2006 – Jan 15, 2006 Kbuild

lore
Share & tools
lore
#0 lore raw

Running make on the kernel tree with multiple targets on the command line and in parallel mode gets errors. The prepare targets are run several times, once for each target on the command line. Sometimes the result is sensible, sometimes the prepare commands overwrite each other with either garbage or missing files.

make -j12 compressed modules vmlinux
Using /foo/linux as source for kernel
Using /foo/linux as source for kernel
Using /foo/linux as source for kernel
GEN /foo/obj/Makefile
CHK include/linux/version.h
GEN /foo/obj/Makefile
GEN /foo/obj/Makefile

  CHK     include/linux/version.h
  CHK     include/linux/version.h
  UPD     include/linux/version.h
  UPD     include/linux/version.h
  UPD     include/linux/version.h

mv: cannot stat `include/linux/version.h.tmp': No such file or directory make[1]: *** [include/linux/version.h] Error 1
make[1]: *** Waiting for unfinished jobs....
make: *** [vmlinux] Error 2
make: *** Waiting for unfinished jobs....

I know that the command above is equivalent to 'make -j12' but that is irrelevant, make is supposed to handle multiple targets without repeating commands.

Is this where we mention http://www.google.com/search?q=cache:HwuX7YF2uBIJ:aegis.sourceforge.net/auug97.pdf&hl=en ?

#1 lore raw
Quoted 11 lines · Keith Owens

Running make on the kernel tree with multiple targets on the command line and in parallel mode gets errors. The prepare targets are run several times, once for each target on the command line. Sometimes the result is sensible, sometimes the prepare commands overwrite each other with either garbage or missing files.

make -j12 compressed modules vmlinux
Using /foo/linux as source for kernel
Using /foo/linux as source for kernel
Using /foo/linux as source for kernel
GEN /foo/obj/Makefile

I've tested it locally. It happens only when using 'make O=...' or in your case with KBUILT_OUTPUT set to a value.

I will try to take a look during the weekend but if you have any inputs that would be appreciated.

Quoted 2 lines

Is this where we mention http://www.google.com/search?q=cache:HwuX7YF2uBIJ:aegis.sourceforge.net/auug97.pdf&hl=en ?

The bug you see is due to the way the "make O=..." support is done - not due to use of recursive makefiles in the kernel.

That being said I hope one day to write a tool that can take all the kbuild files used as part of the kernel build and create one big Makefile - sounds familiar?

The current syntax is rather easy to parse up so no syntax changes in the kbuild (makefile) files needed.
But several other topics are higher on the todo list for now.

Sam

#2 lore raw
In reply to Keith Owens
Quoted 2 lines · Keith Owens

Running make on the kernel tree with multiple targets on the command line and in parallel mode gets errors.

Hi Keith.
Can you please try attached patch.
It does the right thing here with:
make -j 24 O=~/o all vmlinux modules prepare bzImage

Sam

Makefile +4 -3
index deedaf7..b3dd9db 100644
@@ -106,12 +106,13 @@ KBUILD_OUTPUT := $(shell cd $(KBUILD_OUT
 $(if $(KBUILD_OUTPUT),, \
      $(error output directory "$(saved-output)" does not exist))
 
-.PHONY: $(MAKECMDGOALS)
+.PHONY: $(MAKECMDGOALS) cdbuilddir
+$(MAKECMDGOALS) _all: cdbuilddir
 
-$(filter-out _all,$(MAKECMDGOALS)) _all:
+cdbuilddir:
 	$(if $(KBUILD_VERBOSE:1=),@)$(MAKE) -C $(KBUILD_OUTPUT) \
 	KBUILD_SRC=$(CURDIR) \
-	KBUILD_EXTMOD="$(KBUILD_EXTMOD)" -f $(CURDIR)/Makefile $@
+	KBUILD_EXTMOD="$(KBUILD_EXTMOD)" -f $(CURDIR)/Makefile $(MAKECMDGOALS)
 
 # Leave processing to above invocation of make
 skip-makefile := 1