From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-qt1-x82d.google.com (mail-qt1-x82d.google.com [IPv6:2607:f8b0:4864:20::82d]) by sourceware.org (Postfix) with ESMTPS id 5B2583858401 for ; Wed, 27 Oct 2021 11:42:59 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 5B2583858401 Received: by mail-qt1-x82d.google.com with SMTP id 19so528319qtt.7 for ; Wed, 27 Oct 2021 04:42:59 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=W/HTi0a47zLW6YgzEpqmPEu0I0mMEoKRANwo/Z05c9U=; b=cpLfZsLnL6oIZCTLwk54TTEk91p3dfB8ZA0hm295kCggoyZmOKXr2mrnrMfHxcuDKR 7juw+ssjJImuWzoN9rV+IpOIkadLAHWRLK7IW1deZCW+y2gSceu/bnDaS/2QVjSgzmNI FIt7W4K7NfeZZ201mi7I8+MXNkxjWkJ1JD9SNeHmKQS+H5+L3ko1N35Dhot3QkyhgrBK FfC1p2FC3h4FZUTxalNVkjHKRxXnCPxa+I6BGGWamFx7KIs5dqXVtXWK2ov60sPqlQLz 88FXuG5DMKOLD1MXFjjCLnDMQrHmQ0dIGOy+I/hoHxz4iXJpOMXWh+jJgkpoQkC8V08g SglA== X-Gm-Message-State: AOAM531iLGTY/+8NLDsNR/22qpwE+eyBXE+RwkmXyEvIOL7ftVPCd5/R YRtwngmidI0dQ02J5RRpDq6rhsS1IrtXkQ== X-Google-Smtp-Source: ABdhPJx3tLrA6YA3no/zVBelhBm2VMUd7jCYf60mEuNlIojYFWXnpGUCjGg3I949WCQLqO74xPE50w== X-Received: by 2002:a05:622a:2cd:: with SMTP id a13mr30458516qtx.328.1635334978702; Wed, 27 Oct 2021 04:42:58 -0700 (PDT) Received: from ?IPV6:2804:431:c7cb:6672:6176:d3d6:1b13:4aed? ([2804:431:c7cb:6672:6176:d3d6:1b13:4aed]) by smtp.gmail.com with ESMTPSA id o5sm11758644qkl.50.2021.10.27.04.42.57 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 27 Oct 2021 04:42:58 -0700 (PDT) Message-ID: <32118e07-b497-0ba0-cd72-48a76a31e14f@linaro.org> Date: Wed, 27 Oct 2021 08:42:57 -0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.1.2 Subject: Re: [PATCH 2/3] Fix LIBC_PROG_BINUTILS for -fuse-ld=lld Content-Language: en-US To: Fangrui Song Cc: libc-alpha@sourceware.org, "H.J. Lu" References: <20211026200346.3371750-1-adhemerval.zanella@linaro.org> <20211026200346.3371750-3-adhemerval.zanella@linaro.org> <20211026204857.oxtoxlwfeh5gxop7@google.com> From: Adhemerval Zanella In-Reply-To: <20211026204857.oxtoxlwfeh5gxop7@google.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-13.2 required=5.0 tests=BAYES_00, BODY_8BITS, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 27 Oct 2021 11:43:01 -0000 On 26/10/2021 17:48, Fangrui Song wrote: > > On 2021-10-26, Adhemerval Zanella wrote: >> GCC does not print the correct linker when -fuse-ld=lld is used with >> the -print-prog-name=ld: >> >>  $ gcc -v 2>&1 | tail -n 1 >>  gcc version 11.2.0 (Ubuntu 11.2.0-7ubuntu2) >>  $ gcc >>  ld >> >> This is different than for gold: >> >>  $ gcc -fuse-ld=gold -print-prog-name=ld >>  ld.gold > > I think it may be debatable whether -fuse-ld={bfd,gold,lld} should > affect -print-prog-name=ld output. > >   # Should -fuse-ld= do anything with this? >   % aarch64-linux-gnu-gcc -print-prog-name=../bin/ld >   /usr/lib/gcc-cross/aarch64-linux-gnu/10/../../../../aarch64-linux-gnu/bin/../bin/ld I think it would make sense, it allows to query the underlying static linker used by the driver. What does not make much sense to me is allow arbitrary paths as input. > > gcc/gcc.c has OPT_fuse_ld_bfd but not OPT_fuse_ld_lld, which may explain > the behavior difference. I think this is was oversight from lld gcc support and any case we need to handle gcc that does not print the correct linker used if we want to allow a way to set a non-default linker. > > Clang does not have the GCC -fuse-ld= --print-prog-name=ld behavior. > > > > This option is used solely to support --with-binutils. Maybe we should just remove it, since it is just simplify the use of a different binutils and for clang it does not make sense (since it has different the integrated assembly and different tool names). >> Using ld.lld as the static linker name prints the expected result. >> >> This is only required when -fuse-ld=lld is used, if lld is used as >> the 'ld' programs (through a symlink) LIBC_PROG_BINUTILS works >> as expected. >> >> Checked on x86_64-linux-gnu. >> --- >> aclocal.m4 | 6 +++++- >> configure  | 6 +++++- >> 2 files changed, 10 insertions(+), 2 deletions(-) >> >> diff --git a/aclocal.m4 b/aclocal.m4 >> index c195c4db56..83da631822 100644 >> --- a/aclocal.m4 >> +++ b/aclocal.m4 >> @@ -114,8 +114,12 @@ if test -n "$path_binutils"; then >>     path_binutils=`(cd $path_binutils; pwd) | sed 's%/*$%/%'` >>     CC="$CC -B$path_binutils" >> fi >> +case "$CC" in >> +    *fuse-ld=lld*) LDNAME=ld.lld;; >> +    *)             LDNAME=ld;; > > Perhaps hard code -fuse-ld=bfd and -fuse-ld=gold as well? > > I think gcc -print-prog-name=ld.bfd is more robust than > gcc -print-prog-name=ld -fuse-ld=bfd. It outlines the missing gcc support, since with ld.bfd and ld.gold does work with gcc. I will maybe send a patch to remove LIBC_PROG_BINUTILS. > >> +esac >> AS=`$CC -print-prog-name=as` >> -LD=`$CC -print-prog-name=ld` >> +LD=`$CC -print-prog-name=$LDNAME` >> AR=`$CC -print-prog-name=ar` >> AC_SUBST(AR) >> OBJDUMP=`$CC -print-prog-name=objdump` >> diff --git a/configure b/configure >> index 39d75eb4ed..2a28c58cd6 100755 >> --- a/configure >> +++ b/configure >> @@ -4549,8 +4549,12 @@ if test -n "$path_binutils"; then >>     path_binutils=`(cd $path_binutils; pwd) | sed 's%/*$%/%'` >>     CC="$CC -B$path_binutils" >> fi >> +case "$CC" in >> +    *fuse-ld=lld*) LDNAME=ld.lld;; >> +    *)             LDNAME=ld;; >> +esac >> AS=`$CC -print-prog-name=as` >> -LD=`$CC -print-prog-name=ld` >> +LD=`$CC -print-prog-name=$LDNAME` >> AR=`$CC -print-prog-name=ar` >> >> OBJDUMP=`$CC -print-prog-name=objdump` >> --  >> 2.32.0 >>