Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 255695 - sys-apps/baselayout: /etc/profile: support $PREPATH and $PREROOTPATH for prepending path vars
Summary: sys-apps/baselayout: /etc/profile: support $PREPATH and $PREROOTPATH for prep...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] baselayout (show other bugs)
Hardware: All Linux
: High normal
Assignee: William Hubbs
URL:
Whiteboard:
Keywords:
: 484268 (view as bug list)
Depends on:
Blocks:
 
Reported: 2009-01-20 21:09 UTC by Donnie Berkholz (RETIRED)
Modified: 2020-10-18 12:17 UTC (History)
6 users (show)

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


Attachments
0001-Move-default-path-to-env.d.patch (0001-Move-default-path-to-env.d.patch,1.59 KB, patch)
2017-06-07 22:27 UTC, William Hubbs
Details | Diff
0001-etc-env.d-move-default-settings-to-50bbaselayout-ins.patch (0001-etc-env.d-move-default-settings-to-50bbaselayout-ins.patch,1.32 KB, patch)
2017-06-07 23:08 UTC, William Hubbs
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Donnie Berkholz (RETIRED) gentoo-dev 2009-01-20 21:09:43 UTC
For things like this to be useful:

  hephaestus $ cat /etc/env.d/00local 
  PATH="/usr/lib/ccache/bin:/usr/lib/distcc/bin"
  ROOTPATH="/usr/lib/ccache/bin:/usr/lib/distcc/bin"

we need /etc/profile to prepend items to the path instead of appending them to the end of it. Could this be changed?
Comment 1 SpanKY gentoo-dev 2009-01-20 23:45:36 UTC
that would break gcc-config handling with multilib.  better to add a new PRE_PATH and PRE_ROOTPATH variable i think.
Comment 2 Zac Medico gentoo-dev 2009-01-21 01:04:01 UTC
The PATH setup inside portage's ebuild.sh already has support for a PREROOTPATH variable (without underscore). For /etc/profile, naming the variable slightly differenty is good, since otherwise we could get some interference. For example, it the user puts /usr/lib/ccache/bin in PREROOTPATH then it's going to trigger sandbox violations in CCACHE_DIR if the user hasn't enabled FEATURES=ccache.
Comment 3 Donnie Berkholz (RETIRED) gentoo-dev 2009-01-21 08:37:24 UTC
If gcc-config is the only thing that breaks, I kinda wonder if everything else should prepend (i.e. PATH/ROOTPATH are prepend by default), and just gcc-config should append. I'd expect that in most cases we'd want things in special paths to be preferred over the default path.
Comment 4 SpanKY gentoo-dev 2009-01-21 09:21:06 UTC
gcc-config being the only known thing so far doesnt make it the only thing ...

also, gcc-config itself adds no path.  i'm talking about all the paths in $PATH showing up before /usr/bin which /etc/profile adds.
Comment 5 Donnie Berkholz (RETIRED) gentoo-dev 2009-01-21 18:10:09 UTC
You clearly understand gcc-config better than I do, so go ahead and fix this in whatever way makes the most sense to you.
Comment 6 SpanKY gentoo-dev 2013-09-13 03:55:22 UTC
*** Bug 484268 has been marked as a duplicate of this bug. ***
Comment 7 Mike Gilbert gentoo-dev 2017-06-07 18:12:55 UTC
(In reply to SpanKY from comment #4)
> gcc-config being the only known thing so far doesnt make it the only thing
> ...
> 
> also, gcc-config itself adds no path.  i'm talking about all the paths in
> $PATH showing up before /usr/bin which /etc/profile adds.

Can you elaborate on this a bit more? It's not clear to me how having /usr/bin at the tail end of PATH would break "gcc-config handling with multilib".

Also, maybe instead of hard-coding the position of PATH in /etc/profile, we could move "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" into a new file called /etc/env.d/50default and make it follow the same logic as every other PATH setting.
Comment 8 William Hubbs gentoo-dev 2017-06-07 18:37:23 UTC
Actually I like floppym's idea.
Comment 9 William Hubbs gentoo-dev 2017-06-07 22:27:10 UTC
Created attachment 475562 [details, diff]
0001-Move-default-path-to-env.d.patch

This is a proposed patch to move the default path setting to a file in
/etc/env.d. I called the file 50defaultpath. Take a look and let me know
what you think. I do suspect that this will break other packages.

William
Comment 10 William Hubbs gentoo-dev 2017-06-07 23:08:49 UTC
Created attachment 475570 [details, diff]
0001-etc-env.d-move-default-settings-to-50bbaselayout-ins.patch

This is a better patch, but definitely could cause more breakages.

How should we handle this type of breakage?

William
Comment 11 William Hubbs gentoo-dev 2017-06-08 17:47:38 UTC
This is in the tree and will be in baselayout-2.4.

https://gitweb.gentoo.org/proj/baselayout.git/commit/?id=ef383418
Comment 12 Mike Gilbert gentoo-dev 2017-06-08 18:17:29 UTC
You forgot to apply the patch to update /etc/profile.
Comment 14 Sergei Trofimovich (RETIRED) gentoo-dev 2018-08-24 00:57:35 UTC
(In reply to Mike Gilbert from comment #7)
> (In reply to SpanKY from comment #4)
> > gcc-config being the only known thing so far doesnt make it the only thing
> > ...
> > 
> > also, gcc-config itself adds no path.  i'm talking about all the paths in
> > $PATH showing up before /usr/bin which /etc/profile adds.
> 
> Can you elaborate on this a bit more? It's not clear to me how having
> /usr/bin at the tail end of PATH would break "gcc-config handling with
> multilib".
> 
> Also, maybe instead of hard-coding the position of PATH in /etc/profile, we
> could move "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
> into a new file called /etc/env.d/50default and make it follow the same
> logic as every other PATH setting.

gcc-config wrapper (/usr/bin/gcc) used to append CFLAGS_<ABI> based in ABI variable. That means you really wanted '/usr/bin/gcc' as your first entry in PATH and not real gcc binary.

Addition of CFLAGS_<ABI> was removed since in 2011: https://gitweb.gentoo.org/proj/gcc-config.git/commit/?id=7ac40f3eb8434961f70485247d883f5b3009dcf2
Comment 15 Larry the Git Cow gentoo-dev 2018-08-24 18:19:44 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/proj/gcc-config.git/commit/?id=9b907ef80bc421df23515afc4c306e4d96c67649

commit 9b907ef80bc421df23515afc4c306e4d96c67649
Author:     Sergei Trofimovich <slyfox@gentoo.org>
AuthorDate: 2018-08-24 17:36:57 +0000
Commit:     Sergei Trofimovich <slyfox@gentoo.org>
CommitDate: 2018-08-24 18:09:17 +0000

    Convert binary wrapper to a symlink wrapper.
    
    Before the change:
       /usr/bin/gcc and friends were a copy of /usr/$(libexecdir)/misc/gcc-config
    After the change:
       /usr/bin/gcc is a symlink to a real compiler binary. Examples:
           /usr/${CTARGET}/gcc-bin/${GCC_VER}/gcc (native)
           /usr/${CHOST}/${CTARGET}/gcc-bin/${GCC_VER}/gcc (cross)
    
    gcc-config is a binary wrapper that does (or did) a few things:
    
    - [removed in 2011] injects additional CFLAGS_${ABI}
    
      Removed in commit 7ac40f3eb8434961f70485247d883f5b3009dcf2
      "Stop auto appending CFLAGS_<abi> from the env."
    
    - traverses PATH for real compiler binary and reexecutes it.
    
    - reads /etc/env.d/05gcc-${CTARGET} as a fallback if PATH is empty.
    
    Today binary wrapper does only PATH resolution and re-execution.
    
    This change has a few minor benefits:
    
    - PATH will not contain explicit /usr/${CHOST}/${CTARGET}/gcc-bin/${GCC_VER}
      entry. This will make PATH shorter for those who have mavy cross-compilers
      installed.
    
    - compiler switch will not require sourcing '. /etc/profile' as changes are
      applied as soon an symlink is switched.
    
    - ccache will see gcc binary changes directly and react accordingly.
      Previously in default configuration ccache cache depended on state of
      /usr/$(libexecdir)/misc/gcc-config
    
      See bug #640958 where ccache did not notice USE=-pie -> USE=pie switch.
    
    - Reasoning about PATH ordering is straightforward: all available binaries
      (as symlinks) are in /usr/bin.
    
      See bug #255695 where PATH ordering changed and bug #626606 where
      people get confused on what is in /usr/bin/gcc binary.
    
    Bug: https://bugs.gentoo.org/626606
    Bug: https://bugs.gentoo.org/255695
    Bug: https://bugs.gentoo.org/640958
    Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>

 .gitignore                                         |   3 -
 Makefile                                           |   8 +-
 README                                             |  69 +----
 gcc-config                                         |  33 +--
 tests/rw-multi-native-configs/test.select          |   4 +-
 .../usr/lib/gcc-config/wrapper                     |   0
 tests/source/test.whitespace                       |   2 +-
 wrapper.c                                          | 323 ---------------------
 8 files changed, 28 insertions(+), 414 deletions(-)