Skip to content

Commit 8c00898

Browse files
marxinmasahir0y
authored andcommitted
scripts: support GNU make 4.4 in jobserver-exec
Starting with GNU make 4.4, --jobserver-auth newly uses named pipe (fifo) instead of part of opened file descriptors: https://www.gnu.org/software/make/manual/html_node/POSIX-Jobserver.html Support also the new format. Signed-off-by: Martin Liska <[email protected]> Signed-off-by: Masahiro Yamada <[email protected]>
1 parent aedee9e commit 8c00898

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

scripts/jobserver-exec

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,20 @@ try:
2626
# If the MAKEFLAGS variable contains multiple instances of the
2727
# --jobserver-auth= option, the last one is relevant.
2828
fds = opts[-1].split("=", 1)[1]
29-
reader, writer = [int(x) for x in fds.split(",", 1)]
30-
# Open a private copy of reader to avoid setting nonblocking
31-
# on an unexpecting process with the same reader fd.
32-
reader = os.open("/proc/self/fd/%d" % (reader),
33-
os.O_RDONLY | os.O_NONBLOCK)
29+
30+
# Starting with GNU Make 4.4, named pipes are used for reader and writer.
31+
# Example argument: --jobserver-auth=fifo:/tmp/GMfifo8134
32+
_, _, path = fds.partition('fifo:')
33+
34+
if path:
35+
reader = os.open(path, os.O_RDONLY | os.O_NONBLOCK)
36+
writer = os.open(path, os.O_WRONLY)
37+
else:
38+
reader, writer = [int(x) for x in fds.split(",", 1)]
39+
# Open a private copy of reader to avoid setting nonblocking
40+
# on an unexpecting process with the same reader fd.
41+
reader = os.open("/proc/self/fd/%d" % (reader),
42+
os.O_RDONLY | os.O_NONBLOCK)
3443

3544
# Read out as many jobserver slots as possible.
3645
while True:

0 commit comments

Comments
 (0)