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

Lei Zhang via cfe-commits cfe-commits at lists.llvm.org
Mon Jun 20 03:59:20 PDT 2016

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.


> 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,

More information about the cfe-commits mailing list