Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 832398 - portage constructs PATH from $ROOT/etc/env.d, should be /etc/env.d
Summary: portage constructs PATH from $ROOT/etc/env.d, should be /etc/env.d
Status: RESOLVED FIXED
Alias: None
Product: Portage Development
Classification: Unclassified
Component: Core - Ebuild Support (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Portage team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 858824
  Show dependency tree
 
Reported: 2022-01-30 22:02 UTC by Andreas K. Hüttel
Modified: 2022-09-26 00:28 UTC (History)
3 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andreas K. Hüttel archtester gentoo-dev 2022-01-30 22:02:13 UTC
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.
Comment 1 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2022-01-31 01:15:42 UTC
Possibly should be ${BROOT} instead of just /.
Comment 2 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2022-09-26 00:28:31 UTC
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>
```