[PATCH] D81946: [WIP][RISCV] Enable multilib support even without a detected GCC install

Edward Jones via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jun 16 09:54:17 PDT 2020


edward-jones created this revision.
edward-jones added reviewers: asb, simoncook, lenary.
Herald added subscribers: cfe-commits, evandro, luismarques, apazos, sameer.abuasal, pzheng, s.egerton, Jim, benna, psnobl, jocewei, PkmX, rkruppe, the_o, brucehoult, MartinMosbeck, rogfer01, zzheng, MaskRay, jrtc27, shiva0217, kito-cheng, niosHD, sabuasal, johnrusso, rbar, emaste.
Herald added a reviewer: espindola.
Herald added a project: clang.

Previously the driver would only report multilibs which already exist. This has been relaxed so that when there is no detected GCC installation the multilibs will be reported anyway.

In the absence of a GCC installation, the driver will look for libraries starting from the resource directory:

  <prefix>/lib/clang/<version>

This is slightly different to the path in the case where a GCC install is detected. in that case the resource directory includes the triple:

  <prefix>/lib/gcc/<triple>/<version>

In addition to the resource directory the driver will also look for libraries not installed alongside the compiler in the following directories:

In the absence of a detected GCC installation:

  <prefix>/lib/clang/<version>/../../../<triple>/lib

With a GCC installation:

  <prefix>/lib/gcc/<triple>/<version>/../../../../<triple>/lib

The calculation of the sysroot has also been updated. If a sysroot was not provided to the driver then the driver would try to derive it from the detected GCC installation. If this was not possible then it would be derived from the directory of the driver "<prefix>/bin/clang" as follows:

  <prefix>/bin/../<triple>

This uses the original triple as provided to the compiler, however this isn't ideal as the presence of multilibs means that riscv32 libraries/headers/tools may be installed under "<prefix>/riscv64-unknown-elf" instead of "<prefix>/riscv32-unknown-elf". The GCC installation detector already handles this by trying both the original triple *and* the triple of the biarch variant using the first directory with exists. This behaviour has been copied so the same occurs even without a gcc installation.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D81946

Files:
  clang/lib/Driver/ToolChains/Arch/RISCV.cpp
  clang/lib/Driver/ToolChains/Arch/RISCV.h
  clang/lib/Driver/ToolChains/Gnu.cpp
  clang/lib/Driver/ToolChains/RISCVToolchain.cpp
  clang/lib/Driver/ToolChains/RISCVToolchain.h
  clang/test/Driver/Inputs/multilib_riscv_elf_nogcc_tree/bin/riscv32-unknown-elf-ld
  clang/test/Driver/Inputs/multilib_riscv_elf_nogcc_tree/bin/riscv64-unknown-elf-ld
  clang/test/Driver/Inputs/multilib_riscv_elf_nogcc_tree/lib/clang/11.0.0/rv32i/ilp32/clang_rt.crtbegin-riscv32.o
  clang/test/Driver/Inputs/multilib_riscv_elf_nogcc_tree/lib/clang/11.0.0/rv32i/ilp32/clang_rt.crtend-riscv32.o
  clang/test/Driver/Inputs/multilib_riscv_elf_nogcc_tree/lib/clang/11.0.0/rv32i/ilp32/libclang_rt.builtins-riscv32.a
  clang/test/Driver/Inputs/multilib_riscv_elf_nogcc_tree/lib/clang/11.0.0/rv32iac/ilp32/clang_rt.crtbegin-riscv32.o
  clang/test/Driver/Inputs/multilib_riscv_elf_nogcc_tree/lib/clang/11.0.0/rv32iac/ilp32/clang_rt.crtend-riscv32.o
  clang/test/Driver/Inputs/multilib_riscv_elf_nogcc_tree/lib/clang/11.0.0/rv32iac/ilp32/libclang_rt.builtins-riscv32.a
  clang/test/Driver/Inputs/multilib_riscv_elf_nogcc_tree/lib/clang/11.0.0/rv32im/ilp32/clang_rt.crtbegin-riscv32.o
  clang/test/Driver/Inputs/multilib_riscv_elf_nogcc_tree/lib/clang/11.0.0/rv32im/ilp32/clang_rt.crtend-riscv32.o
  clang/test/Driver/Inputs/multilib_riscv_elf_nogcc_tree/lib/clang/11.0.0/rv32im/ilp32/libclang_rt.builtins-riscv32.a
  clang/test/Driver/Inputs/multilib_riscv_elf_nogcc_tree/lib/clang/11.0.0/rv32imac/ilp32/clang_rt.crtbegin-riscv32.o
  clang/test/Driver/Inputs/multilib_riscv_elf_nogcc_tree/lib/clang/11.0.0/rv32imac/ilp32/clang_rt.crtend-riscv32.o
  clang/test/Driver/Inputs/multilib_riscv_elf_nogcc_tree/lib/clang/11.0.0/rv32imac/ilp32/libclang_rt.builtins-riscv32.a
  clang/test/Driver/Inputs/multilib_riscv_elf_nogcc_tree/lib/clang/11.0.0/rv32imafc/ilp32f/clang_rt.crtbegin-riscv32.o
  clang/test/Driver/Inputs/multilib_riscv_elf_nogcc_tree/lib/clang/11.0.0/rv32imafc/ilp32f/clang_rt.crtend-riscv32.o
  clang/test/Driver/Inputs/multilib_riscv_elf_nogcc_tree/lib/clang/11.0.0/rv32imafc/ilp32f/libclang_rt.builtins-riscv32.a
  clang/test/Driver/Inputs/multilib_riscv_elf_nogcc_tree/lib/clang/11.0.0/rv64imac/lp64/clang_rt.crtbegin-riscv64.o
  clang/test/Driver/Inputs/multilib_riscv_elf_nogcc_tree/lib/clang/11.0.0/rv64imac/lp64/clang_rt.crtend-riscv64.o
  clang/test/Driver/Inputs/multilib_riscv_elf_nogcc_tree/lib/clang/11.0.0/rv64imac/lp64/libclang_rt.builtins-riscv64.a
  clang/test/Driver/Inputs/multilib_riscv_elf_nogcc_tree/lib/clang/11.0.0/rv64imafdc/lp64d/clang_rt.crtbegin-riscv64.o
  clang/test/Driver/Inputs/multilib_riscv_elf_nogcc_tree/lib/clang/11.0.0/rv64imafdc/lp64d/clang_rt.crtend-riscv64.o
  clang/test/Driver/Inputs/multilib_riscv_elf_nogcc_tree/lib/clang/11.0.0/rv64imafdc/lp64d/libclang_rt.builtins-riscv64.a
  clang/test/Driver/Inputs/multilib_riscv_elf_nogcc_tree/riscv64-unknown-elf/lib/crt0.o
  clang/test/Driver/Inputs/multilib_riscv_elf_nogcc_tree/riscv64-unknown-elf/lib/rv32i/ilp32/crt0.o
  clang/test/Driver/Inputs/multilib_riscv_elf_nogcc_tree/riscv64-unknown-elf/lib/rv32iac/ilp32/crt0.o
  clang/test/Driver/Inputs/multilib_riscv_elf_nogcc_tree/riscv64-unknown-elf/lib/rv32im/ilp32/crt0.o
  clang/test/Driver/Inputs/multilib_riscv_elf_nogcc_tree/riscv64-unknown-elf/lib/rv32imac/ilp32/crt0.o
  clang/test/Driver/Inputs/multilib_riscv_elf_nogcc_tree/riscv64-unknown-elf/lib/rv32imafc/ilp32f/crt0.o
  clang/test/Driver/Inputs/multilib_riscv_elf_nogcc_tree/riscv64-unknown-elf/lib/rv64imac/lp64/crt0.o
  clang/test/Driver/Inputs/multilib_riscv_elf_nogcc_tree/riscv64-unknown-elf/lib/rv64imafdc/lp64d/crt0.o
  clang/test/Driver/riscv32-toolchain-extra.c
  clang/test/Driver/riscv64-toolchain-extra.c

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D81946.271123.patch
Type: text/x-patch
Size: 33859 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200616/c61d9180/attachment-0001.bin>


More information about the cfe-commits mailing list