From: Fangrui Song <maskray@google.com>
To: Nick Desaulniers <ndesaulniers@google.com>,
Ilie Halip <ilie.halip@gmail.com>
Cc: Albert Ou <aou@eecs.berkeley.edu>,
Jordan Rupprecht <rupprecht@google.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
LKML <linux-kernel@vger.kernel.org>,
clang-built-linux <clang-built-linux@googlegroups.com>,
Palmer Dabbelt <palmer@dabbelt.com>,
Paul Walmsley <paul.walmsley@sifive.com>,
linux-riscv@lists.infradead.org,
Thomas Gleixner <tglx@linutronix.de>, Mao Han <han_mao@c-sky.com>
Subject: Re: [PATCH] riscv: fix vdso build with lld
Date: Thu, 2 Apr 2020 10:53:54 -0700 [thread overview]
Message-ID: <20200402175354.pzhzhumlqsjk66nu@google.com> (raw)
In-Reply-To: <CAKwvOdnasXV2Uw1r4we_46oGD_0Ybjanm7T_-9J83bdf6jeOAg@mail.gmail.com>
The comment of `With ld -R we can then ...` should be fixed as well.
On 2020-04-02, Nick Desaulniers wrote:
>+ Jordan, Fangrui
>
>On Thu, Apr 2, 2020 at 1:56 AM Ilie Halip <ilie.halip@gmail.com> wrote:
>>
>> When building with the LLVM linker this error occurrs:
>> LD arch/riscv/kernel/vdso/vdso-syms.o
>> ld.lld: error: no input files
>>
>> This happens because the lld treats -R as an alias to -rpath, as opposed
>> to ld where -R means --just-symbols.
>>
>> Use the long option name for compatibility between the two.
>>
>> Link: https://github.com/ClangBuiltLinux/linux/issues/805
>> Reported-by: Dmitry Golovin <dima@golovin.in>
>> Signed-off-by: Ilie Halip <ilie.halip@gmail.com>
>> ---
>> arch/riscv/kernel/vdso/Makefile | 3 ++-
>> 1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/arch/riscv/kernel/vdso/Makefile b/arch/riscv/kernel/vdso/Makefile
>> index 33b16f4212f7..19f7b9ea10ab 100644
>> --- a/arch/riscv/kernel/vdso/Makefile
>> +++ b/arch/riscv/kernel/vdso/Makefile
>> @@ -41,7 +41,8 @@ SYSCFLAGS_vdso.so.dbg = -shared -s -Wl,-soname=linux-vdso.so.1 \
>> $(obj)/vdso-dummy.o: $(src)/vdso.lds $(obj)/rt_sigreturn.o FORCE
>> $(call if_changed,vdsold)
>>
>> -LDFLAGS_vdso-syms.o := -r -R
>> +# lld aliases -R to -rpath; use the longer option name
>
>Thanks for the patch. Maybe the comment can be dropped? It doesn't
>make sense if there's no -R in the source file you're touching. If
>someone cares about why `--just-symbols` is spelled out, that's what
>`git log` or vim fugitive is for. Maybe the maintainer would be kind
>enough to just drop that line for you when merging?
>
>Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
>
>Jordan, Fangrui, thoughts on this? Sounds like something other users
>of LLD might run into porting their codebase to LLVM's linker.
Independently, I noticed this ~2 days ago.
https://reviews.llvm.org/D76885#1952860
GNU ld parses options with getopt_long and -j is recognized as
--just-symbols ('R') because there is no other long options prefixed with -j.
Now, the following comment applies. Basically, --just-symbols/-R is an
overloaded option. It can be used as an -rpath if the argument is a directory.
The best practice is to use either -rpath or --just-symbols, never -R.
// binutils-gdb/ld/lexsup.c
case 'R':
/* The GNU linker traditionally uses -R to mean to include
only the symbols from a file. The Solaris linker uses -R
to set the path used by the runtime linker to find
libraries. This is the GNU linker -rpath argument. We
try to support both simultaneously by checking the file
named. If it is a directory, rather than a regular file,
we assume -rpath was meant. */
{
struct stat s;
if (stat (optarg, &s) >= 0
&& ! S_ISDIR (s.st_mode))
{
lang_add_input_file (optarg,
lang_input_file_is_symbols_only_enum,
NULL);
break;
}
}
>$ ld.lld --help | grep \\-R
> -R <value> Alias for --rpath
>$ ld.bfd --help | grep \\-R
> -R FILE, --just-symbols FILE
>
>> +LDFLAGS_vdso-syms.o := -r --just-symbols
>> $(obj)/vdso-syms.o: $(obj)/vdso-dummy.o FORCE
>> $(call if_changed,ld)
>>
>> --
>> 2.17.1
>>
>
>
>--
>Thanks,
>~Nick Desaulniers
prev parent reply other threads:[~2020-04-02 17:54 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-02 8:55 [PATCH] riscv: fix vdso build with lld Ilie Halip
2020-04-02 17:35 ` Nick Desaulniers
2020-04-02 17:53 ` Fangrui Song [this message]
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=20200402175354.pzhzhumlqsjk66nu@google.com \
--to=maskray@google.com \
--cc=aou@eecs.berkeley.edu \
--cc=clang-built-linux@googlegroups.com \
--cc=gregkh@linuxfoundation.org \
--cc=han_mao@c-sky.com \
--cc=ilie.halip@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=ndesaulniers@google.com \
--cc=palmer@dabbelt.com \
--cc=paul.walmsley@sifive.com \
--cc=rupprecht@google.com \
--cc=tglx@linutronix.de \
/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 NNTP newsgroup(s).