bug-make
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Another issue with -O?


From: Edward Welbourne
Subject: Re: Another issue with -O?
Date: Sat, 04 May 2013 13:39:05 +0000

>> I think having this facility built into make is a win, especially as
>> parallel builds become predominant.  I would be even more happy about it
>> if we can get it to the point where it can be enabled by default, and
>> users don't even have to worry about it.

> I agree with Paul. This is something that can't really be done right
> by an external tool.

While I agree that make is a better place to do this than an external
tool, something in the back of my mind has been niggling about this
still not really being the right answer.

I suspect the root of that niggle is a desire to make the stdio FILE /
descriptor implement this; there would be a way to "fork" a file
descriptor (or a way to configure what fork() does with inherited file
descriptors), such that each child forked off it gets to see something
that looks and feels just like the original (e.g. isatty() and kindred
functions give the same answers) but with some configuration options
passed to the fdfork/ffork function that determine what happens to
interleaved I/O among the children of a common parent.  One option would
then be to buffer all output from the child and deliver it when the
child closes.  (Another commonly desirable pattern would be to ensure
that interleaving happens only at line boundaries, for example, to avoid
the case some of us report with -j of one process's error coming in part
way through a line of output from another.)  When make fork()s its
sub-processes, it could then (before exec()ing the sub-process) select
which way to set the interleaf options on the file-handles it inherits
from its parent.  There would be nothing particularly special about make
here: any program that invokes fork() would be able to do similar; and
any program that fork()s many children is indeed apt to want the same
choices you're considering for make (and maybe others).

This is undoubtedly too big a thing to change in the standard library,
and has been for decades, so we have to make do with doing it in make
instead; but maybe it'll stir someone's brain to think of another way to
achieve the same result, that's not so specific to make.  Perhaps a
"shim" round the standard library might implement ffork/fdfork, or
something like them.  I have no idea whether it's even possible to
preserve descriptor attributes in the sense countenanced, using only the
existing standard library facilities.  Perhaps a new option to fcntl()
could do the trick (but that'd be little use to make, today, as it'd
take decades before all fcntl()s implement it).

Anyway, enough rattling - I think what you've implemented sounds like a
great feature and I await with glee its (suitably tried, tested and
refined) release in the next version of GNU make,

        Eddy.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]