From: Fangrui Song <maskray@google.com>
To: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Cc: libc-alpha@sourceware.org, "H.J. Lu" <hjl.tools@gmail.com>
Subject: Re: [PATCH 2/3] Fix LIBC_PROG_BINUTILS for -fuse-ld=lld
Date: Tue, 26 Oct 2021 13:48:57 -0700 [thread overview]
Message-ID: <20211026204857.oxtoxlwfeh5gxop7@google.com> (raw)
In-Reply-To: <20211026200346.3371750-3-adhemerval.zanella@linaro.org>
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
gcc/gcc.c has OPT_fuse_ld_bfd but not OPT_fuse_ld_lld, which may explain
the behavior difference.
Clang does not have the GCC -fuse-ld= --print-prog-name=ld behavior.
>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.
>+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
>
next prev parent reply other threads:[~2021-10-26 20:49 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-26 20:03 [PATCH 0/3] Improve lld support and current status Adhemerval Zanella
2021-10-26 20:03 ` [PATCH 1/3] elf: Disable ifuncmain{1,5,5pic,5pie} when using LLD Adhemerval Zanella
2021-10-29 19:49 ` Fangrui Song
2021-10-26 20:03 ` [PATCH 2/3] Fix LIBC_PROG_BINUTILS for -fuse-ld=lld Adhemerval Zanella
2021-10-26 20:48 ` Fangrui Song [this message]
2021-10-27 11:42 ` Adhemerval Zanella
2021-10-26 20:03 ` [PATCH 3/3] Check if linker also support -mtls-dialect=gnu2 Adhemerval Zanella
2021-10-27 2:04 ` Fāng-ruì Sòng
2021-10-29 0:56 ` Fāng-ruì Sòng
2021-10-26 20:33 ` [PATCH 0/3] Improve lld support and current status Fangrui Song
2021-10-27 13:11 ` Adhemerval Zanella
2021-10-28 1:06 ` Fangrui Song
2021-10-28 1:18 ` Fangrui Song
2021-10-28 17:40 ` Adhemerval Zanella
2021-10-28 11:48 ` Adhemerval Zanella
2021-10-27 22:39 ` Tulio Magno Quites Machado Filho
2021-10-27 22:50 ` Tulio Magno Quites Machado Filho
2021-11-05 7:23 ` lld status with powerpc64 Fangrui Song
2021-11-05 7:45 ` Fangrui Song
2021-11-05 13:58 ` Adhemerval Zanella
2021-11-05 19:32 ` Adhemerval Zanella
2021-11-05 19:38 ` H.J. Lu
2021-11-05 19:40 ` H.J. Lu
2021-11-05 19:50 ` Fāng-ruì Sòng
2021-11-07 14:24 ` Bill Schmidt
2021-11-08 11:37 ` Adhemerval Zanella
2021-11-08 13:26 ` Bill Schmidt
2021-11-08 13:54 ` Adhemerval Zanella
2021-11-08 13:59 ` Bill Schmidt
2021-11-08 14:11 ` Adhemerval Zanella
2021-11-08 14:12 ` Bill Schmidt
[not found] ` <OFD215FC7A.323066CE-ON00258787.0051DA95-00258787.00532945@ibm.com>
2021-11-08 22:38 ` Fangrui Song
2021-11-09 12:20 ` Adhemerval Zanella
2021-10-27 23:37 ` [PATCH 0/3] Improve lld support and current status Fangrui Song
2021-10-28 17:27 ` Tulio Magno Quites Machado Filho
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20211026204857.oxtoxlwfeh5gxop7@google.com \
--to=maskray@google.com \
--cc=adhemerval.zanella@linaro.org \
--cc=hjl.tools@gmail.com \
--cc=libc-alpha@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).