Gentoo Archives: gentoo-dev

From: James Le Cuirot <chewi@g.o>
To: gentoo-dev <gentoo-dev@l.g.o>
Cc: James Le Cuirot <chewi@g.o>
Subject: [gentoo-dev] [PATCH 3/7] toolchain.eclass: Fix cross-compiling gcc for standalone prefix
Date: Sat, 21 Jan 2023 22:22:11
Message-Id: 20230121222037.29094-4-chewi@gentoo.org
In Reply to: [gentoo-dev] Allow prefixed systems to be cross-compiled by James Le Cuirot
1 Standalone prefix has always configured gcc with a sysroot, but the
2 location of this sysroot is different at build time when
3 cross-compiling. gcc has a separate configure option for that.
4
5 prefix-guest systems do not have a sysroot applied, as they use the
6 host's libc.
7
8 Move this code from the prefix profile into the eclass so that it's less
9 of a special case. We can avoid relying on the `BOOTSTRAP_RAP_STAGE2`
10 variable by checking for the `prefix-guest` USE flag instead, as a
11 prefix-guest profile is now used for RAP stage 2.
12
13 Signed-off-by: James Le Cuirot <chewi@g.o>
14 ---
15 eclass/toolchain.eclass | 15 +++++++++++++++
16 .../features/prefix/standalone/profile.bashrc | 3 ---
17 2 files changed, 15 insertions(+), 3 deletions(-)
18
19 diff --git a/eclass/toolchain.eclass b/eclass/toolchain.eclass
20 index 0dd23d93e383..479814f0df3e 100644
21 --- a/eclass/toolchain.eclass
22 +++ b/eclass/toolchain.eclass
23 @@ -1200,6 +1200,21 @@ toolchain_src_configure() {
24 confgcc+=( --enable-threads=posix )
25 ;;
26 esac
27 +
28 + if ! use prefix-guest ; then
29 + # GNU ld scripts, such as those in glibc, reference unprefixed paths
30 + # as the sysroot given here is automatically prepended. For
31 + # prefix-guest, we use the host's libc instead.
32 + if [[ -n ${EPREFIX} ]] ; then
33 + confgcc+=( --with-sysroot="${EPREFIX}" )
34 + fi
35 +
36 + # We need to build against the right headers and libraries. Again,
37 + # for prefix-guest, this is the host's.
38 + if [[ -n ${ESYSROOT} ]] ; then
39 + confgcc+=( --with-build-sysroot="${ESYSROOT}" )
40 + fi
41 + fi
42 fi
43
44 # __cxa_atexit is "essential for fully standards-compliant handling of
45 diff --git a/profiles/features/prefix/standalone/profile.bashrc b/profiles/features/prefix/standalone/profile.bashrc
46 index 3cdda77b9a88..043f766c37e9 100644
47 --- a/profiles/features/prefix/standalone/profile.bashrc
48 +++ b/profiles/features/prefix/standalone/profile.bashrc
49 @@ -21,9 +21,6 @@ if [[ ${CATEGORY}/${PN} == sys-devel/gcc && ${EBUILD_PHASE} == configure ]]; the
50 fi
51 eend $?
52 done
53 -
54 - # use sysroot of toolchain to get correct include and library at compile time
55 - EXTRA_ECONF="${EXTRA_ECONF} --with-sysroot=${EPREFIX}"
56 elif [[ ${CATEGORY}/${PN} == sys-devel/clang && ${EBUILD_PHASE} == configure ]]; then
57 ebegin "Use ${EPREFIX} as default sysroot"
58 sed -i -e "s@DEFAULT_SYSROOT \"\"@DEFAULT_SYSROOT \"${EPREFIX}\"@" "${S}"/CMakeLists.txt
59 --
60 2.39.1