[Top][All Lists]

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

Re: bug#45756: Prepending '+' to the recipe line when linking with GCC's

From: Nick Bowler
Subject: Re: bug#45756: Prepending '+' to the recipe line when linking with GCC's -flto=jobserver
Date: Thu, 4 Feb 2021 18:12:26 -0500

On 2021-01-09, R. Diez <> wrote:
> [Resending in hopes it will attach to the new bug. --karl]
>> [...]
>> At any rate, it would be extremely helpful to have a minimal-as-possible
>> runnable (automake-able) example showing the case where the + needs to
>> be prepended. rdiez, can you create such a mini-project?
>  > [...]
> I normally use Autoconf, and I do not understand very much the separation
> between Autoconf and Automake. I do not know who is responsible for the
> generation of the makefile rules to link the executable. Either Autoconf or
> Automake must decide that GCC is not just used for compiling each object
> file, but also for linking, and that rule is not visible in the
> file.
> Of course, such a linking rule does not user $(MAKE), and there is no '+'
> prefix, so the GNU Make jobserver file descriptors will not be passed to
> child processes. This is documented in the GNU Make manual.
> You do not need any special demo project for this. Just take any existing
> Automake project written in C or C++, and use these compilation flags in
> :
> AM_CFLAGS="-flto=jobserver"
> AM_CXXFLAGS="-flto=jobserver"
> If you run the makefile with "make -j 2", GCC will receive environment
> variable MAKEFLAGS with a setting like "--jobserver-fds=xxx", but GNU Make
> will
> close the file descriptors mentioned there before executing the rule and
> running GCC. This issue is not visible in GCC yet due to this bug I
> reported:
> I am not sure how I can demonstrate this in a project, there is not actually
> much to demonstrate.
> This is not just an issue while linking. Like I said, any stage, including
> compilation of a single object file, could use the GNU Make jobs server. So
> there should be a global option in Autoconf or Automake to prepend a '+' to
> all generated rules.

This issue has come up from time to time.  I think I wrote something on
it recently.  think everyone can agree that a solution to this problem
is desirable.

However simply prepending "+" to commands is not practical for Automake
to do because "+" has way more effects than just keeping the jobserver
fds open.  In particular, it will completely break "make -n".

A configure option to allow the user to enable this (rather than an
automake option) would probably be a simple and acceptable way to
get things at leas working, even if it's not an "ideal" solution.

Another possibility is for a "+"-prefixed command to check MAKEFLAGS
to see if options like -n that suppress command execution were used
(Automake already has to do this sort of thing in some rules).

Since I believe the jobserver feature is exclusive to GNU make, I
imagine it would also be possible to make use of GNU make substitution
features to only add the "+" when make options that suppress command
execution are omitted.  This could probably be done in a manner that is
interoperable with other make implementations and would likely perform
better than shell tests inside commands.

Finally this issue could also probably be solved by changing GNU make
itself: providing another mechanism to keep jobserver fds open in rules.


reply via email to

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