[PATCH] D98113: [Driver] Also search FilePaths for compiler-rt before falling back

Jessica Clarke via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Mar 8 08:32:26 PST 2021


jrtc27 added a comment.

In D98113#2610775 <https://reviews.llvm.org/D98113#2610775>, @abidh wrote:

> In D98113#2609027 <https://reviews.llvm.org/D98113#2609027>, @jrtc27 wrote:
>
>> One thing that is currently rather ugly about BareMetal is that it ignores the AddArch argument. Once you have a sysroot, the architecture suffix is rather unnecessary, and given compiler-rt uses LLVM_ENABLE_PER_TARGET_RUNTIME_DIR to decide both whether to add a suffix and whether to add `lib/${OS}` to the install path, that means you can't nicely point compiler-rt at the sysroot as the install directory (well, unless you do something like make COMPILER_RT_OUTPUT_DIR point at the sysroot not the libdir and set COMPILER_RT_OS_DIR to `.` (or maybe the empty string also works)).
>
> Agree that setting the compiler-rt installation directory is not ideal. I remember I ended up doing some post installation steps to make sure that libraries were in right folder.
>
> Regarding this patch, currently Baremetal toolchain looks for compiler-rt in a multilib specific directory. Does that not solve the problem of finding compiler-rt for any given arch/abi combination automatically?

So, technically yes for RISC-V I believe we can do that. However that support code only really exists for RISC-V, and we have other architectures too we need to extend. This approach is entirely general with no lists of arch-specific combinations needed, and far more flexible. I also believe that conceptually compiler-rt does belong in the sysroot, not with the compiler. The libgcc-with-gcc model kind of makes sense for GCC given you have to configure GCC for a specific architecture, but for Clang there is no such coupling. This allows you to, say, use a system-provided Clang with your own bare-metal sysroot (not that that's our use-case, but it's a sensible one). The other way to see that compiler-rt doesn't really belong with the compiler is to look at the bootstrapping process: compiler-rt depends on a libc, typically newlib, which then depends on your compiler. So you have to build Clang, then build newlib, then go back and build compiler-rt to add it to your Clang. That gets rather annoying to manage in CI jobs.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D98113/new/

https://reviews.llvm.org/D98113



More information about the cfe-commits mailing list