From 94a2e724905951352a266b831aedd6a1c18825c9 Mon Sep 17 00:00:00 2001 From: Amit Pundir Date: Mon, 26 Mar 2018 20:43:33 +0530 Subject: [PATCH] ANDROID: arm64: Image.gz-dtb build target depends on Image.gz While doing parallel builds using "make -j" option, I ran into a build race condition a few times where-in Image.gz-dtb target starts building before Image.gz is even ready, resulting in a corrupt Image.gz-dtb kernel image. How to reproduce --> $ make ARCH=arm64 CROSS_COMPILE=aarch64-linux-androidkernel- defconfig menuconfig + CONFIG_BUILD_ARM64_APPENDED_DTB_IMAGE=y CONFIG_BUILD_ARM64_APPENDED_DTB_IMAGE_NAMES="qcom/apq8096-db820c" $ make ARCH=arm64 CROSS_COMPILE=aarch64-linux-androidkernel- -j9 .. SYSMAP System.map OBJCOPY arch/arm64/boot/Image GZIP arch/arm64/boot/Image.gz DTC arch/arm64/boot/dts/qcom/apq8096-db820c.dtb Building modules, stage 2. CAT arch/arm64/boot/Image.gz-dtb GZIP arch/arm64/boot/Image.gz .. $ du -sh arch/arm64/boot/Image.gz-dtb 28K arch/arm64/boot/Image.gz-dtb When built with this patch --> $ du -sh arch/arm64/boot/Image.gz-dtb 8.9M arch/arm64/boot/Image.gz-dtb Let's make Image.gz-dtb build target depend on Image.gz explicitly. Signed-off-by: Amit Pundir --- arch/arm64/Makefile | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/arch/arm64/Makefile b/arch/arm64/Makefile index 2dbca8c11498..0b0f5b7cead1 100644 --- a/arch/arm64/Makefile +++ b/arch/arm64/Makefile @@ -143,7 +143,10 @@ dtbs: prepare scripts dtbs_install: $(Q)$(MAKE) $(dtbinst)=$(boot)/dts -Image-dtb Image.gz-dtb: vmlinux scripts dtbs +Image-dtb: vmlinux scripts dtbs + $(Q)$(MAKE) $(build)=$(boot) $(boot)/$@ + +Image.gz-dtb: vmlinux scripts dtbs Image.gz $(Q)$(MAKE) $(build)=$(boot) $(boot)/$@ PHONY += vdso_install