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