* [gentoo-dev] [PATCH 1/2] sysroot.eclass: New eclass for using a different sysroot
@ 2025-05-09 17:31 James Le Cuirot
2025-05-09 17:31 ` [gentoo-dev] [PATCH 2/2] waf-utils.eclass: Set up QEMU when cross-compiling James Le Cuirot
2025-05-09 18:29 ` [gentoo-dev] [PATCH 1/2] sysroot.eclass: New eclass for using a different sysroot Ulrich Müller
0 siblings, 2 replies; 4+ messages in thread
From: James Le Cuirot @ 2025-05-09 17:31 UTC (permalink / raw
To: gentoo-dev; +Cc: James Le Cuirot
This only has one function for now, but I intend to add a general
purpose sysroot wrapper script for use with Meson, Perl, and more. It
just needs longer in the oven.
Signed-off-by: James Le Cuirot <chewi@gentoo.org>
---
eclass/sysroot.eclass | 34 ++++++++++++++++++++++++++++++++++
1 file changed, 34 insertions(+)
create mode 100644 eclass/sysroot.eclass
diff --git a/eclass/sysroot.eclass b/eclass/sysroot.eclass
new file mode 100644
index 000000000000..73722154564a
--- /dev/null
+++ b/eclass/sysroot.eclass
@@ -0,0 +1,34 @@
+# Copyright 2025 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+# @ECLASS: sysroot.eclass
+# @MAINTAINER:
+# cross@gentoo.org
+# @AUTHOR:
+# James Le Cuirot <chewi@gentoo.org>
+# @SUPPORTED_EAPIS: 8
+# @BLURB: Common functions for using a different sysroot (e.g. cross-compiling)
+
+case ${EAPI} in
+ 7|8) ;;
+ *) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;;
+esac
+
+# @FUNCTION: qemu_arch
+# @DESCRIPTION:
+# Return the QEMU architecture name for the current CHOST. This name is used in
+# qemu-user binary filenames, e.g. qemu-ppc64le.
+qemu_arch() {
+ case "${CHOST}" in
+ armeb*) echo armeb ;;
+ arm*) echo arm ;;
+ hppa*) echo hppa ;;
+ i?86*) echo i386 ;;
+ mips64el*) [[ ${ABI} == n32 ]] && echo mipsn32el || echo mips64el ;;
+ mips64*) [[ ${ABI} == n32 ]] && echo mipsn32 || echo mips64 ;;
+ powerpc64le*) echo ppc64le ;;
+ powerpc64*) echo ppc64 ;;
+ powerpc*) echo ppc ;;
+ *) echo "${CHOST%%-*}" ;;
+ esac
+}
--
2.49.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [gentoo-dev] [PATCH 2/2] waf-utils.eclass: Set up QEMU when cross-compiling
2025-05-09 17:31 [gentoo-dev] [PATCH 1/2] sysroot.eclass: New eclass for using a different sysroot James Le Cuirot
@ 2025-05-09 17:31 ` James Le Cuirot
2025-05-09 18:23 ` James Le Cuirot
2025-05-09 18:29 ` [gentoo-dev] [PATCH 1/2] sysroot.eclass: New eclass for using a different sysroot Ulrich Müller
1 sibling, 1 reply; 4+ messages in thread
From: James Le Cuirot @ 2025-05-09 17:31 UTC (permalink / raw
To: gentoo-dev; +Cc: James Le Cuirot
waf supports executing binaries via a wrapper for cross-compiling. This
may already be handled by a QEMU outside this environment if binfmt_misc
has been used with the F flag, and we cannot add a cross-only dependency
on QEMU. For these reasons, this sets the prefix using QEMU_LD_PREFIX
rather adding QEMU's -L arg to the --cross-execute option, and it checks
whether QEMU is present before trying to use it.
I have used this to cross-compile Samba and its waf-based dependencies.
Signed-off-by: James Le Cuirot <chewi@gentoo.org>
---
eclass/waf-utils.eclass | 19 +++++++++++++++----
1 file changed, 15 insertions(+), 4 deletions(-)
diff --git a/eclass/waf-utils.eclass b/eclass/waf-utils.eclass
index 377b455de736..01e62d88bd81 100644
--- a/eclass/waf-utils.eclass
+++ b/eclass/waf-utils.eclass
@@ -1,4 +1,4 @@
-# Copyright 1999-2024 Gentoo Authors
+# Copyright 1999-2025 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
# @ECLASS: waf-utils.eclass
@@ -23,7 +23,7 @@ esac
if [[ -z ${_WAF_UTILS_ECLASS} ]]; then
_WAF_UTILS_ECLASS=1
-inherit multilib toolchain-funcs multiprocessing
+inherit multilib sysroot toolchain-funcs multiprocessing
# @ECLASS_VARIABLE: WAF_VERBOSE
# @USER_VARIABLE
@@ -79,7 +79,7 @@ waf-utils_src_configure() {
: "${WAF_BINARY:="${S}/waf"}"
- local conf_args=()
+ local conf_args=() CMD=()
local waf_help=$("${WAF_BINARY}" --help 2>/dev/null)
if [[ ${waf_help} == *--docdir* ]]; then
@@ -95,9 +95,20 @@ waf-utils_src_configure() {
conf_args+=( --mandir="${EPREFIX}"/usr/share/man )
fi
+ # waf supports executing binaries via a wrapper for cross-compiling. This
+ # may already be handled by a QEMU outside this environment if binfmt_misc
+ # has been used with the F flag, and we cannot add a cross-only dependency
+ # on QEMU. For these reasons, set the prefix using QEMU_LD_PREFIX rather
+ # than QEMU's -L arg, and check whether QEMU is present before using it.
+ if tc-is-cross-compiler; then
+ CMD+=( QEMU_LD_PREFIX="${SYSROOT}" )
+ local qemu=$(type -P "qemu-$(qemu_arch)")
+ [[ -n ${qemu} ]] && conf_args+=( --cross-compile --cross-execute="${qemu}" )
+ fi
+
tc-export AR CC CPP CXX RANLIB
- local CMD=(
+ CMD+=(
PYTHONHASHSEED=1
CCFLAGS="${CFLAGS}"
LINKFLAGS="${CFLAGS} ${LDFLAGS}"
--
2.49.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [gentoo-dev] [PATCH 2/2] waf-utils.eclass: Set up QEMU when cross-compiling
2025-05-09 17:31 ` [gentoo-dev] [PATCH 2/2] waf-utils.eclass: Set up QEMU when cross-compiling James Le Cuirot
@ 2025-05-09 18:23 ` James Le Cuirot
0 siblings, 0 replies; 4+ messages in thread
From: James Le Cuirot @ 2025-05-09 18:23 UTC (permalink / raw
To: gentoo-dev
[-- Attachment #1: Type: text/plain, Size: 833 bytes --]
On Fri, 2025-05-09 at 18:31 +0100, James Le Cuirot wrote:
> waf supports executing binaries via a wrapper for cross-compiling. This
> may already be handled by a QEMU outside this environment if binfmt_misc
> has been used with the F flag, and we cannot add a cross-only dependency
> on QEMU. For these reasons, this sets the prefix using QEMU_LD_PREFIX
> rather adding QEMU's -L arg to the --cross-execute option, and it checks
> whether QEMU is present before trying to use it.
>
> I have used this to cross-compile Samba and its waf-based dependencies.
>
> Signed-off-by: James Le Cuirot <chewi@gentoo.org>
Actually, hold that thought. I've considered cases where the architecture is
the same but the libc is different. While we could still use QEMU in that
case, it would be better not to. Let me rethink this.
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 858 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [gentoo-dev] [PATCH 1/2] sysroot.eclass: New eclass for using a different sysroot
2025-05-09 17:31 [gentoo-dev] [PATCH 1/2] sysroot.eclass: New eclass for using a different sysroot James Le Cuirot
2025-05-09 17:31 ` [gentoo-dev] [PATCH 2/2] waf-utils.eclass: Set up QEMU when cross-compiling James Le Cuirot
@ 2025-05-09 18:29 ` Ulrich Müller
1 sibling, 0 replies; 4+ messages in thread
From: Ulrich Müller @ 2025-05-09 18:29 UTC (permalink / raw
To: James Le Cuirot; +Cc: gentoo-dev
[-- Attachment #1: Type: text/plain, Size: 1262 bytes --]
>>>>> On Fri, 09 May 2025, James Le Cuirot wrote:
> --- /dev/null
> +++ b/eclass/sysroot.eclass
> @@ -0,0 +1,34 @@
> +# Copyright 2025 Gentoo Authors
> +# Distributed under the terms of the GNU General Public License v2
> +
> +# @ECLASS: sysroot.eclass
> +# @MAINTAINER:
> +# cross@gentoo.org
> +# @AUTHOR:
> +# James Le Cuirot <chewi@gentoo.org>
> +# @SUPPORTED_EAPIS: 8
> +# @BLURB: Common functions for using a different sysroot (e.g. cross-compiling)
> +
> +case ${EAPI} in
> + 7|8) ;;
This doesn't agree with the SUPPORTED_EAPIS above.
> + *) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;;
> +esac
> +
> +# @FUNCTION: qemu_arch
> +# @DESCRIPTION:
> +# Return the QEMU architecture name for the current CHOST. This name is used in
> +# qemu-user binary filenames, e.g. qemu-ppc64le.
> +qemu_arch() {
> + case "${CHOST}" in
The quotation marks aren't strictly necessary.
> + armeb*) echo armeb ;;
> + arm*) echo arm ;;
> + hppa*) echo hppa ;;
> + i?86*) echo i386 ;;
> + mips64el*) [[ ${ABI} == n32 ]] && echo mipsn32el || echo mips64el ;;
> + mips64*) [[ ${ABI} == n32 ]] && echo mipsn32 || echo mips64 ;;
> + powerpc64le*) echo ppc64le ;;
> + powerpc64*) echo ppc64 ;;
> + powerpc*) echo ppc ;;
> + *) echo "${CHOST%%-*}" ;;
> + esac
> +}
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 507 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-05-09 18:30 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-09 17:31 [gentoo-dev] [PATCH 1/2] sysroot.eclass: New eclass for using a different sysroot James Le Cuirot
2025-05-09 17:31 ` [gentoo-dev] [PATCH 2/2] waf-utils.eclass: Set up QEMU when cross-compiling James Le Cuirot
2025-05-09 18:23 ` James Le Cuirot
2025-05-09 18:29 ` [gentoo-dev] [PATCH 1/2] sysroot.eclass: New eclass for using a different sysroot Ulrich Müller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox