* ./configure compiler-rt patch
@ 2018-02-13 14:53 Matúš Olekšák
2018-02-21 2:12 ` Rich Felker
0 siblings, 1 reply; 5+ messages in thread
From: Matúš Olekšák @ 2018-02-13 14:53 UTC (permalink / raw)
To: musl
[-- Attachment #1.1: Type: text/plain, Size: 305 bytes --]
Hi,
I have complete LLVM toolchain and I discovered that, detection of
compiler-rt is not working in ./configure. Because it is looking for
dynamic library compiler_rt but it doesn't exist. Instead it should ask
compiler about libgcc-file-name to get correct filename. I attached patch
to fix this issue.
[-- Attachment #1.2: Type: text/html, Size: 399 bytes --]
[-- Attachment #2: compiler-rt.patch --]
[-- Type: text/x-patch, Size: 519 bytes --]
--- a/configure
+++ b/configure
@@ -597,7 +597,8 @@
# Find compiler runtime library
test -z "$LIBCC" && tryldflag LIBCC -lgcc && tryldflag LIBCC -lgcc_eh
-test -z "$LIBCC" && tryldflag LIBCC -lcompiler_rt
+test -z "$LIBCC" && try_libcc=`$CC -print-libgcc-file-name 2>/dev/null` \
+ && tryldflag LIBCC "$try_libcc"
test -z "$LIBCC" && try_libcc=`$CC -print-file-name=libpcc.a 2>/dev/null` \
&& tryldflag LIBCC "$try_libcc"
printf "using compiler runtime libraries: %s\n" "$LIBCC"
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: ./configure compiler-rt patch
2018-02-13 14:53 ./configure compiler-rt patch Matúš Olekšák
@ 2018-02-21 2:12 ` Rich Felker
2018-02-21 10:30 ` Shiz
0 siblings, 1 reply; 5+ messages in thread
From: Rich Felker @ 2018-02-21 2:12 UTC (permalink / raw)
To: musl
On Tue, Feb 13, 2018 at 03:53:39PM +0100, Matúš Olekšák wrote:
> Hi,
> I have complete LLVM toolchain and I discovered that, detection of
> compiler-rt is not working in ./configure. Because it is looking for
> dynamic library compiler_rt but it doesn't exist. Instead it should ask
> compiler about libgcc-file-name to get correct filename. I attached patch
> to fix this issue.
> --- a/configure
> +++ b/configure
> @@ -597,7 +597,8 @@
>
> # Find compiler runtime library
> test -z "$LIBCC" && tryldflag LIBCC -lgcc && tryldflag LIBCC -lgcc_eh
> -test -z "$LIBCC" && tryldflag LIBCC -lcompiler_rt
> +test -z "$LIBCC" && try_libcc=`$CC -print-libgcc-file-name 2>/dev/null` \
> + && tryldflag LIBCC "$try_libcc"
> test -z "$LIBCC" && try_libcc=`$CC -print-file-name=libpcc.a 2>/dev/null` \
> && tryldflag LIBCC "$try_libcc"
> printf "using compiler runtime libraries: %s\n" "$LIBCC"
Sorry for the slow response. I think this probably okay, but if I
remember right, there has been discussion of this before and might be
more subtlety to doing it optimally. The nice property of the -lgcc
case (and the -lcompiler_rt case if it worked, but it doesn't) is that
it's immune to changes in compiler version; upgrading gcc without
rerunning configure won't cause it to fail.
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.
Note that -print-libgcc-file-name does work with pcc, at least modern
versions, so I think we could remove the pcc-specific check too at
some point.
Rich
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: ./configure compiler-rt patch
2018-02-21 2:12 ` Rich Felker
@ 2018-02-21 10:30 ` Shiz
2018-02-21 10:58 ` Dmitry Golovin
0 siblings, 1 reply; 5+ messages in thread
From: Shiz @ 2018-02-21 10:30 UTC (permalink / raw)
To: musl
[-- Attachment #1: Type: text/plain, Size: 1062 bytes --]
> On 21 Feb 2018, at 03:12, Rich Felker <dalias@libc.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
[-- Attachment #2: Message signed with OpenPGP --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: ./configure compiler-rt patch
2018-02-21 10:30 ` Shiz
@ 2018-02-21 10:58 ` Dmitry Golovin
0 siblings, 0 replies; 5+ messages in thread
From: Dmitry Golovin @ 2018-02-21 10:58 UTC (permalink / raw)
To: musl
21.02.2018, 12:30, "Shiz" <hi@shiz.me>:
>> On 21 Feb 2018, at 03:12, Rich Felker <dalias@libc.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
^ permalink raw reply [flat|nested] 5+ messages in thread
* ./configure compiler-rt patch
@ 2018-02-06 21:16 Matúš Olekšák
0 siblings, 0 replies; 5+ messages in thread
From: Matúš Olekšák @ 2018-02-06 21:16 UTC (permalink / raw)
To: musl
[-- Attachment #1.1: Type: text/plain, Size: 305 bytes --]
Hi,
I have complete LLVM toolchain and I discovered that, detection of
compiler-rt is not working in ./configure. Because it is looking for
dynamic library compiler_rt but it doesn't exist. Instead it should ask
compiler about libgcc-file-name to get correct filename. I attached patch
to fix this issue.
[-- Attachment #1.2: Type: text/html, Size: 341 bytes --]
[-- Attachment #2: compiler-rt.patch --]
[-- Type: text/x-patch, Size: 519 bytes --]
--- a/configure
+++ b/configure
@@ -597,7 +597,8 @@
# Find compiler runtime library
test -z "$LIBCC" && tryldflag LIBCC -lgcc && tryldflag LIBCC -lgcc_eh
-test -z "$LIBCC" && tryldflag LIBCC -lcompiler_rt
+test -z "$LIBCC" && try_libcc=`$CC -print-libgcc-file-name 2>/dev/null` \
+ && tryldflag LIBCC "$try_libcc"
test -z "$LIBCC" && try_libcc=`$CC -print-file-name=libpcc.a 2>/dev/null` \
&& tryldflag LIBCC "$try_libcc"
printf "using compiler runtime libraries: %s\n" "$LIBCC"
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2018-02-21 10:58 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-13 14:53 ./configure compiler-rt patch Matúš Olekšák
2018-02-21 2:12 ` Rich Felker
2018-02-21 10:30 ` Shiz
2018-02-21 10:58 ` Dmitry Golovin
-- strict thread matches above, loose matches on Subject: below --
2018-02-06 21:16 Matúš Olekšák
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/musl/
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).