commit: 1d58ac561d07cc269aaf84ce4f94378f30daf6fd
Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Fri Jan 30 09:36:41 2026 +0000
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Fri Jan 30 09:37:52 2026 +0000
URL: https://gitweb.gentoo.org/proj/steve.git/commit/?id=1d58ac56
stevie: Provide -j value in MAKEFLAGS
Provide the job count as -j in MAKEFLAGS, to accommodate clients using
that as an upper job bound (e.g. LLVM).
Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>
src/stevie.cxx | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/src/stevie.cxx b/src/stevie.cxx
index 7f9fe8e..2023176 100644
--- a/src/stevie.cxx
+++ b/src/stevie.cxx
@@ -100,6 +100,19 @@ static int run_command(int jobserver_fd, char **argv,
const char *jobserver_path
}
new_makeflags += "--jobserver-auth=fifo:";
new_makeflags += jobserver_path;
+
+ /* Some clients (e.g. LLVM) try to read -j from MAKEFLAGS to
determine
+ * the upper jobs bound. To accommodate them, try to grab the
job count
+ * from steve. Note that this is not 100% reliable, as it
doesn't
+ * account for job token count changing at runtime.
+ *
+ * We do not need to offset the value since stevie takes one
job token,
+ * so we match GNU make exactly.
+ */
+ int64_t num_jobs;
+ if (ioctl(jobserver_fd, STEVE_IOC_GET_JOBS, &num_jobs) == 0)
+ new_makeflags += std::format(" -j{}", num_jobs);
+
if (setenv("MAKEFLAGS", new_makeflags.c_str(), 1) == -1) {
std::print(stderr, "Unable to set MAKEFLAGS={}\n",
new_makeflags);
_exit(1);