summaryrefslogtreecommitdiff
path: root/dev-build
diff options
context:
space:
mode:
authorSam James <sam@gentoo.org>2025-11-22 13:48:25 +0000
committerSam James <sam@gentoo.org>2025-11-22 13:49:04 +0000
commit6fdeb2675154560d6083cb076b501f0820f6fdfe (patch)
tree634ff64749347f02e6d2700770892020a2dd956b /dev-build
parent65cabc771798059866c2a442a9beebd42a6c2181 (diff)
downloadgentoo-6fdeb2675154560d6083cb076b501f0820f6fdfe.tar.gz
gentoo-6fdeb2675154560d6083cb076b501f0820f6fdfe.tar.bz2
gentoo-6fdeb2675154560d6083cb076b501f0820f6fdfe.zip
dev-build/ninja: allow pseudo FIFOs as a jobserver
Bug: https://bugs.gentoo.org/692576 Signed-off-by: Sam James <sam@gentoo.org>
Diffstat (limited to 'dev-build')
-rw-r--r--dev-build/ninja/files/ninja-1.13.2-allow-psuedo-fifo.patch88
-rw-r--r--dev-build/ninja/ninja-1.13.2-r1.ebuild133
-rw-r--r--dev-build/ninja/ninja-9999.ebuild1
3 files changed, 222 insertions, 0 deletions
diff --git a/dev-build/ninja/files/ninja-1.13.2-allow-psuedo-fifo.patch b/dev-build/ninja/files/ninja-1.13.2-allow-psuedo-fifo.patch
new file mode 100644
index 000000000000..612038a1c58b
--- /dev/null
+++ b/dev-build/ninja/files/ninja-1.13.2-allow-psuedo-fifo.patch
@@ -0,0 +1,88 @@
+https://github.com/ninja-build/ninja/pull/2692
+
+From 9f1f01d7d03b84342dda511aad0ef3e3fcf4ea7c Mon Sep 17 00:00:00 2001
+From: Sam James <sam@gentoo.org>
+Date: Sat, 22 Nov 2025 12:49:35 +0000
+Subject: [PATCH] Don't require a FIFO to be identifiable as such
+
+The jobserver specification [0] currently suggests that the FIFO must be a
+genuine FIFO.
+
+For some work we're doing [1][2], we're emulating a FIFO using CUSE/FUSE to allow
+tracking when consumers disappear to avoid lost tokens. nixos had a similar
+idea in the past too [3].
+
+There doesn't seem to be a good reason to check that any FIFO passed by
+the user is actually identifiable as such by `stat()`, so drop the check.
+
+make already does not perform such a check, just the specification isn't
+clear about it, so we've asked them to clarify it [4].
+
+[0] https://www.gnu.org/software/make/manual/html_node/POSIX-Jobserver.html
+[1] https://codeberg.org/amonakov/guildmaster
+[2] https://gitweb.gentoo.org/proj/steve.git/
+[3] https://github.com/NixOS/nixpkgs/pull/314888
+[4] https://savannah.gnu.org/bugs/index.php?67726
+---
+ src/jobserver-posix.cc | 12 ------------
+ src/jobserver_test.cc | 10 +---------
+ 2 files changed, 1 insertion(+), 21 deletions(-)
+
+diff --git a/src/jobserver-posix.cc b/src/jobserver-posix.cc
+index 0e3c7e250c..95208c09b6 100644
+--- a/src/jobserver-posix.cc
++++ b/src/jobserver-posix.cc
+@@ -26,13 +26,6 @@
+
+ namespace {
+
+-// Return true if |fd| is a fifo or pipe descriptor.
+-bool IsFifoDescriptor(int fd) {
+- struct stat info;
+- int ret = ::fstat(fd, &info);
+- return (ret == 0) && ((info.st_mode & S_IFMT) == S_IFIFO);
+-}
+-
+ // Implementation of Jobserver::Client for Posix systems
+ class PosixJobserverClient : public Jobserver::Client {
+ public:
+@@ -89,11 +82,6 @@ class PosixJobserverClient : public Jobserver::Client {
+ std::string("Error opening fifo for reading: ") + strerror(errno);
+ return false;
+ }
+- if (!IsFifoDescriptor(read_fd_)) {
+- *error = "Not a fifo path: " + fifo_path;
+- // Let destructor close read_fd_.
+- return false;
+- }
+ write_fd_ = ::open(fifo_path.c_str(), O_WRONLY | O_NONBLOCK | O_CLOEXEC);
+ if (write_fd_ < 0) {
+ *error =
+diff --git a/src/jobserver_test.cc b/src/jobserver_test.cc
+index 850a8b13fd..9e180e6e39 100644
+--- a/src/jobserver_test.cc
++++ b/src/jobserver_test.cc
+@@ -379,21 +379,13 @@ TEST(Jobserver, PosixFifoClientWithWrongPath) {
+ ASSERT_GE(fd, 0) << "Could not create file: " << strerror(errno);
+ ::close(fd);
+
+- // Create new client instance, passing the file path for the fifo.
++ // Create new client instance, with an empty file path.
+ Jobserver::Config config;
+ config.mode = Jobserver::Config::kModePosixFifo;
+- config.path = file_path;
+-
+ std::string error;
+ std::unique_ptr<Jobserver::Client> client =
+ Jobserver::Client::Create(config, &error);
+- EXPECT_FALSE(client.get());
+- EXPECT_FALSE(error.empty());
+- EXPECT_EQ("Not a fifo path: " + file_path, error);
+
+- // Do the same with an empty file path.
+- error.clear();
+- config.path.clear();
+ client = Jobserver::Client::Create(config, &error);
+ EXPECT_FALSE(client.get());
+ EXPECT_FALSE(error.empty());
+
diff --git a/dev-build/ninja/ninja-1.13.2-r1.ebuild b/dev-build/ninja/ninja-1.13.2-r1.ebuild
new file mode 100644
index 000000000000..0ce81c709cd1
--- /dev/null
+++ b/dev-build/ninja/ninja-1.13.2-r1.ebuild
@@ -0,0 +1,133 @@
+# Copyright 2012-2025 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+PYTHON_COMPAT=( python3_{11..14} )
+
+inherit bash-completion-r1 edo python-any-r1 toolchain-funcs
+
+DESCRIPTION="A small build system similar to make"
+HOMEPAGE="https://ninja-build.org/"
+
+if [[ ${PV} == 9999 ]]; then
+ EGIT_REPO_URI="https://github.com/ninja-build/ninja.git"
+ inherit git-r3
+else
+ SRC_URI="https://github.com/ninja-build/${PN}/archive/v${PV}.tar.gz -> ${P}.tar.gz"
+ KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~loong ~m68k ~mips ~ppc ~ppc64 ~riscv ~s390 ~sparc ~x86 ~amd64-linux ~x86-linux ~arm64-macos ~ppc-macos ~x64-macos ~x64-solaris"
+fi
+
+GTEST_VER=1.16.0
+SRC_URI+=" test? ( https://github.com/google/googletest/archive/refs/tags/v${GTEST_VER}.tar.gz -> gtest-${GTEST_VER}.tar.gz )"
+
+LICENSE="Apache-2.0"
+SLOT="0"
+IUSE="doc test"
+RESTRICT="!test? ( test )"
+
+BDEPEND="
+ ${PYTHON_DEPS}
+ dev-util/re2c
+ doc? (
+ app-text/asciidoc
+ app-text/doxygen
+ dev-libs/libxslt
+ media-gfx/graphviz
+ )
+"
+PDEPEND="
+ app-alternatives/ninja
+"
+
+PATCHES=(
+ "${FILESDIR}"/ninja-cflags.patch
+ "${FILESDIR}"/${PN}-1.13.2-allow-psuedo-fifo.patch
+)
+
+pkg_setup() {
+ :
+}
+
+src_unpack() {
+ if [[ ${PV} == 9999 ]] ; then
+ git-r3_src_unpack
+ fi
+
+ default
+}
+
+bootstrap() {
+ if tc-is-cross-compiler; then
+ local -x AR=$(tc-getBUILD_AR)
+ local -x CXX=$(tc-getBUILD_CXX)
+ local -x CFLAGS=
+ local -x CXXFLAGS="${BUILD_CXXFLAGS} -D_FILE_OFFSET_BITS=64"
+ local -x LDFLAGS=${BUILD_LDFLAGS}
+ fi
+
+ local bootstrap_args=(
+ --with-python=python
+ --bootstrap
+ --verbose
+ $(usev test --gtest-source-dir="${WORKDIR}"/googletest-${GTEST_VER})
+ )
+
+ edo ${EPYTHON} configure.py "${bootstrap_args[@]}"
+}
+
+src_compile() {
+ python_setup
+
+ tc-export AR CXX
+ unset CFLAGS
+ export CXXFLAGS="${CXXFLAGS} -D_FILE_OFFSET_BITS=64"
+
+ bootstrap
+
+ if use doc; then
+ edo ./ninja -v doxygen manual
+ fi
+
+ if tc-is-cross-compiler; then
+ edo ${EPYTHON} configure.py --with-python=python
+ edo ./ninja -v ninja
+ fi
+}
+
+src_test() {
+ if ! tc-is-cross-compiler; then
+ # Bug 485772
+ ulimit -n 2048
+ edo ./ninja -v ninja_test
+ edo ./ninja_test
+ fi
+}
+
+src_install() {
+ newbin ninja{,-reference}
+
+ if use doc; then
+ docinto html
+ dodoc -r doc/doxygen/html/.
+ dodoc doc/manual.html
+ fi
+
+ newbashcomp misc/bash-completion ${PN}
+
+ insinto /usr/share/vim/vimfiles/syntax/
+ doins misc/ninja.vim
+
+ echo 'au BufNewFile,BufRead *.ninja set ft=ninja' > "${T}"/ninja.vim || die
+ insinto /usr/share/vim/vimfiles/ftdetect
+ doins "${T}"/ninja.vim
+
+ insinto /usr/share/zsh/site-functions
+ newins misc/zsh-completion _ninja
+}
+
+pkg_postinst() {
+ if ! [[ -e "${EROOT}/usr/bin/ninja" ]]; then
+ ln -s ninja-reference "${EROOT}/usr/bin/ninja" || die
+ fi
+}
diff --git a/dev-build/ninja/ninja-9999.ebuild b/dev-build/ninja/ninja-9999.ebuild
index 06ee36ddd779..0ce81c709cd1 100644
--- a/dev-build/ninja/ninja-9999.ebuild
+++ b/dev-build/ninja/ninja-9999.ebuild
@@ -42,6 +42,7 @@ PDEPEND="
PATCHES=(
"${FILESDIR}"/ninja-cflags.patch
+ "${FILESDIR}"/${PN}-1.13.2-allow-psuedo-fifo.patch
)
pkg_setup() {