This is an archive of the discontinued LLVM Phabricator instance.

Let Clang invoke CloudABI's linker
ClosedPublic

Authored by ed on Mar 11 2015, 5:32 AM.

Details

Summary

Now that CloudABI's target information and header search logic for Clang has been submitted, the only thing that remains to be done is adding support for CloudABI's linker.

CloudABI uses Binutils ld, although there is some work to use lld instead. This means that this code is largely based on what we use on FreeBSD. There are some exceptions, however:

  • Only static linking is performed. CloudABI does not support any dynamically linked executables.
  • CloudABI uses compiler-rt, libc++ and libc++abi unconditionally. Link in these libraries instead of using libgcc_s, libstdc++, etc.
  • We must ensure that the .eh_frame_hdr is present to make C++ exceptions work properly.

Diff Detail

Repository
rL LLVM

Event Timeline

ed updated this revision to Diff 21694.Mar 11 2015, 5:32 AM
ed retitled this revision from to Let Clang invoke CloudABI's linker.
ed updated this object.
ed edited the test plan for this revision. (Show Details)
ed added a reviewer: echristo.
ed set the repository for this revision to rL LLVM.
ed added a subscriber: Unknown Object (MLST).

Hi Chandler,

Would you by any chance have some spare cycles to take a look at this change?

Thanks,
Ed

echristo edited edge metadata.Mar 19 2015, 11:53 AM

Why not just pass all of these down via the driver normally instead of hardcoding options via a tool?

-eric

ed added a comment.Mar 19 2015, 2:44 PM

Hi Eric,

Why not just pass all of these down via the driver normally instead of hardcoding options via a tool?

Could you please clarify this for me? Are you referring to the fact that -Bstatic and --eh-frame-hdr are passed to the linker unconditionally?

The latter already seems to happen for some of the other architectures, for example on NetBSD. Regarding -Bstatic: it turns out it's a no-op. It has no effect, as the linker does not know how to do dynamic linking anyway. Still, it is more consistent to pass it along, as the CRT object files that are passed in are purely intended for static linkage.

If CloudABI would ever gain support for dynamic linkage, we wouldn't want Clang to call the linker in a way where it wants to do dynamic linkage, while still providing CRT object files that can only be used for static linkage.

echristo accepted this revision.Mar 25 2015, 5:15 PM
echristo edited edge metadata.

Sure, ok then.

-eric

This revision is now accepted and ready to land.Mar 25 2015, 5:15 PM
This revision was automatically updated to reflect the committed changes.