Gentoo Archives: gentoo-dev

From: Joshua Kinard <kumba@g.o>
To: gentoo-dev@l.g.o
Subject: Re: [gentoo-dev] [PATCH] kernel-2.eclass: Make xmakeopts an array for spaces in toolchain vars
Date: Mon, 23 Jan 2023 16:20:16
Message-Id: 7bd2f495-313f-beeb-3f54-55cc98bc61cc@gentoo.org
In Reply to: [gentoo-dev] [PATCH] kernel-2.eclass: Make xmakeopts an array for spaces in toolchain vars by James Le Cuirot
1 On 1/21/2023 06:03, James Le Cuirot wrote:
2 > Variables like CC can have spaces for additional arguments. This is
3 > particularly useful for reliably setting the sysroot.
4 >
5 > Signed-off-by: James Le Cuirot <chewi@g.o>
6 > ---
7 > eclass/kernel-2.eclass | 21 +++++++++++++++------
8 > 1 file changed, 15 insertions(+), 6 deletions(-)
9 >
10 > diff --git a/eclass/kernel-2.eclass b/eclass/kernel-2.eclass
11 > index 873d4a204669..f7fcf15743f0 100644
12 > --- a/eclass/kernel-2.eclass
13 > +++ b/eclass/kernel-2.eclass
14 > @@ -1,4 +1,4 @@
15 > -# Copyright 1999-2022 Gentoo Authors
16 > +# Copyright 1999-2023 Gentoo Authors
17 > # Distributed under the terms of the GNU General Public License v2
18 >
19 > # @ECLASS: kernel-2.eclass
20 > @@ -756,13 +756,22 @@ env_setup_xmakeopts() {
21 >
22 > # When cross-compiling, we need to set the ARCH/CROSS_COMPILE
23 > # variables properly or bad things happen !
24 > - xmakeopts="ARCH=${KARCH}"
25 > + xmakeopts=( ARCH="${KARCH}" )
26 > if [[ ${CTARGET} != ${CHOST} ]] && ! cross_pre_c_headers; then
27 > - xmakeopts="${xmakeopts} CROSS_COMPILE=${CTARGET}-"
28 > + xmakeopts+=( CROSS_COMPILE="${CTARGET}-" )
29 > elif type -p ${CHOST}-ar >/dev/null; then
30 > - xmakeopts="${xmakeopts} CROSS_COMPILE=${CHOST}-"
31 > + xmakeopts+=( CROSS_COMPILE="${CHOST}-" )
32 > fi
33 > - xmakeopts="${xmakeopts} HOSTCC=$(tc-getBUILD_CC) CC=$(tc-getCC) LD=$(tc-getLD) AR=$(tc-getAR) NM=$(tc-getNM) OBJCOPY=$(tc-getOBJCOPY) READELF=$(tc-getREADELF) STRIP=$(tc-getSTRIP)"
34 > + xmakeopts+=(
35 > + HOSTCC="$(tc-getBUILD_CC)"
36 > + CC="$(tc-getCC)"
37 > + LD="$(tc-getLD)"
38 > + AR="$(tc-getAR)"
39 > + NM="$(tc-getNM)"
40 > + OBJCOPY="$(tc-getOBJCOPY)"
41 > + READELF="$(tc-getREADELF)"
42 > + STRIP="$(tc-getSTRIP)"
43 > + )
44 > export xmakeopts
45 > }
46 >
47 > @@ -850,7 +859,7 @@ install_headers() {
48 > local ddir=$(kernel_header_destdir)
49 >
50 > env_setup_xmakeopts
51 > - emake headers_install INSTALL_HDR_PATH="${ED}"${ddir}/.. ${xmakeopts}
52 > + emake headers_install INSTALL_HDR_PATH="${ED}"${ddir}/.. "${xmakeopts[@]}"
53 >
54 > # let other packages install some of these headers
55 > rm -rf "${ED}"${ddir}/scsi || die #glibc/uclibc/etc...
56
57 Can we perhaps use this opportunity to make "xmakeopts" more clear via a better name, as well as uppercase it
58 to indicate that it is an exported variable? E.g., something like "CROSS_MAKEOPTS" is more clear to the
59 reader than "xmakeopts", IMHO.
60
61 I realize such a change may be a tad invasive to the eclass and possibly touch some ebuilds, so that may need
62 to be a separate patch that this proposed change would then be based off of.
63
64 --
65 Joshua Kinard
66 Gentoo/MIPS
67 kumba@g.o
68 rsa6144/5C63F4E3F5C6C943 2015-04-27
69 177C 1972 1FB8 F254 BAD0 3E72 5C63 F4E3 F5C6 C943
70
71 "The past tempts us, the present confuses us, the future frightens us. And our lives slip away, moment by
72 moment, lost in that vast, terrible in-between."
73
74 --Emperor Turhan, Centauri Republic

Replies