dev-build/make: Sync with Gentoo

It's from Gentoo commit 4a92861a64c292cd2f090d4a41d95154305449ab.

Signed-off-by: Flatcar Buildbot <buildbot@flatcar-linux.org>
This commit is contained in:
Flatcar Buildbot 2025-11-17 07:06:57 +00:00 committed by Krzesimir Nowak
parent f0298ee173
commit 6bcf6e08b7
2 changed files with 185 additions and 0 deletions

View File

@ -0,0 +1,81 @@
https://bugs.gentoo.org/966090
https://savannah.gnu.org/bugs/index.php?67687#comment3
https://file.savannah.gnu.org/file/sv67687_release_tokens.diff?file_id=57804
Rebased on make-4.4.1 because of test changes.
commit 04a04b5dfe66de46353c9fe31dd64efab2516257
Author: Dmitry Goncharov <dgoncharov@users.sf.net>
Date: Thu Nov 13 00:25:15 2025 -0500
[SV 67687] Release all jobserver tokens upon a fatal signal.
* src/commands.c (fatal_error_signal): Call jobserver_clear after
reap_childen to let free_child run jobserver_release before the
pipe/fifo is closed.
* tests/scripts/features/jobserver: Add tests.
--- a/src/commands.c
+++ b/src/commands.c
@@ -531,7 +531,6 @@ fatal_error_signal (int sig)
temp_stdin_unlink ();
osync_clear ();
- jobserver_clear ();
/* A termination signal won't be sent to the entire
process group, but it means we want to kill the children. */
@@ -577,6 +576,8 @@ fatal_error_signal (int sig)
while (job_slots_used > 0)
reap_children (1, 1);
+ jobserver_clear ();
+
/* Delete any non-precious intermediate files that were made. */
remove_intermediates (1);
--- a/tests/scripts/features/jobserver
+++ b/tests/scripts/features/jobserver
@@ -198,4 +198,39 @@ all:;@echo "$$MAKEFLAGS"
run_make_test(q!all:;@echo hi!, "", "#MAKE#: cannot open jobserver nosuchfile: $ERR_no_such_file\n#MAKE#: $j1err\nhi\n");
}
+if ($port_type eq 'UNIX') {
+ # sv 67687.
+ # Test that make releases all jobserver tokens upon a fatal signal.
+ #
+ # When the submake releases all its tokens make prints something like
+ #
+ # "make[1]: *** [child.mk:2: a] Terminated
+ # make[1]: *** [child.mk:2: b] Terminated
+ # make: *** [t001.mk:2: all] Terminated".
+ #
+ # When make detects lost jobserver tokens, make prints something like
+ #
+ # "make[1]: *** [child.mk:2: a] Terminated
+ # make[1]: *** [child.mk:2: b] Terminated
+ # make: *** [t001.mk:2: all] Terminated
+ # INTERNAL: exiting with 1 jobserver tokens available; should be 3!".
+ #
+ # This test has to fail if the last line is "exiting with ...".
+ # Anchor \Z ensures that the regex won't match when the "exiting with ..."
+ # message is present, because the preceding "Terminated" message is
+ # followed by a new line.
+ #
+ # "[\w\d ]*" after "Terminated" is for macos.
+ create_file('child.mk',
+'all: a b c
+a b:; @sleep 180
+c:; @sleep 2 && kill -term $$PPID');
+ my $re = '/#MAKE#: \*\*\* \[#MAKEFILE#:2: all\] Terminated[\w\d ]*\Z/';
+ run_make_test(q!
+all:; @$(MAKE) --no-print-directory -f child.mk
+!, '-j3', $re, 512);
+ run_make_test(undef, '--jobserver-style=pipe -j3', $re, 512);
+ unlink('child.mk') unless $keep;
+}
+
1;
--
2.51.2

View File

@ -0,0 +1,104 @@
# Copyright 1999-2025 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
EAPI=8
VERIFY_SIG_OPENPGP_KEY_PATH=/usr/share/openpgp-keys/make.asc
GUILE_COMPAT=( 2-2 3-0 )
inherit flag-o-matic unpacker verify-sig guile-single
DESCRIPTION="Standard tool to compile source trees"
HOMEPAGE="https://www.gnu.org/software/make/make.html"
if [[ ${PV} == 9999 ]] ; then
EGIT_REPO_URI="https://git.savannah.gnu.org/git/make.git"
inherit autotools git-r3
elif [[ $(ver_cut 3) -ge 90 || $(ver_cut 4) -ge 90 ]] ; then
SRC_URI="https://alpha.gnu.org/gnu/make/${P}.tar.lz"
SRC_URI+=" verify-sig? ( https://alpha.gnu.org/gnu/make/${P}.tar.lz.sig )"
else
SRC_URI="mirror://gnu/make/${P}.tar.lz"
SRC_URI+=" verify-sig? ( mirror://gnu/make/${P}.tar.lz.sig )"
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
LICENSE="GPL-3+"
SLOT="0"
IUSE="doc guile nls static test"
RESTRICT="!test? ( test )"
REQUIRED_USE="guile? ( ${GUILE_REQUIRED_USE} )"
DEPEND="
guile? ( ${GUILE_DEPS} )
"
RDEPEND="
${DEPEND}
nls? ( virtual/libintl )
"
BDEPEND="
$(unpacker_src_uri_depends)
doc? ( virtual/texi2dvi )
nls? ( sys-devel/gettext )
verify-sig? ( sec-keys/openpgp-keys-make )
test? ( dev-lang/perl )
"
DOCS="AUTHORS NEWS README*"
PATCHES=(
"${FILESDIR}"/${PN}-4.4-default-cxx.patch
"${FILESDIR}"/${PN}-4.4.1-c23.patch
"${FILESDIR}"/${PN}-4.4.1-jobserver-kill-return-tokens.patch
)
src_unpack() {
if [[ ${PV} == 9999 ]] ; then
git-r3_src_unpack
cd "${S}" || die
./bootstrap || die
else
use verify-sig && verify-sig_verify_detached "${DISTDIR}"/${P}.tar.lz{,.sig}
unpacker ${P}.tar.lz
fi
}
src_prepare() {
default
if [[ ${PV} == 9999 ]] ; then
eautoreconf
fi
if use guile; then
guile_bump_sources
fi
}
pkg_setup() {
if use guile; then
guile-single_pkg_setup
fi
}
src_configure() {
use static && append-ldflags -static
local myeconfargs=(
--program-prefix=g
$(use_with guile)
$(use_enable nls)
)
econf "${myeconfargs[@]}"
}
src_compile() {
emake all $(usev doc 'pdf html')
}
src_install() {
use doc && HTML_DOCS=( doc/make.html/. ) DOCS="${DOCS} doc/make.pdf"
default
dosym gmake /usr/bin/make
dosym gmake.1 /usr/share/man/man1/make.1
guile_unstrip_ccache
}