commit:     61f76236aa10c297f79c2fee123a79d26bfa9327
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Wed May  6 04:54:03 2020 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Wed May  6 06:37:12 2020 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=61f76236

doebuild: Use ccache/distcc/icecream only in src_* phases

Enable ccache/distcc/icecream only when src_* phases are executed.
There is generally little value from them in pkg_*, as these phases
use CC only to do a few tests at most.  These compilations generally
are not run in parallel and the programs are tiny, so usually
the overhead exceeds the gain.

On the other hand, running them in pkg_* phases results in files being
created with root ownership that breaks them afterwards when using
userpriv.  As a result, user not only loses the benefit of, say, distcc
but also frequently hits error messages that confuse some configure
scripts and result in miscompiled packages.

Bug: https://bugs.gentoo.org/581880
Reviewed-by: Zac Medico <zmedico <AT> gentoo.org>
Closes: https://github.com/gentoo/portage/pull/547
Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>

 lib/portage/package/ebuild/doebuild.py | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/lib/portage/package/ebuild/doebuild.py 
b/lib/portage/package/ebuild/doebuild.py
index 2bff94cb1..1343eca6d 100644
--- a/lib/portage/package/ebuild/doebuild.py
+++ b/lib/portage/package/ebuild/doebuild.py
@@ -486,7 +486,14 @@ def doebuild_environment(myebuild, mydo, myroot=None, 
settings=None,
                distcc = "distcc" in mysettings.features
                icecream = "icecream" in mysettings.features
 
-               if ccache or distcc or icecream:
+               # run cc thingies only in src_* phases as otherwise they might
+               # create files with incorrect ownership and trip over
+               # (NB: install has a similar issue but 1) some badly written
+               # packages rebuild stuff there, so ccache is very helpful
+               # and 2) almost always some compilation will happen earlier,
+               # so permissions will be already set correctly)
+               if (ccache or distcc or icecream) and mydo in ('unpack',
+                               'prepare', 'configure', 'test', 'install'):
                        libdir = None
                        default_abi = mysettings.get("DEFAULT_ABI")
                        if default_abi:

Reply via email to