]> git.ipfire.org Git - thirdparty/gcc.git/commit
Do not skip jobserver flags with negative file descriptors
authorSenthil Kumar Selvaraj <saaadhu@gcc.gnu.org>
Thu, 18 Dec 2025 06:15:50 +0000 (11:45 +0530)
committerSenthil Kumar Selvaraj <saaadhu@gcc.gnu.org>
Thu, 18 Dec 2025 06:15:50 +0000 (11:45 +0530)
commit5ae3346507bbc39731bf4d43efe56cdb208f23fc
tree1db8558490bc3fc21e4e14140ee23a3840ebf918
parent135fe58ec9a989fc301d762547325fd90ea37397
Do not skip jobserver flags with negative file descriptors

As part of jobserver detection, the jobserver_info constructor looks
for the last occurence of "--jobserver-auth=", and parses the argument
for that option to look for either a named pipe (has a "fifo:" prefix)
or read and write pipe fds separated by a comma.

With GNU Make 4.4 and above, named pipes are used by default because
anonymous pipe fds cannot be used reliably (see
https://savannah.gnu.org/bugs/?57242), but it still supports a
--jobserver-style=pipe option for compatibility reasons. With that
flag enabled, or with older GNU Make versions, the jobserver detection
code checks if the provided fds are greater than 0 and valid. If
invalid, it drops them from MAKEFLAGS used for subsequent child
processes.

However, GNU Make explicitly provides negative jobserver pipe fds if
the command is not marked as recursive (i.e is missing a '+' prefix in
the Makefile) - see https://savannah.gnu.org/bugs/?57242#comment13.

The MAKEFLAGS look like this in that case.

-j4 --jobserver-auth=3,4 --jobserver-auth=-2,-2

Stripping off the final --jobserver-auth with negative fds undoes this
helpful hint from GNU Make, and exposes child processes (like
lto-wrapper) to all the issues with anonymous pipe fds that forced GNU
Make to switch to named pipes by default.

This patch prevents that stripping if jobserver communication is *not*
via a named pipe *and* file descriptors are negative. As a result,
child processes receive MAKEFLAGS with negative file descriptors too,
and correctly decide that a jobserver is not available.

gcc/ChangeLog:

* opts-common.cc (jobserver_info::jobserver_info): Do not skip
negative file descriptors in simple UNIX pipe mode.
gcc/opts-common.cc