Openwall GNU/*/Linux - a small security-enhanced Linux distro for servers
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date: Wed, 21 Feb 2018 12:58:15 +0200
From: Dmitry Golovin <dima@...ovin.in>
To: "musl@...ts.openwall.com" <musl@...ts.openwall.com>
Subject: Re: ./configure compiler-rt patch



21.02.2018, 12:30, "Shiz" <hi@...z.me>:
>>  On 21 Feb 2018, at 03:12, Rich Felker <dalias@...c.org> wrote:
>>
>>  It might be optimal to try the basename produced by
>>  -print-libgcc-file-name, stripping the "lib" and ".a" parts and using
>>  it with -l, to see if that works. But it might not actually work for
>>  anything other than gcc. I know it doesn't (or at least didn't in the
>>  past) work for pcc.
>
> Sadly, that won’t work for clang, to the best of my knowledge.
> Quickly tested on a macOS machine, but I think it’s the same anywhere:
>
> ~ » clang -rtlib=compiler-rt -print-libgcc-file-name
> /Applications/.../usr/lib/clang/9.0.0/lib/darwin17.4.0/libclang_rt.builtins-x86_64.a
> ~ » clang -lclang_rt.builtins-x86_64
> ld: library not found for -lclang_rt.builtins-x86_64
> clang: error: linker command failed with exit code 1 (use -v to see invocation)
>
> I’m fairly sure -lcompiler_rt used to work at some point, but it seems
> they stripped support, which makes sense given that compiler-rt is
> actually multiple things now, and this would refer to the builtins part
> of it.
>
> - Shiz

I can confirm on Linux with my toolchain:
$ clang -print-libgcc-file-name
/x86_64-pc-linux-musl/lib/clang/7.0.0/lib/linux/libclang_rt.builtins-x86_64.a
$ clang -lclang_rt.builtins-x86_64
/x86_64-pc-linux-musl/bin/ld.lld: error: unable to find library -lclang_rt.builtins-x86_64
clang-7.0: error: linker command failed with exit code 1 (use -v to see invocation)

The workaround would be then:
$ clang -L/x86_64-pc-linux-musl/lib/clang/7.0.0/lib/linux -lclang_rt.builtins-x86_64

In general case it comes to:
$ LIBGCCPATH="$(clang -print-libgcc-file-name)"
$ LIBGCCDIR="${LIBGCCPATH%/*}"
$ LIBGCCFILE="${LIBGCCPATH##*/lib}"
$ clang -L$LIBGCCDIR -l${LIBGCCFILE%*.a}

As a person who compiles musl with compiler-rt, I want this patch to be merged, because right now I set LIBCC="$(clang -print-libgcc-file-name)" parameter to musl's configure anyway.

Regards,
Dmitry

Powered by blists - more mailing lists

Your e-mail address:

Powered by Openwall GNU/*/Linux - Powered by OpenVZ