2006-01-11 08:39:27

by Keith Owens

[permalink] [raw]
Subject: 2.6.15 make fails with multiple targets in parallel

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 ?


2006-01-11 16:39:16

by Sam Ravnborg

[permalink] [raw]
Subject: Re: 2.6.15 make fails with multiple targets in parallel

On Wed, Jan 11, 2006 at 07:39:11PM +1100, Keith Owens wrote:
> 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.

> 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

2006-01-15 17:04:30

by Sam Ravnborg

[permalink] [raw]
Subject: Re: 2.6.15 make fails with multiple targets in parallel

On Wed, Jan 11, 2006 at 07:39:11PM +1100, Keith Owens wrote:
> 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

diff --git a/Makefile b/Makefile
index deedaf7..b3dd9db 100644
--- a/Makefile
+++ b/Makefile
@@ -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