Gentoo Archives: gentoo-dev

From: Mike Gilbert <floppym@g.o>
To: Gentoo Dev <gentoo-dev@l.g.o>
Subject: Re: [gentoo-dev] [PATCH] toolchain.eclass: set CHOST for gcc-config calls
Date: Tue, 27 Dec 2016 17:04:36
Message-Id: CAJ0EP43c9TMEyVKbbZrC2pJDp0HXdSvsHZWkjPKfLJts08OAEQ@mail.gmail.com
In Reply to: Re: [gentoo-dev] [PATCH] toolchain.eclass: set CHOST for gcc-config calls by Joakim Tjernlund
1 On Tue, Dec 27, 2016 at 6:10 AM, Joakim Tjernlund
2 <Joakim.Tjernlund@××××××××.com> wrote:
3 > On Tue, 2016-12-27 at 00:22 -0800, Daniel Campbell wrote:
4 >> On 12/26/2016 12:22 PM, Mike Gilbert wrote:
5 >> > Bug: https://bugs.gentoo.org/603776
6 >> > ---
7 >> > eclass/toolchain.eclass | 8 ++++----
8 >> > 1 file changed, 4 insertions(+), 4 deletions(-)
9 >> >
10 >> > diff --git a/eclass/toolchain.eclass b/eclass/toolchain.eclass
11 >> > index 55249b00249b..97511ee12440 100644
12 >> > --- a/eclass/toolchain.eclass
13 >> > +++ b/eclass/toolchain.eclass
14 >> > @@ -2119,13 +2119,13 @@
15 >> >
16 >> > do_gcc_config() {
17 >> > if ! should_we_gcc_config ; then
18 >> > - env -i ROOT="${ROOT}" gcc-config --use-old --force
19 >> > + env -i CHOST="${CHOST}" ROOT="${ROOT}" gcc-config --use-old --force
20 >> > return 0
21 >> > fi
22 >> >
23 >> > local current_gcc_config target
24 >> >
25 >> > - current_gcc_config=$(env -i ROOT="${ROOT}" gcc-config -c ${CTARGET} 2>/dev/null)
26 >> > + current_gcc_config=$(env -i CHOST="${CHOST}" ROOT="${ROOT}" gcc-config -c ${CTARGET} 2>/dev/null)
27 >> > if [[ -n ${current_gcc_config} ]] ; then
28 >> > local current_specs use_specs
29 >> > # figure out which specs-specific config is active
30 >> > @@ -2159,12 +2159,12 @@ should_we_gcc_config() {
31 >> > # if the current config is invalid, we definitely want a new one
32 >> > # Note: due to bash quirkiness, the following must not be 1 line
33 >> > local curr_config
34 >> > - curr_config=$(env -i ROOT="${ROOT}" gcc-config -c ${CTARGET} 2>&1) || return 0
35 >> > + curr_config=$(env -i CHOST="${CHOST}" ROOT="${ROOT}" gcc-config -c ${CTARGET} 2>&1) || return 0
36 >> >
37 >> > # if the previously selected config has the same major.minor (branch) as
38 >> > # the version we are installing, then it will probably be uninstalled
39 >> > # for being in the same SLOT, make sure we run gcc-config.
40 >> > - local curr_config_ver=$(env -i ROOT="${ROOT}" gcc-config -S ${curr_config} | awk '{print $2}')
41 >> > + local curr_config_ver=$(env -i CHOST="${CHOST}" ROOT="${ROOT}" gcc-config -S ${curr_config} | awk
42 >> > '{print $2}')
43 >> >
44 >> > local curr_branch_ver=$(get_version_component_range 1-2 ${curr_config_ver})
45 >> >
46 >> >
47 >>
48 >> Seems like an obvious bug and fix; is there any reason passing CHOST
49 >> around might be a bad idea? It seems to me that it enforces the behavior
50 >> it's meant to have to begin with and makes it more obvious that CHOST is
51 >> used.
52 >
53 > Will that work for cross toolchains well?
54
55 I was hoping someone would be paying enough attention to ask this question. ;-)
56
57 I *think* it will still work for cross-toolchains. If someone can
58 think of a way this will break, please share.
59
60 For a typical cross-compiler build, CHOST is unchanged from the value
61 typically in make.conf, but CTARGET gets set to the "cross" arch.
62
63 In the case where we are cross-compiling a native compiler, CHOST
64 would be taken from ${ROOT}/etc/portage/make.conf, and ROOT would
65 typically be something like /usr/${cross_arch}/. So I think we are
66 safe there as well.
67
68 What I'm very unsure of is cross-compiling a cross-compiler CBUILD !=
69 CHOST != CTARGET. That requires a bit of thought. I'm not sure we even
70 really support that in toolchain.eclass though.

Replies