Carl-Daniel Hailfinger wrote:
Make totally depends on timestamps.
This is interesting information. I falsely assumed it would make sure
that it executed a rule to the end if it's pulled in through a
dependency before assuming that dependency to be satisfied.
How do we solve it? Two ways are possible:
- Fix build_opt_tbl.c to use fopen/fwrite/fclose/rename.
- Perform that logic in the makefile.
Fixing build_opt_tbl.c is IMHO the preferred course because it avoids
hacks in makefiles.
Ok. Well, 2. was definitely easier to hack up correctly, but here you
go. A somewhat race safe build_opt_tbl. Check r3783.
I'm attaching the Makefile hack fix as a reference (Not required
anymore, DO NOT APPLY)
my right hand is injured and I am typing with
my left hand only (no worries ;-)).
Get well soon!
--
coresystems GmbH • Brahmsstr. 16 • D-79104 Freiburg i. Br.
Tel.: +49 761 7668825 • Fax: +49 761 7664613
Email: info@coresystems.de •
http://www.coresystems.de/
Registergericht: Amtsgericht Freiburg • HRB 7656
Geschäftsführer: Stefan Reinauer • Ust-IdNr.: DE245674866
Make sure the creation of option_table.c and option_table.o happens
atomically.
Signed-off-by: Stefan Reinauer
stepan@coresystems.de
Index: src/config/Config.lb
===================================================================
--- src/config/Config.lb (revision 3782)
+++ src/config/Config.lb (working copy)
@@ -181,9 +181,15 @@
action "$(HOSTCC) $(HOSTCFLAGS) $(CPUFLAGS) $< -o $@"
end
+# make seems to assume that a non-phony dependency is satisfied if the target
+# file exists, not if the according rule has been completely finished. The
+# following rule makes sure we don't confuse make with partly created or empty
+# option_table.[ch] files in case coreboot is compiled with make -j.
makerule option_table.h option_table.c
depends "build_opt_tbl $(MAINBOARD)/cmos.layout"
- action "./build_opt_tbl -b --config $(MAINBOARD)/cmos.layout --header option_table.h --option option_table.c"
+ action "./build_opt_tbl -b --config $(MAINBOARD)/cmos.layout --header option_table.h.tmp --option option_table.c.tmp"
+ action "mv option_table.c.tmp option_table.c"
+ action "mv option_table.h.tmp option_table.h"
end
if HAVE_OPTION_TABLE