[gentoo-musl] Re: Add support for musl-libc on Linux

Felix Janda via cfe-commits cfe-commits at lists.llvm.org
Mon Jun 13 06:21:55 PDT 2016


[Added CC to the musl list]

Lei Zhang wrote:
> 2016-06-13 3:07 GMT+08:00 Joerg Sonnenberger <joerg at bec.de>:
> > On Sun, Jun 12, 2016 at 10:51:11AM +0800, Lei Zhang via llvm-commits wrote:
> >> Hi,
> >>
> >> I'm replying to this thread; sorry I wasn't subscribed to the list,
> >> thus cannot reply to it directly.
> >>
> >> http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20160606/161733.html
> >>
> >> Joerg, thanks for your reply. Could you please tell me what kind of
> >> test cases I should prepare?
> >
> > The target/triple parser has a unit test in
> > unittests/ADT/TripleTest.cpp. The rest should get output validation in
> > clang's test/Driver directory. Not sure which one is the primary
> > GNU/Linux test.
> 
> Thanks for the pointer :)
> 
> The patches are re-attached with test cases included. Do they look sane enough?

> --- lib/Driver/ToolChains.cpp   (revision 272546)
> +++ lib/Driver/ToolChains.cpp   (working copy)
> @@ -4152,6 +4152,8 @@
>
>    if (Triple.isAndroid())
>      return Triple.isArch64Bit() ? "/system/bin/linker64" : "/system/bin/linker";
> +  else if (Triple.getEnvironment() == llvm::Triple::Musl)
> +    return "/lib/ld-musl-" + Triple.getArchName().str() + ".so.1";

It does not seem to me that the dynamic linker name detection will work
on most archs not in the test cases. For example, the arm gentoo musl
stage3's have the target triple

armv7a-hardfloat-linux-musleabi

and the dynamic linker name

/lib/ld-musl-armhf.so.1

Generally, the dynamic linker name takes the form
"/lib/ld-musl-$ARCH$SUBARCH.so.1", where the definite source for the
values of $ARCH and $SUBARCH is musl's configure script.

It seems difficult to get all cases right and some of them might not be
very interesting, but it would be nice to have a more intelligent patch.
See for example

http://git.alpinelinux.org/cgit/aports/plain/main/clang/clang-0004-Add-musl-targets-and-dynamic-linker.patch

Felix


More information about the cfe-commits mailing list