Subject: [PATCH] make -j12 all fails in uImage target

From: Olaf Hering <[email-masked]>
Date: Tue, 12 Jul 2005 23:29:28 +0200

On Sun, Feb 06, Olaf Hering wrote:

> 
> this is what I got with 2.6.11rc3:
> 
> make ARCH=ppc O=../O-2.6.11-rc3-b50-SMP -j12 all
> ...
>   LD      vmlinux
>   SYSMAP  System.map
>   SYSMAP  .tmp_System.map
>   OBJCOPY arch/ppc/boot/images/vmlinux.bin
>   HOSTCC  arch/ppc/boot/utils/addnote
>   HOSTCC  arch/ppc/boot/utils/mknote
>   HOSTCC  arch/ppc/boot/utils/mkprep
>   LD      arch/ppc/boot/lib/built-in.o
>   HOSTCC  arch/ppc/boot/utils/hack-coff
>   HOSTCC  arch/ppc/boot/utils/mkbugboot
>   OBJCOPY arch/ppc/boot/images/vmlinux.bin
>   GZIP    arch/ppc/boot/images/vmlinux.gz
> /bin/sh: line 1: arch/ppc/boot/images/vmlinux.bin: No such file or directory
> make[2]: *** [arch/ppc/boot/images/vmlinux.gz] Error 1
> make[1]: *** [uImage] Error 2
> make[1]: *** Waiting for unfinished jobs....
> 
> also, one time that zImage.chrp was only 570K instead of the expected
> 1.4M, so netboot failed. But I got no build error.

make -j zImage may call if_changed twice at the same time,
the result is a corrupted vmlinux.gz
write to a temporary file for the time being until someone with
make skills fix the serialization properly.

Signed-off-by: Olaf Hering <[email-masked]>

 arch/ppc/boot/images/Makefile |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletion(-)

Index: linux-2.6.13-rc2-olh/arch/ppc/boot/images/Makefile
===================================================================
--- linux-2.6.13-rc2-olh.orig/arch/ppc/boot/images/Makefile
+++ linux-2.6.13-rc2-olh/arch/ppc/boot/images/Makefile
@@ -6,12 +6,17 @@ MKIMAGE		:= $(srctree)/scripts/mkuboot.s
 
 extra-y		:= vmlinux.bin vmlinux.gz
 
+# two make processes may write to vmlinux.gz at the same time with make -j
+quiet_cmd_mygzip = GZIP    $@
+cmd_mygzip = gzip -f -9 < $< > $@.$$$$ && mv $@.$$$$ $@
+
+
 OBJCOPYFLAGS_vmlinux.bin := -O binary
 $(obj)/vmlinux.bin: vmlinux FORCE
 	$(call if_changed,objcopy)
 
 $(obj)/vmlinux.gz: $(obj)/vmlinux.bin FORCE
-	$(call if_changed,gzip)
+	$(call if_changed,mygzip)
 
 quiet_cmd_uimage = UIMAGE  $@
       cmd_uimage = $(CONFIG_SHELL) $(MKIMAGE) -A ppc -O linux -T kernel \