simon-git: charset (master): Simon Tatham
Commits to Tartarus CVS repository.
tartarus-commits at lists.tartarus.org
Wed Mar 16 20:34:12 GMT 2016
TL;DR:
89123b0 Fix parallel builds of libcharset.
Repository: git://git.tartarus.org/simon/charset.git
On the web: http://tartarus.org/~simon-git/gitweb/?p=charset.git
Branch updated: master
Committer: Simon Tatham <anakin at pobox.com>
Date: 2016-03-16 20:34:12
commit 89123b0bdbb3b2780a1bc16d95813f08f43801e5
web diff http://tartarus.org/~simon-git/gitweb/?p=charset.git;a=commitdiff;h=89123b0bdbb3b2780a1bc16d95813f08f43801e5;hp=284007079e05fc55b679bc5b64db814f83a65573
Author: Simon Tatham <anakin at pobox.com>
Date: Wed Mar 16 20:33:19 2016 +0000
Fix parallel builds of libcharset.
The generation script sbcsgen.pl was writing out both sbcsdat.c and
sbcsdat.h, and the makefile was indicating this using the syntax
'sbcsdat.c sbcsdat.h: [input files]', which is a well known error - it
doesn't mean 'run these commands once to build both these files in one
step', it means 'run these commands once for _each_ of these files you
want to build'. (So it's what you would want, for example, if lots of
different files are built using a command that only varied in the
output file name - you could provide a rule command involving a $@.)
This error causes a race condition in a parallel build, because make
will probably queue up two runs of sbcsgen.pl, once to generate the .c
and once for the .h (in fact both will generate both, but make doesn't
know that). Then suppose one of those succeeds, say the one make
thinks is generating the .c; so make launches a subsequent job that
needs the .c file; and then the other run of sbcsgen.pl gets to the
point where it opens the .c for output and truncates it. Bang!
The automake manual has a really scary section on how to tell make the
thing you really wanted ('just run this command once and both these
files will appear'), which I really don't want to try to actually use.
So instead I've bowed to inevitability: if sbcsgen.pl is going to be
run once for each output file, I should just arrange that it has
separate modes in which it generates one or the other output file, and
then make's assumptions will be _right_, and no file will get
overwritten as a side effect make is unaware of.
With that fixed, the parallel build still failed because a couple of
files that include sbcsdat.c or sbcsdat.h were not flagged as doing so
in the makefile, so that their build steps could start running before
sbcsgen.pl had finished. So I've also added a couple of missing
dependencies on sbcsdat.c (and a missing -I in one case as well), and
now a parallel build in libcharset seems to work.
Makefile | 21 ++++++---
sbcsgen.pl | 144 +++++++++++++++++++++++++++++++++++++-----------------------
2 files changed, 104 insertions(+), 61 deletions(-)
More information about the tartarus-commits
mailing list