Merging RISCVToolChain and BareMetal toolchains

I recently discovered that we have two RISC-V toolchain classes in Clang that are intended to support baremetal development:

  1. RISCVToolChain is used when an existing GCC installation is present.
  2. BareMetal is used otherwise.

I think this creates an unnecessary maintenance overhead and increases confusion as evidenced by [clang] Enable --gcc-install-dir for RISCV baremetal toolchains by mihailo-stojanovic · Pull Request #71803 · llvm/llvm-project · GitHub. I don’t think that support for using an existing GCC installation is RISC-V specific and would be also beneficial to other targets supported by the BareMetal toolchain.

I would like to propose extending the BareMetal toolchain to support using an existing GCC installation, and then deprecating and removing the RISCVToolChain.

1 Like

On a similar note I wondered why there is CSKYToolChain which from reading the initial commit ([Clang][CSKY] Add the CSKY target and compiler driver · llvm/llvm-project@97e4960 · GitHub) just sounds like a typical Linux on CSKY Toolchain that could be merged into Linux.cpp/Gnu.cpp and BareMetal support.

I can’t speak for the RISCV toolchain itself, would very much like to see the functionality in the BareMetal toolchain so all targets that support it can benefit.

This sounds fantastic to me.