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 34D90138334 for ; Fri, 13 Sep 2019 14:32:42 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 9D9A3E0C37; Fri, 13 Sep 2019 14:32:38 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 476C8E0BD8 for ; Fri, 13 Sep 2019 14:32:36 +0000 (UTC) Received: from a1i15 (host2092.kph.uni-mainz.de [134.93.134.92]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: ulm) by smtp.gentoo.org (Postfix) with ESMTPSA id 24F5B34B108; Fri, 13 Sep 2019 14:32:33 +0000 (UTC) From: Ulrich Mueller To: Manoj Gupta Cc: gentoo-dev@lists.gentoo.org Subject: Re: [gentoo-dev] Re: [PATCH] toolchain-funcs: Add tc-ld-is-lld helper. References: <20190912113240.226571-1-manojgupta@google.com> Date: Fri, 13 Sep 2019 16:32:24 +0200 In-Reply-To: (Manoj Gupta's message of "Fri, 13 Sep 2019 07:11:03 -0700") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) 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 X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha256; protocol="application/pgp-signature" X-Archives-Salt: 162b468d-170d-41ef-805e-f9bc2221c750 X-Archives-Hash: 83333e7495eb1e7026c4a90c404e95bd --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable >>>>> On Fri, 13 Sep 2019, Manoj Gupta wrote: >> LLD is a new linker for LLVM project. >> Add tc-ld-is-lld helper to be able to detect it. >>=20 >> Signed-off-by: Manoj Gupta >> --- >> eclass/toolchain-funcs.eclass | 30 ++++++++++++++++++++++++++++++ >> 1 file changed, 30 insertions(+) >>=20 >> diff --git a/eclass/toolchain-funcs.eclass b/eclass/toolchain-funcs.ecla= ss >> index 7bd90bb4e4a..e358d484417 100644 >> --- a/eclass/toolchain-funcs.eclass >> +++ b/eclass/toolchain-funcs.eclass >> @@ -453,6 +453,36 @@ tc-ld-is-gold() { >> return 1 >> } >>=20=20 >> +# @FUNCTION: tc-ld-is-lld >> +# @USAGE: [toolchain prefix] >> +# @DESCRIPTION: >> +# Return true if the current linker is set to lld. >> +tc-ld-is-lld() { >> + local out >> + >> + # First check the linker directly. >> + out=3D$($(tc-getLD "$@") --version 2>&1) Why 2>&1 here, and not 2>/dev/null? >> + if [[ ${out} =3D=3D *"LLD"* ]] ; then >> + return 0 >> + fi >> + >> + # Then see if they're selecting lld via compiler flags. >> + # Note: We're assuming they're using LDFLAGS to hold the >> + # options and not CFLAGS/CXXFLAGS. >> + local base=3D"${T}/test-tc-lld" >> + cat <<-EOF > "${base}.c" >> + int main() { return 0; } >> + EOF >> + out=3D$($(tc-getCC "$@") ${CFLAGS} ${CPPFLAGS} ${LDFLAGS} -Wl,--= version "${base}.c" -o "${base}" 2>&1) Ditto. >> + rm -f "${base}"* >> + if [[ ${out} =3D=3D *"LLD"* ]] ; then >> + return 0 >> + fi >> + >> + # No lld here! >> + return 1 The previous 6 lines could be shortened to one: [[ ${out} =3D=3D *"LLD"* ]] >> +} >> + >> # @FUNCTION: tc-ld-disable-gold >> # @USAGE: [toolchain prefix] >> # @DESCRIPTION: --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAEBCAAdFiEEZlHkP3TnuTbxrN0HwwkGhRxhwnMFAl17qHgACgkQwwkGhRxh wnO63gf+N4XUwVpHXRsakm94WFjNJYxh3gTv8HnmodcKEcEzMhIue66EYVWdRkUq mdVPUQzCiXA4QrXcHVyhl+9+fr4zCn2b3x7sEHuReHyk0IiCK6w1KYhpv99IviMg zAzMGrCs9XdyJ5kKK7oSMj71gBFFZIHqOflk1gLGMuSgOa1wTS9S3XXvL3x+nb9M S/CXFYe102aqqcWzC1kUpUE76hF43c9D+QpzRF+4hsdHPIctuTRlk0EuVUZAFgnK h5SfNe9kXIpbz7w1S7rKB5RrtCO0ZCI9L0Lpg0jl8KTgSqWqgf1FQFuVlEPGHmrQ TABRH8EhDmi17oA/k3Ly11GmwakpWQ== =cVds -----END PGP SIGNATURE----- --=-=-=--