If I understand the code at https://gitweb.gentoo.org/proj/portage.git/tree/lib/portage/util/env_update.py#n106 correctly, then PATH setting for ebuilds is constructed from $ROOT/etc/env.d This makes no sense, since $ROOT may even be empty; the build dependencies are present in / (or at least portage should take both into consideration). The problem may sound academic, but actually has an impact, I think... LLVM installs its binaries in an extra directory together with an env.d file; now if CC=clang and that env.d is not present (yet) in /tmp/stage1root, the stage1 build of catalyst cannot find the clang binary and fails miserably.
Possibly should be ${BROOT} instead of just /.
Fixed in portage-3.0.33: ``` portage-3.0.33 (2022-07-18) -------------- Bug fixes: * env-update: Handle BROOT vs ROOT distinction for PATH (and other variables like PREROOTPATH and ROOTPATH). The issue being that only some variables are relevant for execution (and hence need to be derived from BROOT), while others need to correspond to EROOT for e.g. library paths. This should help with Clang stage building. [..]. ``` ``` commit 7cc778fbf3aa7919036f2bb224b118d96c14f31e Author: Arfrever Frehtes Taifersar Arahesis <arfrever@apache.org> Date: Mon Jul 11 03:54:26 2022 +0100 env-update: handle BROOT vs ROOT distinction for e.g. PATH When Portage builds packages with a non-trivial ROOT setting, say, ROOT=/tmp/stage1root, the build dependencies (compilers, tools, etc.) should be taken from the actual build environment BROOT, say BROOT=/ , and that must also be reflected in the environment. An example situation that leads to problems otherwise is the following: * We build a clang-based stage1 with CC=clang * The clang binary exists only in a custom directory pulled into PATH via env.d. * ROOT=/tmp/stage1root is initially empty, meaning portage tries to build with settings from an empty env.d, and suddently cannot find the clang that perfectly exists in BROOT=/ anymore. * The build fails. The patch takes a more versatile approach and separates environment variables into three categories: * constructed from ROOT * constructed from BROOT * combined from ROOT and BROOT (checks EROOT, then BROOT. If present in both, only EROOT is used.) Thanks-to: Andreas K. Hüttel <dilfridge@gentoo.org> Thanks-to: James Le Cuirot <chewi@gentoo.org> Signed-off-by: Sam James <sam@gentoo.org> Closes: https://github.com/gentoo/portage/pull/851 Signed-off-by: Sam James <sam@gentoo.org> ```