Re: Generating missing depfiles by an automake based makefile
On Wed, Feb 8, 2023 at 11:54 AM Jan Engelhardt wrote: > depfiles are created ahead of make so that the include command > in Makefiles succeeds (include-with-ignore is non-portable AFAIR). Atleast, gnu make and sun make can build included files. > depfiles are not specifically tracked; this is impossible, > due to a chicken-egg problem. Do you mean this is impossible when we have to support some specific make impl? > .Po file contents control when an .o file -- and thus also > the .Po file itself -- is remade. > If a .Po file has no practical content, there is no indication > that it needs to be remade. Absence of the depfile is such an indication. Here is a sample bash session which demonstrates how gnu make and sun make are able to build a missing depfile. $ ls hello.c hello.h makefile $ cat makefile all: hello.tsk hello.tsk: hello.o gcc-10 -o $@ $^ hello.o: hello.c hello.Po gcc-10 -c hello.c -MD -MF hello.Po hello.Po: gcc-10 -c hello.c -MD -MF hello.Po include hello.Po $ gmake gcc-10 -c hello.c -MD -MF hello.Po gcc-10 -o hello.tsk hello.o $ gmake gmake: Nothing to be done for 'all'. $ rm hello.Po $ gmake gcc-10 -c hello.c -MD -MF hello.Po gcc-10 -o hello.tsk hello.o $ gmake gmake: Nothing to be done for 'all'. $ rm hello.o hello.Po hello.tsk $ $ $ # this is sun make $ /bin/make gcc-10 -c hello.c -MD -MF hello.Po gcc-10 -o hello.tsk hello.o $ /bin/make $ rm hello.Po $ /bin/make gcc-10 -c hello.c -MD -MF hello.Po gcc-10 -o hello.tsk hello.o $ /bin/make $ In the case of gnu make the rule to build the depfile does not have to have a recipe and can be simplified to hello.Po: Which implementations of make does automake generate makefiles for? Can automake be enhanced to generate gnu make specific code to allow for depfiles to be rebuilt? Such enhancement can be conditional, that is, only when the generated makefile is supposed to be used with gnu make. Same for sun make. regards, Dmitry
Re: Generating missing depfiles by an automake based makefile
On Thursday 2023-02-09 22:33, Dmitry Goncharov wrote: > >> .Po file contents control when an .o file -- and thus also >> the .Po file itself -- is remade. >> If a .Po file has no practical content, there is no indication >> that it needs to be remade. > >Absence of the depfile is such an indication. >Here is a sample bash session which demonstrates how gnu make and sun >make are able to build a missing depfile. > >$ ls >hello.c hello.h makefile >$ cat makefile >all: hello.tsk >hello.tsk: hello.o >gcc-10 -o $@ $^ > >hello.o: hello.c hello.Po >gcc-10 -c hello.c -MD -MF hello.Po > >hello.Po: >gcc-10 -c hello.c -MD -MF hello.Po > >include hello.Po This is a GNU extension. If you try this with e.g. OpenBSD make, it will complain.
Re: Generating missing depfiles by an automake based makefile
On Thu, Feb 9, 2023 at 11:41 AM Jan Engelhardt wrote: > This is a GNU extension. Not only gnu. Also supported by sun make. > If you try this with e.g. > OpenBSD make, it will complain. That's why i asked those questions about portability. Do i understand it correctly, that a need to support bmake forces automake to abandon a good mechanism to rebuild depfiles? regards, Dmitry
Re: Generating missing depfiles by an automake based makefile
On Thursday 2023-02-09 22:53, Dmitry Goncharov wrote: > >> If you try this with e.g. >> OpenBSD make, it will complain. > >That's why i asked those questions about portability. >Do i understand it correctly, that a need to support bmake forces >automake to abandon a good mechanism to rebuild depfiles? Maybe not. autoconf is big on text substitution, and there already is an AM_MAKE_INCLUDE m4 macro to test for the type of include directive. It would probably take a new m4 macro AM_MAKE_SILENT_INCLUDE that tests for the availability of "-include", and if found, also somehow changes the rest of the depfile logic to use absent-depfiles rather than empty-depfiles.
Re: Generating missing depfiles by an automake based makefile
On Thu, Feb 9, 2023 at 12:15 PM Jan Engelhardt wrote: > On Thursday 2023-02-09 22:53, Dmitry Goncharov wrote: > It would probably take a new m4 macro AM_MAKE_SILENT_INCLUDE that tests > for the availability of "-include", and if found, also somehow changes > the rest of the depfile logic to use absent-depfiles rather than > empty-depfiles. i am not looking forward to -include (even though -include is supported by bmake, gnu make and sun make). -include robs the user the error message should make fails to rebuild a depfile. i'd rather introduce rules to rebuild depfiles, as presented in the earlier email. regards, Dmitry
Re: Generating missing depfiles by an automake based makefile
Dmitry> i am not looking forward to -include (even though -include is Dmitry> supported by bmake, gnu make and sun make). Dmitry> -include robs the user the error message should make fails to rebuild a depfile. Dmitry> i'd rather introduce rules to rebuild depfiles, as presented in the Dmitry> earlier email. It's been a long time since I worked on automake, but the dependency tracking in automake is designed not to need to rebuild or pre-build dep files. Doing that means invoking the compiler twice, which is slow. Instead, automake computes dependencies as a side effect of compilation. What is the scenario where you both end up with an empty depfile and a compilation that isn't out of date for some other reason? That seems like it shouldn't be possible. Tom
Re: Generating missing depfiles by an automake based makefile
On Thursday, February 9, 2023, Tom Tromey wrote: > > > It's been a long time since I worked on automake, but the dependency > tracking in automake is designed not to need to rebuild or pre-build dep > files. Doing that means invoking the compiler twice, which is slow. > Instead, automake computes dependencies as a side effect of compilation. The hello.Po example presented above computes depfiles as a side effect of compilation. Moreover, when hello.Po is absent that makefile compiles hello.o as a side effect of hello.Po computation. In total there is only one compilation. > > What is the scenario where you both end up with an empty depfile and a > compilation that isn't out of date for some other reason? That seems > like it shouldn't be possible. > > When a depfile is missing (for any reason) the current automake makefile creates a dummy depfile. From that point on the user has to notice that make is no longer tracking dependencies and their build is incorrect. I am asking if automake can be enhanced to do something similar to hello.Po example above, in those cases when make supports that. Regards, Dmitry