[llvm] [LLVM] Remove the requirement for named pipe in jobserver (PR #169154)

Michał Górny via llvm-commits llvm-commits at lists.llvm.org
Sat Nov 22 00:21:10 PST 2025


https://github.com/mgorny created https://github.com/llvm/llvm-project/pull/169154

Remove the requirement that the jobserver "fifo" is actually a named pipe.  Named pipes are essentially stateless, and therefore carry a high risk of a killed process leaving the server with no tokens left, and no clear way to reclaim them.  Therefore, multiple jobserver implementations use FUSE instead:

- [nixos-jobserver](https://github.com/NixOS/nixpkgs/pull/314888) (WIP) uses simple file on FUSE

- [steve](https://gitweb.gentoo.org/proj/steve.git) uses a character device via CUSE

- [guildmaster](https://codeberg.org/amonakov/guildmaster) uses a character device via CUSE

This is compatible with GNU make and Ninja, since they do not check the file type, and seems to be the only solution that can achieve state tracking while preserving compatibility.

CC @amonakov

>From 762cdd326fc9d8e9b0e89bff3d268de07a152904 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= <mgorny at gentoo.org>
Date: Sat, 22 Nov 2025 09:02:54 +0100
Subject: [PATCH] [LLVM] Remove the requirement for named pipe in jobserver
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Remove the requirement that the jobserver "fifo" is actually a named
pipe.  Named pipes are essentially stateless, and therefore carry a high
risk of a killed process leaving the server with no tokens left, and no
clear way to reclaim them.  Therefore, multiple jobserver
implementations use FUSE instead:

- [nixos-jobserver](https://github.com/NixOS/nixpkgs/pull/314888) (WIP)
  uses simple file on FUSE

- [steve](https://gitweb.gentoo.org/proj/steve.git) uses a character
  device via CUSE

- [guildmaster](https://codeberg.org/amonakov/guildmaster) uses
  a character device via CUSE

This is compatible with GNU make and Ninja, since they do not check
the file type, and seems to be the only solution that can achieve
state tracking while preserving compatibility.

Signed-off-by: Michał Górny <mgorny at gentoo.org>
---
 llvm/lib/Support/Unix/Jobserver.inc | 10 +---------
 1 file changed, 1 insertion(+), 9 deletions(-)

diff --git a/llvm/lib/Support/Unix/Jobserver.inc b/llvm/lib/Support/Unix/Jobserver.inc
index 53bf7f288ca1f..300fb5e55045e 100644
--- a/llvm/lib/Support/Unix/Jobserver.inc
+++ b/llvm/lib/Support/Unix/Jobserver.inc
@@ -19,14 +19,6 @@
 #include <unistd.h>
 
 namespace {
-/// Returns true if the given file descriptor is a FIFO (named pipe).
-bool isFifo(int FD) {
-  struct stat StatBuf;
-  if (::fstat(FD, &StatBuf) != 0)
-    return false;
-  return S_ISFIFO(StatBuf.st_mode);
-}
-
 /// Returns true if the given file descriptors are valid.
 bool areFdsValid(int ReadFD, int WriteFD) {
   if (ReadFD == -1 || WriteFD == -1)
@@ -75,7 +67,7 @@ JobserverClientImpl::JobserverClientImpl(const JobserverConfig &Config) {
   case JobserverConfig::PosixFifo:
     // Open the FIFO for reading. It must be non-blocking and close-on-exec.
     ReadFD = ::open(Config.Path.c_str(), O_RDONLY | O_NONBLOCK | O_CLOEXEC);
-    if (ReadFD < 0 || !isFifo(ReadFD)) {
+    if (ReadFD < 0) {
       if (ReadFD >= 0)
         ::close(ReadFD);
       ReadFD = -1;



More information about the llvm-commits mailing list