Subject: Re: [PATCH v2 1/5] Makefile: rename objects in-place, don't clobber

From: Junio C Hamano <[email-masked]>
Date: Mon, 29 Mar 2021 17:21:37 -0700

Ævar Arnfjörð Bjarmason <[email-masked]> writes:

>> Really, does anybody else use "$(CC) -o $@" in such a way in their
>> Makefile?  Having to do this smells simply crazy (I am not saying
>> you are crazy---the platform that forces you to write such a thing
>> is crazy).
>
> Yes, if you do say a Google search for "Cannot open or remove a file
> containing a running program" you'll find that there's 15k results of
> people basically (re)discovering this problem in porting their software
> to AIX, and the solutions being some variant of "yes AIX sucks, just use
> this 'cmd >x+ && mv x+ x' trick".

What I meant was if there are well known upstream projects whose
Makefile actually use

	$(CC) -o $@+ ...
	mv $@+ $@

I wouldn't be surprised if AIX community maintained collections of
patches to many projects to turn

	$(CC) -o $@ ...

in the Makefiles taken from upstream projects into

	$(CC) -o $@+ ...
	mv $@+ $@

to work AIX around.  As an upstream, however, I am not interested in
forcing that pattern on users of other platforms.

In any case, I do not care too much about the "I am building a new
binary while running, without installing, the one I built" use case
and do not agree with the idea of making the Makefile ugly only to
support such a use case.  That is where my comments are coming from
on this topic.  FWIW, AIX developers who do not do the "build, run
without installing, and rebuild while the old one is still running"
will not need the "$(CC) -o $@+ && mv $@+ $@" either, right?