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 0DC13138334 for ; Fri, 13 Sep 2019 14:39:10 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id CA02CE0CBA; Fri, 13 Sep 2019 14:39:04 +0000 (UTC) Received: from mail-lf1-x144.google.com (mail-lf1-x144.google.com [IPv6:2a00:1450:4864:20::144]) (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 89E42E0CA3 for ; Fri, 13 Sep 2019 14:39:03 +0000 (UTC) Received: by mail-lf1-x144.google.com with SMTP id u28so1547221lfc.5 for ; Fri, 13 Sep 2019 07:39:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Ym47tAkVQbnJVcSaRTAYv7YkkzZDozBpX1HD0yBbAn0=; b=hgBBL+70QXYydfUBHuRDgTMTUN9NLstji/6pxtoYovfyAbqAwoP9XfpcqAbM1pUSxL HesJ3k4ShnNnmC7GBIaOfZ3oM+IxqIYWr1Z5InBWAXNa7QRW3ddupkjBSTV7M5/u0gVt vPF+GmIeyGu65nDCKXa9F03eApxCslOxNuvWqoqmDF3Jhn/hWvGsd5FxzLjbDwDeaGRl 7cSqkTJ8+JX1RKEd7M886Ekp+a+OVjB8zWvwkdnLAkCYqOM5eqT1dTriAgAWeWp4wrzQ hAxfiD7G0A7l1V7mIXDAZjA8yWWyteNnPrNCL5Hz6S41Z2fCoMI0WSs29d7ZHxX4IF1J +L8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Ym47tAkVQbnJVcSaRTAYv7YkkzZDozBpX1HD0yBbAn0=; b=Bq7SUvWNfJQ+xTADny5I42jCfb1FNEFZtROYeKifrEUK+v4u27ZCCrtgRf9vA03Ph4 gRpz4kDui1FYWt8o7tfXKh05XPfse1BMgD11r1pCx+e7EPccJOutXTVkYkTmn1MeftMk VW4RLr2QGVIUs4+N5G/ZIbVB8lwE2yAFsiEvGe7/a/SIUt4bRwKRmBlUni8jIjorolfE eae9bjEwNV/IEVkV2TvrKnzMKBUnSypTg9wPXfa3Jfv8vfGZ1Pn5bBc5P8EUulqR0nV0 HmVA+1+6gmMoZ2hVfc2Nv3mZekma51q6Sz31B3XbywMfQwLxQe44ULXePCWTYuFe7MtH ofSQ== X-Gm-Message-State: APjAAAU7NS81baG2tq6PXzWeLeMwl4cBiN8i2pKznvhYO3iTBpgeHBeY Kg5L5DCiz/nlhEgrWddLOQMdAGMBde+V9zA/c3h+c9Flz1hZ3g== X-Google-Smtp-Source: APXvYqyzienkTgebWNySt1DSdmCw5zorGS7xwh9qWpsymEIHZi0DZjj8OOVTtOLIZD7VioxmfvXgQHD3KwnHdBlAIF4= X-Received: by 2002:a19:741a:: with SMTP id v26mr31698641lfe.79.1568385541608; Fri, 13 Sep 2019 07:39:01 -0700 (PDT) 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 References: <20190912113240.226571-1-manojgupta@google.com> In-Reply-To: From: Manoj Gupta Date: Fri, 13 Sep 2019 07:38:50 -0700 Message-ID: Subject: Re: [gentoo-dev] Re: [PATCH] toolchain-funcs: Add tc-ld-is-lld helper. To: Ulrich Mueller Cc: gentoo-dev@lists.gentoo.org Content-Type: text/plain; charset="UTF-8" X-Archives-Salt: a6b9094c-624f-4ff5-bc54-26c43f8f20f4 X-Archives-Hash: 254cd615bd2dc17e8a29ff895329a51b On Fri, Sep 13, 2019 at 7:32 AM Ulrich Mueller wrote: > > >>>>> 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. > >> > >> Signed-off-by: Manoj Gupta > >> --- > >> eclass/toolchain-funcs.eclass | 30 ++++++++++++++++++++++++++++++ > >> 1 file changed, 30 insertions(+) > >> > >> diff --git a/eclass/toolchain-funcs.eclass b/eclass/toolchain-funcs.eclass > >> index 7bd90bb4e4a..e358d484417 100644 > >> --- a/eclass/toolchain-funcs.eclass > >> +++ b/eclass/toolchain-funcs.eclass > >> @@ -453,6 +453,36 @@ tc-ld-is-gold() { > >> return 1 > >> } > >> > >> +# @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=$($(tc-getLD "$@") --version 2>&1) > > Why 2>&1 here, and not 2>/dev/null? > > >> + if [[ ${out} == *"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="${T}/test-tc-lld" > >> + cat <<-EOF > "${base}.c" > >> + int main() { return 0; } > >> + EOF > >> + out=$($(tc-getCC "$@") ${CFLAGS} ${CPPFLAGS} ${LDFLAGS} -Wl,--version "${base}.c" -o "${base}" 2>&1) > > Ditto. > > >> + rm -f "${base}"* > >> + if [[ ${out} == *"LLD"* ]] ; then > >> + return 0 > >> + fi > >> + > >> + # No lld here! > >> + return 1 > > The previous 6 lines could be shortened to one: > [[ ${out} == *"LLD"* ]] Thanks for the review. I did it this way to make this an exact copy of tc-ld-is-gold function above it except the LLD checks. Should I also change the tc-ld-is-gold function? > > >> +} > >> + > >> # @FUNCTION: tc-ld-disable-gold > >> # @USAGE: [toolchain prefix] > >> # @DESCRIPTION: