This is an archive of the discontinued LLVM Phabricator instance.

Add initial support for multilibs in Baremetal toolchain.
ClosedPublic

Authored by abidh on Dec 11 2020, 11:45 AM.

Details

Summary

This patch add support of riscv multilibs in the Baremetal toolchain. It is
a bit different to what is done in GNU.cpp as we are not iterating a
GNU sysroot to find the multilibs. This is intended for an llvm only
toolchain. We are not checking for the presence of any runtime bits to
enable a specific multilib.

I have structured the patch so that other targets for which
there is no multilibs support yet in Baremetal.cpp (e.g. arm-none-eabi)
will not be affected. Patch also allows some multilibs reuse.

Long term, I would like to go in the direction of data-driven specification of
multilib directories and flags.

Diff Detail

Event Timeline

abidh created this revision.Dec 11 2020, 11:45 AM
abidh requested review of this revision.Dec 11 2020, 11:45 AM
jroelofs added inline comments.Dec 14 2020, 9:21 AM
clang/lib/Driver/ToolChains/BareMetal.cpp
58

no else after return

169

I think the suffix ought to go after lib/baremetal, rather than before to match what is specified by Multilib::gccSuffix() (yeah, bad name... sorry). That will group all of them under a top-level folder like has been done for other platforms (i.e. darwin, linux, etc). Then it becomes a per-platform decision whether the contents are organized into folders like in a gcc toolchain, or if the lib names themselves get the discriminator (i.e. libclang_rt.${kind}.a)

jroelofs added inline comments.Dec 14 2020, 9:27 AM
clang/lib/Driver/ToolChains/BareMetal.cpp
169

minor nit: the RuntimesDir should be suffixed by the gccSuffix, not the osSuffix (even though they're the same in this case).

abidh updated this revision to Diff 311650.Dec 14 2020, 10:41 AM

Handle review comments.

This revision is now accepted and ready to land.Dec 14 2020, 10:43 AM
This revision was automatically updated to reflect the committed changes.
abidh marked 3 inline comments as done.
Herald added a project: Restricted Project. · View Herald TranscriptDec 14 2020, 1:00 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript
zixuan-wu added inline comments.
clang/lib/Driver/ToolChains/BareMetal.cpp
177

I think the multilib osSuffix added here will make every multilib contain include dir, and those include dirs are the same. For lib, there should be different multilib dir.

So it's better to add osSuffix at construction function like following I think instead of be part of sysroot.

if (!SysRoot.empty()) {
    llvm::sys::path::append(SysRoot, "lib", SelectedMultilib.osSuffix());
    getFilePaths().push_back(std::string(SysRoot));
  }

@abidh

abidh added inline comments.Jul 29 2022, 11:06 AM
clang/lib/Driver/ToolChains/BareMetal.cpp
177

The multilib include directories are not necessarily the same. In my opinion, having a separate include and lib directory for every multilib is much cleaner then having all multilib share an include directory and then you put multilib specific directories inside that.

zixuan-wu added inline comments.Jul 31 2022, 6:59 PM
clang/lib/Driver/ToolChains/BareMetal.cpp
177

So you are going to copy times of same include headers? For now, GCC on RISCV is just sharing one same include directory and having multiple multilib directory under lib of root.