Re: [dev] Build system: redo

From: Sergey Matveev <stargrave_AT_stargrave.org>
Date: Sun, 20 Dec 2020 22:26:45 +0300

Greetings!

*** Jeremy [2020-12-20 10:00]:
>Would you happen to know why $3 is necessary, and why one can't write
>to $1 directly?

We need this to atomically create targets. How can one determine if $1
was completed successfully when some outage happens? For example:

    $ cat tarball.tar.do
    wget -O tarball.tar uri://huge/file

starts downloading and suddenly power is lost. tarball.tar will be
created, but it is truncated. But from Makefile (and redo's) point of
view the target exists, fresh and is completed. $3 is temporary file,
that will be renamed (and fsync-ed ideally) to $1 only after successful
.do completion. http://cr.yp.to/redo/atomic.html

>If I `redo /bin/musl-gcc.do`, it will complain that I am overwriting the
>target(redo-python) or it will just truncate the target(redo-c).

Pay attention that redo (as Make too) deals only with single file
targets (or "empty" (always outdated) ones). If "make install"
overwrites /bin/musl-gcc, then of course that is not expected case for
redo. My goredo implementation also (like apenwarr/redo) explicitly
checks if $1 was overwritten directly, because that usage does not make
any guarantees at all (no atomic target building). So all $CC and
similar commands must be told to "-o $3", for redo being able to fsync
and rename it.

In your case it is better to use target that does not directly
"connected" with musl-gcc binary, where (as I understand) hardly "make
install" can be told to use $3 for it. And also pay attention that
"redo" command *always* builds the specified target (makes them
.PHONY-like) -- that is very convenient for human. You should use
"redo-ifchange /bin/musl-build" for forcing redo to check its state and
decide does the target needs to be rebuild.

>Maybe this usecase is irrelevant to the scope of redo, though I'm not sure.
>What do you think?

If you need to run some command if some files are changed -- that is
perfectly fine usecase of course. But due to configure+make install
inability to specify some temporary $3 file, you should use unrelated to
musl-gcc binary target and use redo-ifchange to prevent forceful building.

-- 
Sergey Matveev (http://www.stargrave.org/)
OpenPGP: CF60 E89A 5923 1E76 E263  6422 AE1A 8109 E498 57EF
Received on Sun Dec 20 2020 - 20:26:45 CET

This archive was generated by hypermail 2.3.0 : Sun Dec 20 2020 - 20:36:07 CET