Allow the MAKEFLAGS environment variable to pass through, in case a centralized GNU Make POSIX Jobserver is available. In order to prevent persistence of this variable in environment.bz2, exclude it when the __save_ebuild_env --exclude-init-phases argument is given.
Ultimately we may want to add support for portage to parse MAKEFLAGS and use it to allocate job tokens in various circumstances. For example, emerge could allocate a job token for each job started for emerge --jobs. This would remove a job token from the pool that is available to nested make calls, but is reasonable because nested make calls will execute jobs serially when no jobserver tokens remain. Bug: https://bugs.gentoo.org/692576 Closes: https://github.com/gentoo/portage/pull/1364 Signed-off-by: Zac Medico <zmed...@gentoo.org> --- bin/save-ebuild-env.sh | 5 ++++- lib/portage/__init__.py | 3 ++- lib/portage/package/ebuild/_config/special_env_vars.py | 3 ++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/bin/save-ebuild-env.sh b/bin/save-ebuild-env.sh index 3a2560aabf..6943e59b0b 100644 --- a/bin/save-ebuild-env.sh +++ b/bin/save-ebuild-env.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -# Copyright 1999-2021 Gentoo Authors +# Copyright 1999-2024 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 # @FUNCTION: __save_ebuild_env @@ -24,6 +24,9 @@ __save_ebuild_env() { unset PYTHONPATH fi fi + + # Discard stale GNU Make POSIX Jobserver flags. + unset MAKEFLAGS fi # misc variables inherited from the calling environment diff --git a/lib/portage/__init__.py b/lib/portage/__init__.py index 21bf993170..10c303477f 100644 --- a/lib/portage/__init__.py +++ b/lib/portage/__init__.py @@ -1,4 +1,4 @@ -# Copyright 1998-2023 Gentoo Authors +# Copyright 1998-2024 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 # pylint: disable=ungrouped-imports @@ -657,6 +657,7 @@ def create_trees( # environment to apply to the config that's associated # with ROOT != "/", so pass a nearly empty dict for the env parameter. env_sequence = ( + "MAKEFLAGS", "PATH", "PORTAGE_GRPNAME", "PORTAGE_REPOSITORIES", diff --git a/lib/portage/package/ebuild/_config/special_env_vars.py b/lib/portage/package/ebuild/_config/special_env_vars.py index 1a66192c96..55e5111ef0 100644 --- a/lib/portage/package/ebuild/_config/special_env_vars.py +++ b/lib/portage/package/ebuild/_config/special_env_vars.py @@ -1,4 +1,4 @@ -# Copyright 2010-2021 Gentoo Authors +# Copyright 2010-2024 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 __all__ = ( @@ -112,6 +112,7 @@ environ_whitelist = frozenset( "FEATURES", "FILESDIR", "HOME", + "MAKEFLAGS", "MERGE_TYPE", "NOCOLOR", "NO_COLOR", -- 2.44.2