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

Peter Smith via cfe-commits cfe-commits at lists.llvm.org
Mon Jun 20 04:44:34 PDT 2016


>From what I can see, the EABI type is used to decide if certain
__aeabi_ prefixed functions such as __aeabi_idiv are available. If
Musl differs in function availability from the GNU library here I
think you'll need a Musl EABI type. However if there is no difference
you should be able to use the EABI::GNU type for Musl.

You might find http://reviews.llvm.org/D12413 helpful here
(introduction of -meabi option).

Peter


On 20 June 2016 at 11:59, Lei Zhang <zhanglei.april at gmail.com> wrote:
> 2016-06-20 17:37 GMT+08:00 Peter Smith <peter.smith at linaro.org>:
>> Hello Lei,
>
> Hi, thanks for your reply!
>
>> I agree with Rafael that this is currently missing a few critical
>> things right now, especially in the llvm patch.
>>
>> My (limited) understanding of musl is that it intends to support the
>> same interface as GNUEABI and GNUEABIHF, but it is obviously a
>> different implementation.
>>
>> This is what I could find with a basic grep for GNUAEABI and working
>> out from there.
>>
>> Clang patch
>> I'm assuming you are only intending to support Musl on linux, and not BSD.
>
> Yes.
>
>> ToolChains.cpp
>> - getDynamicLinker()
>> There is a Triple.getEnvironment() == llvm::triple::GNUEABIHF which
>> selects between ld-linux-armhf.so.3 or ld-linux.so.3. I think you'll
>> need ld-linux-armhf.so.3 for MUSLHF here as well.
>
> Actually musl's dynamic linker has a different naming scheme from
> glibc's, which is handled by an extra chunk of code in the patch. The
> code you mentioned won't be reached when musl is present, and thus
> need no change.
>
>> LLVM patch
>> ARMSubtarget.h
>> - isTargetGNUAEABI()
>> I think you'll need to check all the callsites of this function, and
>> check what you want isTargetMusl() to do. At present I think you'll
>> want them to do the same thing in all cases except finding the
>> implementation. There looks to be a trade off between adding MUSCL and
>> MUSCLHF to isTargetGNUAEABI(), adding something like
>> isTargetGNUAEABIInterface() and adding isTargetMusl() to all the
>> callsites.
>>
>> - isTargetEHABICompatible()
>> I'm making the assumption that musl supports the ARM exceptions EHABI,
>> if so you'll want to add MUSL and MUSLHF here.
>
> I'm not 100% sure about this. Could some insider from musl confirm this?
>
>> - isTargetHardFloat()
>> You'll want to add MUSLHF here.
>>
>> ARMTargetMachine.cpp
>> - computeTargetABI()
>> You'll want to add MUSL and MUSLHF alongside GNUEABI and GNUEABIHF in
>> the switch.
>>
>> Hope this helps
>
> In addition to what you mentioned, perhaps I should also add "Musl" as
> a new EABI type in TargetOptions.h (in LLVM), just side by side with
> "GNU", and change relevant bits in LLVM and clang accordingly.
>
>
> Thanks again,
> Lei


More information about the cfe-commits mailing list