From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 8D052139694 for ; Mon, 29 May 2017 21:06:28 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 7C01921C04E; Mon, 29 May 2017 21:06:10 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 25CE0E0D1F for ; Mon, 29 May 2017 21:06:09 +0000 (UTC) Received: from pomiot (d202-252.icpnet.pl [109.173.202.252]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: mgorny) by smtp.gentoo.org (Postfix) with ESMTPSA id 69B843416ED; Mon, 29 May 2017 21:06:08 +0000 (UTC) Message-ID: <1496091964.12795.1.camel@gentoo.org> Subject: Re: [gentoo-dev] [PATCH] meson.eclass: implement basic cross-compiler support From: =?UTF-8?Q?Micha=C5=82_G=C3=B3rny?= To: gentoo-dev@lists.gentoo.org Date: Mon, 29 May 2017 23:06:04 +0200 In-Reply-To: <20170529205811.29385-1-floppym@gentoo.org> References: <20170529205811.29385-1-floppym@gentoo.org> Organization: Gentoo Content-Type: multipart/signed; micalg="pgp-sha512"; protocol="application/pgp-signature"; boundary="=-BTvZlDCICQoIMwZm7Ku6" X-Mailer: Evolution 3.22.6 Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-dev@lists.gentoo.org Reply-to: gentoo-dev@lists.gentoo.org Mime-Version: 1.0 X-Archives-Salt: 4fb3952b-745f-45c8-8650-7defbc01fc94 X-Archives-Hash: 47b275611f3a6c6cf6afc08764a87934 --=-BTvZlDCICQoIMwZm7Ku6 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On pon, 2017-05-29 at 16:58 -0400, Mike Gilbert wrote: > --- > eclass/meson.eclass | 74 +++++++++++++++++++++++++++++++++++++++++------= ------ > 1 file changed, 57 insertions(+), 17 deletions(-) >=20 > diff --git a/eclass/meson.eclass b/eclass/meson.eclass > index 758e4180ba7a..0fdb1d848973 100644 > --- a/eclass/meson.eclass > +++ b/eclass/meson.eclass > @@ -39,8 +39,7 @@ esac > =20 > if [[ -z ${_MESON_ECLASS} ]]; then > =20 > -# FIXME: We will need to inherit toolchain-funcs as well to support cros= sdev. > -inherit ninja-utils > +inherit ninja-utils toolchain-funcs > =20 > fi > =20 > @@ -71,17 +70,52 @@ DEPEND=3D">=3Ddev-util/meson-0.39.1 > # Optional meson arguments as Bash array; this should be defined before > # calling meson_src_configure. > =20 > -# Create a cross file for meson > -# fixme: This function should write a cross file as described at the > -# following url. > -# http://mesonbuild.com/Cross-compilation.html > -# _meson_create_cross_file() { > -# touch "${T}"/meson.crossfile > -# } > +# @FUNCTION: _meson_create_cross_file > +# @INTERNAL > +# @DESCRIPTION: > +# Creates a cross file. meson uses this to define settings for > +# cross-compilers. This function is called from meson_src_configure. > +_meson_create_cross_file() { > + # Reference: http://mesonbuild.com/Cross-compilation.html > + > + # system roughly corresponds to uname -s (lowercase) > + local system=3Dunknown > + case ${CHOST} in > + *-aix*) system=3Daix ;; > + *-cygwin*) system=3Dcygwin ;; > + *-darwin*) system=3Ddarwin ;; > + *-freebsd*) system=3Dfreebsd ;; > + *-linux*) system=3Dlinux ;; > + *-solaris*) system=3Dsunos ;; Don't you want to die on unknown system? Or is it likely to work anyway? > + esac > + > + local cpu_family=3D$(tc-arch) > + case ${cpu_family} in > + amd64) cpu_family=3Dx86_64 ;; > + arm64) cpu_family=3Daarch64 ;; That's purely mapping from known-wrong values, correct? Maybe it'd be reasonable to assert for all correct too, and fail on unknown? > + esac > + > + # This may require adjustment based on CFLAGS > + local cpu=3D${CHOST%%-*} > + > + cat > "${T}/meson.${CHOST}" <<-EOF > + [binaries] > + ar =3D '${AR}' > + c =3D '${CC}' > + cpp =3D '${CXX}' > + strip =3D '${STRIP}' > + > + [host_machine] > + system =3D '${system}' > + cpu_family =3D '${cpu_family}' > + cpu =3D '${cpu}' > + endian =3D '$(tc-endian)' > + EOF > +} > =20 > # @FUNCTION: meson_src_configure > # @DESCRIPTION: > -# This is the meson_src_configure function > +# This is the meson_src_configure function. > meson_src_configure() { > debug-print-function ${FUNCNAME} "$@" > =20 > @@ -94,13 +128,19 @@ meson_src_configure() { > --sysconfdir "${EPREFIX}/etc" > ) > =20 > -# fixme: uncomment this for crossdev support > -# if tc-is-cross-compiler; then > -# _meson_create_cross_file || die "unable to write meson cross file" > -# mesonargs+=3D( > -# --cross-file "${T}"/meson.crossfile > -# ) > -# fi > + # Both meson(1) and _meson_create_cross_file need these > + tc-export AR CC CXX STRIP Wouldn't it be reasonable to make them local first anyway? I would try to avoid polluting the environment. > + > + if tc-is-cross-compiler; then > + _meson_create_cross_file || die "unable to write meson cross file" > + mesonargs+=3D( > + --cross-file "${T}"/meson.${CHOST} > + ) > + # In cross mode, meson uses CC/CXX as the "build" compilers > + local -x AR=3D$(tc-getBUILD_AR) > + local -x CC=3D$(tc-getBUILD_CC) > + local -x CXX=3D$(tc-getBUILD_CXX) > + fi > =20 > # Append additional arguments from ebuild > mesonargs+=3D("${emesonargs[@]}") --=20 Best regards, Micha=C5=82 G=C3=B3rny --=-BTvZlDCICQoIMwZm7Ku6 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: This is a digitally signed message part Content-Transfer-Encoding: 7bit -----BEGIN PGP SIGNATURE----- iQKmBAABCgCQFiEEbbsHzE8NrQbqCv5BsHoa6u+0Rk4FAlksjTxfFIAAAAAALgAo aXNzdWVyLWZwckBub3RhdGlvbnMub3BlbnBncC5maWZ0aGhvcnNlbWFuLm5ldDZE QkIwN0NDNEYwREFEMDZFQTBBRkU0MUIwN0ExQUVBRUZCNDQ2NEUSHG1nb3JueUBn ZW50b28ub3JnAAoJELB6GurvtEZOX34QAMNumpX1PzA0iVqaoNiHvPICst+rPk+M RGMMcvR+dek6glevQ/NROyniKnkcDTKTdj9oW2xBTrnH4utUPms2xxYAG/bLx0Q9 hntzuW1p2DIAJy+DDZaGE99kHThk4iFafcHgb0CEJwIC30MnKC1yStS/W9ELKBIX moGnmMc0Hc9OwUMoM3AmEyacMCGuGkXL61ii3TxwyW/bN0vDY4m0x8G65A9iMSAu k3zjlZLlKF3NGI8eLhHfhYoQd0HvmJadnd1QoJopPST18v41lQPxTi7yK681A61z 8up57/sWkqkcp61N8aJiXpspInAbjAhc/ne8YE79HjxJP1/zb14fGTyPc+P4vDnN y4nMuWwCLpj1XGmCuUb8PiaxEIxKjykjB3VVJcAqLmRW0K4Xq1g/89pT90wIqPkB 64dQOQjrWTKmbPaB/E7710BB+R6c38UgvDXnZUadjBOw/rM2/faLeIetf1MCJ8xA qBkAjX+GiZRNMRi43hXukHCJUPFECJBeHHnXHeDnCSDzphfmvc+cO2Fqoy3GFfQt e7iNavGqDrR5p8YdWGtNoM+McfulZwdYpuC7TFheeHRZRcDVRNz+B8TOJN7DKjQr /71yPAW9wGBciz7QgbVdnr89z6q0/zOtMBviZqI60hY4E1vRjDwyfGWfvRhP+/f+ owRA/GG/sKJi =BFVE -----END PGP SIGNATURE----- --=-BTvZlDCICQoIMwZm7Ku6--