[coreboot] Patch set updated for coreboot: 73eeacc Fix coreboot makefiles not to produce half baked output.

Kyösti Mälkki (kyosti.malkki@gmail.com) gerrit at coreboot.org
Mon Mar 26 19:22:51 CEST 2012


Kyösti Mälkki (kyosti.malkki at gmail.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/750

-gerrit

commit 73eeaccdab5d28d5a7f91cec772096f21d69f152
Author: Kyösti Mälkki <kyosti.malkki at gmail.com>
Date:   Sun Mar 25 22:59:20 2012 +0300

    Fix coreboot makefiles not to produce half baked output.
    
    It looks like the cbfstool utility generates the output file even when
    it fails to generate it properly. This causes make, if started second
    time in a row, after cbfstool failure, to continue beyond the point of
    failure (as the corrupted output file is present in the output tree,
    the second make invocation presumes that it is valid, as it is newer
    than the dependencies).
    
    For the same reason, cases where output file is generated and modified
    within a recipe have to use a temporary file name too.
    
    The output file should be created only when successful, in an atomic
    operation. There could be other places in the make system which
    require a similar fix, this needs to be investigated further.
    
    Change-Id: I7c17f033ee5937eb712b1a594122430cee5c9146
    Signed-off-by: Vadim Bendebury <vbendeb at chromium.org>
    Signed-off-by: Kyösti Mälkki <kyosti.malkki at gmail.com>
---
 src/arch/x86/Makefile.inc |   50 ++++++++++++++++++++++++--------------------
 1 files changed, 27 insertions(+), 23 deletions(-)

diff --git a/src/arch/x86/Makefile.inc b/src/arch/x86/Makefile.inc
index a437d18..f131af9 100755
--- a/src/arch/x86/Makefile.inc
+++ b/src/arch/x86/Makefile.inc
@@ -58,13 +58,15 @@ extract_nth=$(word $(1), $(subst |, ,$(2)))
 ifneq ($(CONFIG_UPDATE_IMAGE),y)
 prebuild-files = \
 	$(foreach file,$(cbfs-files), \
-		$(CBFSTOOL) $@ add $(call extract_nth,1,$(file)) $(call extract_nth,2,$(file)) $(call extract_nth,3,$(file)) $(call extract_nth,4,$(file)); )
+	$(CBFSTOOL) $@.tmp add $(call extract_nth,1,$(file)) \
+	$(call extract_nth,2,$(file)) $(call extract_nth,3,$(file)) \
+	$(call extract_nth,4,$(file)) &&)
 prebuilt-files = $(foreach file,$(cbfs-files), $(call extract_nth,1,$(file)))
 
 $(obj)/coreboot.pre1: $(obj)/coreboot.bootblock $$(prebuilt-files) $(CBFSTOOL)
-	rm -f $@
-	$(CBFSTOOL) $@ create $(CONFIG_COREBOOT_ROMSIZE_KB)K $(obj)/coreboot.bootblock
-	$(prebuild-files)
+	$(CBFSTOOL) $@.tmp create $(CONFIG_COREBOOT_ROMSIZE_KB)K $(obj)/coreboot.bootblock
+	$(prebuild-files) true
+	mv $@.tmp $@
 else
 .PHONY: $(obj)/coreboot.pre1
 $(obj)/coreboot.pre1: $(CBFSTOOL)
@@ -144,11 +146,12 @@ $(objutil)/options/build_opt_tbl: $(top)/util/options/build_opt_tbl.c $(top)/src
 
 $(obj)/coreboot_ram: $(obj)/coreboot_ram.o $(src)/arch/x86/coreboot_ram.ld #ldoptions
 	@printf "    CC         $(subst $(obj)/,,$(@))\n"
-	$(CC) -nostdlib -nostartfiles -static -o $@ -L$(obj) -T $(src)/arch/x86/coreboot_ram.ld $(obj)/coreboot_ram.o
-	$(NM) -n $(obj)/coreboot_ram | sort > $(obj)/coreboot_ram.map
-	$(OBJCOPY) --only-keep-debug $@ $(obj)/coreboot_ram.debug
-	$(OBJCOPY) --strip-debug $@
-	$(OBJCOPY) --add-gnu-debuglink=$(obj)/coreboot_ram.debug $@
+	$(CC) -nostdlib -nostartfiles -static -o $@.tmp -L$(obj) -T $(src)/arch/x86/coreboot_ram.ld $(obj)/coreboot_ram.o
+	$(NM) -n $@.tmp | sort > $@.map
+	$(OBJCOPY) --only-keep-debug $@.tmp $@.debug
+	$(OBJCOPY) --strip-debug $@.tmp
+	$(OBJCOPY) --add-gnu-debuglink=$@.debug $@.tmp
+	mv $@.tmp $@
 
 $(obj)/coreboot_ram.o: $(obj)/arch/x86/lib/c_start.ramstage.o $$(driver-objs) $(obj)/coreboot.a $(LIBGCC_FILE_NAME)
 	@printf "    CC         $(subst $(obj)/,,$(@))\n"
@@ -166,12 +169,12 @@ ifeq ($(CONFIG_AP_CODE_IN_CAR),y)
 
 $(obj)/coreboot_ap: $(obj)/mainboard/$(MAINBOARDDIR)/ap_romstage.o
 	@printf "    CC         $(subst $(obj)/,,$(@))\n"
-	$(CC) -nostdlib -nostartfiles -static -o $@ -L$(obj) -T $(src)/arch/x86/init/ldscript_apc.lb $^
-	$(OBJCOPY) --only-keep-debug $@ $(obj)/coreboot_ap.debug
-	$(OBJCOPY) --strip-debug $@
-	$(OBJCOPY) --add-gnu-debuglink=$(obj)/coreboot_ap.debug $@
-	$(NM) -n $(obj)/coreboot_ap | sort > $(obj)/coreboot_ap.map
-
+	$(CC) -nostdlib -nostartfiles -static -o $@.tmp -L$(obj) -T $(src)/arch/x86/init/ldscript_apc.lb $^
+	$(OBJCOPY) --only-keep-debug $@.tmp $@.debug
+	$(OBJCOPY) --strip-debug $@.tmp
+	$(OBJCOPY) --add-gnu-debuglink=$@.debug $@.tmp
+	$(NM) -n $@.tmp | sort > $@.map
+	mv $@.tmp $@
 
 endif
 
@@ -269,10 +272,10 @@ endif
 
 $(obj)/coreboot.pre: $(obj)/coreboot.romstage $(obj)/coreboot.pre1 $(CBFSTOOL)
 	@printf "    CBFS       $(subst $(obj)/,,$(@))\n"
-	rm -f $@
-	cp $(obj)/coreboot.pre1 $@
-	$(CBFSTOOL) $@ add-stage $(obj)/romstage.elf \
+	cp $(obj)/coreboot.pre1 $@.tmp
+	$(CBFSTOOL) $@.tmp add-stage $(obj)/romstage.elf \
 		$(CONFIG_CBFS_PREFIX)/romstage x $(shell cat $(obj)/location.txt)
+	mv $@.tmp $@
 
 #######################################################################
 # Build the bootblock
@@ -331,11 +334,12 @@ $(obj)/mainboard/$(MAINBOARDDIR)/bootblock.inc: $(src)/arch/x86/init/$(subst ",,
 
 $(obj)/bootblock.elf: $(obj)/mainboard/$(MAINBOARDDIR)/bootblock.o $(obj)/bootblock/ldscript.ld
 	@printf "    LINK       $(subst $(obj)/,,$(@))\n"
-	$(CC) -nostdlib -nostartfiles -static -o $@ -L$(obj) -T $(obj)/bootblock/ldscript.ld $<
-	$(NM) -n $(obj)/bootblock.elf | sort > $(obj)/bootblock.map
-	$(OBJCOPY) --only-keep-debug $@ $(obj)/bootblock.debug
-	$(OBJCOPY) --strip-debug $@
-	$(OBJCOPY) --add-gnu-debuglink=$(obj)/bootblock.debug $@
+	$(CC) -nostdlib -nostartfiles -static -o $@.tmp -L$(obj) -T $(obj)/bootblock/ldscript.ld $<
+	$(NM) -n $@.tmp | sort > $(obj)/bootblock.map
+	$(OBJCOPY) --only-keep-debug $@.tmp $(obj)/bootblock.debug
+	$(OBJCOPY) --strip-debug $@.tmp
+	$(OBJCOPY) --add-gnu-debuglink=$(obj)/bootblock.debug $@.tmp
+	mv $@.tmp $@
 
 #######################################################################
 # Build the romstage




More information about the coreboot mailing list