* [PATCH] scripts: support GNU make 4.4 in jobserver-exec
@ 2023-01-16 10:45 Martin Liška
2023-01-16 11:16 ` Masahiro Yamada
0 siblings, 1 reply; 2+ messages in thread
From: Martin Liška @ 2023-01-16 10:45 UTC (permalink / raw)
To: linux-kernel
Cc: linux-block, Masahiro Yamada, nicolas, axboe, josef, keescook
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 <mliska@suse.cz>
---
scripts/jobserver-exec | 19 ++++++++++++++-----
1 file changed, 14 insertions(+), 5 deletions(-)
diff --git a/scripts/jobserver-exec b/scripts/jobserver-exec
index 4192855f5b8b..7eca035472d3 100755
--- a/scripts/jobserver-exec
+++ b/scripts/jobserver-exec
@@ -26,11 +26,20 @@ try:
# If the MAKEFLAGS variable contains multiple instances of the
# --jobserver-auth= option, the last one is relevant.
fds = opts[-1].split("=", 1)[1]
- reader, writer = [int(x) for x in fds.split(",", 1)]
- # Open a private copy of reader to avoid setting nonblocking
- # on an unexpecting process with the same reader fd.
- reader = os.open("/proc/self/fd/%d" % (reader),
- os.O_RDONLY | os.O_NONBLOCK)
+
+ # Starting with GNU Make 4.4, named pipes are used for reader and writer.
+ # Example argument: --jobserver-auth=fifo:/tmp/GMfifo8134
+ _, _, path = fds.partition('fifo:')
+
+ if path:
+ reader = os.open(path, os.O_RDONLY | os.O_NONBLOCK)
+ writer = os.open(path, os.O_WRONLY)
+ else:
+ reader, writer = [int(x) for x in fds.split(",", 1)]
+ # Open a private copy of reader to avoid setting nonblocking
+ # on an unexpecting process with the same reader fd.
+ reader = os.open("/proc/self/fd/%d" % (reader),
+ os.O_RDONLY | os.O_NONBLOCK)
# Read out as many jobserver slots as possible.
while True:
--
2.39.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] scripts: support GNU make 4.4 in jobserver-exec
2023-01-16 10:45 [PATCH] scripts: support GNU make 4.4 in jobserver-exec Martin Liška
@ 2023-01-16 11:16 ` Masahiro Yamada
0 siblings, 0 replies; 2+ messages in thread
From: Masahiro Yamada @ 2023-01-16 11:16 UTC (permalink / raw)
To: Martin Liška
Cc: linux-kernel, linux-block, nicolas, axboe, josef, keescook
On Mon, Jan 16, 2023 at 7:45 PM Martin Liška <mliska@suse.cz> wrote:
>
> 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 <mliska@suse.cz>
Applied to linux-kbuild/fixes.
Thanks.
> ---
> scripts/jobserver-exec | 19 ++++++++++++++-----
> 1 file changed, 14 insertions(+), 5 deletions(-)
>
> diff --git a/scripts/jobserver-exec b/scripts/jobserver-exec
> index 4192855f5b8b..7eca035472d3 100755
> --- a/scripts/jobserver-exec
> +++ b/scripts/jobserver-exec
> @@ -26,11 +26,20 @@ try:
> # If the MAKEFLAGS variable contains multiple instances of the
> # --jobserver-auth= option, the last one is relevant.
> fds = opts[-1].split("=", 1)[1]
> - reader, writer = [int(x) for x in fds.split(",", 1)]
> - # Open a private copy of reader to avoid setting nonblocking
> - # on an unexpecting process with the same reader fd.
> - reader = os.open("/proc/self/fd/%d" % (reader),
> - os.O_RDONLY | os.O_NONBLOCK)
> +
> + # Starting with GNU Make 4.4, named pipes are used for reader and writer.
> + # Example argument: --jobserver-auth=fifo:/tmp/GMfifo8134
> + _, _, path = fds.partition('fifo:')
> +
> + if path:
> + reader = os.open(path, os.O_RDONLY | os.O_NONBLOCK)
> + writer = os.open(path, os.O_WRONLY)
> + else:
> + reader, writer = [int(x) for x in fds.split(",", 1)]
> + # Open a private copy of reader to avoid setting nonblocking
> + # on an unexpecting process with the same reader fd.
> + reader = os.open("/proc/self/fd/%d" % (reader),
> + os.O_RDONLY | os.O_NONBLOCK)
>
> # Read out as many jobserver slots as possible.
> while True:
> --
> 2.39.0
>
--
Best Regards
Masahiro Yamada
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-01-16 11:17 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-16 10:45 [PATCH] scripts: support GNU make 4.4 in jobserver-exec Martin Liška
2023-01-16 11:16 ` Masahiro Yamada
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).