• [gentoo-dev] [PATCH 1/2] sysroot.eclass: New eclass for using a differe

    From James Le Cuirot@21:1/5 to All on Fri May 9 19:40:01 2025
    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
  • From James Le Cuirot@21:1/5 to All on Fri May 9 19:40:01 2025
    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+
  • From James Le Cuirot@21:1/5 to James Le Cuirot on Fri May 9 20:30:02 2025
    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.

    -----BEGIN PGP SIGNATURE-----

    iQJFBAABCAAvFiEEPxcZ3tkwcedKm2a8EiZBXQDdMTcFAmgeSCsRHGNoZXdpQGdl bnRvby5vcmcACgkQEiZBXQDdMTfwIxAAkeGhJzrgtNWpv0BoJXwJlolvtsMOZo2L ek/H6tA+ACB+rocrWpMrsRKZ5g8KdgvCQQvW2PQgUbBLBV+P9y+FD76IzO0bcMp/ r7j5FWc908psvWunq94hn4BzeXSZ2tgoNIPArstp/OnBQmVJQ7qg3NfCQGhC5LSK s3nZXDkqaQ+hhdsKSwH211gdmabCxlzWnraIy97YGaqUefXigImxJU0ULRiBuBTo xeFdHxvNnN8x/pYMVFF2by+azIWQDt3UlLsRZQSCyMRtFSYyiD9SkQMxAY/0um7M qDs7uau7zdIbneetl34thugyQUTUUfn/salDm+zfUjRsNU5K5tihcWJA1uZmKrXc KC74/vRfimEFWRZ4AT3mnVagrv9qGhrR34vf01myAAvntq6eOb8+5UAJQmkDGFJW PU/C9BjngVqzoz5PvnxoE4DeXLemB9KS7n3qstLkb3+55D/lOoQLiv8DBgZUeHiH 0Ud4S9UXOKqSf1jkcMBGGQPWctvZlhHZ+UraG7XG+f/HtDPO1p70QcfleGUXvgpV pufylt/aBAbvXu40kwV+wzP7souBWCjRE/pRdRX5yn3OxV+XfWyeu3/jdQ5X3Fl1 OYhmQe/fZT0qGNoWm78NwMM7qkK4thfF3CwmlamcD1pNtY11kB/GAnoMUiPEE8/2
    XFUN36yWrOc=
    =f2m7
    -----END PGP SIGNATURE-----

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From =?utf-8?Q?Ulrich_M=C3=BCller?=@21:1/5 to All on Fri May 9 20:30:01 2025
    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
    +}

    -----BEGIN PGP SIGNATURE-----

    iQFDBAEBCAAtFiEEtDnZ1O9xIP68rzDbUYgzUIhBXi4FAmgeSXAPHHVsbUBnZW50 b28ub3JnAAoJEFGIM1CIQV4uBGkIAM7+UFBOMCq9kr6wSH+7yuUCWA+Vsrik3R90 kaZ7uI4WsjAEdgD/C+GXWyL4MVSf0k6FyXDlJnA0Ckz84UA1yQ+4snbhMSYNfnSP QzGPUySobS7Bho5bCq+H65e+dmKqwy3fPtDBBAuSOQYIaqNCoBeyUIyCdnxZiJbB RgNeLDFyIYTNqwBsp6T4U2oxQnPKHYRoXK01QXL2CY3RbbBaNn8ycvMMYcYHRDbV EmNbGTakGLHkh/8Xn8FUDhxUr5uXC7qlN9Y4yZUgYpKL2fveaxv+E9xaUsu7y2Pj W/y8+Wm1hHni6n8g2top8+Xdlw+ptXgS4tqf+80fSMjE02qpFGI=
    =bxAW
    -----END PGP SIGNATURE-----

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)