From LLVM 11.0, the RISC-V targets will need to add some target-specific module flags when generating LLVM IR inside Rustc (this is a change we're requiring of all RISC-V LLVM frontends, and is needed to support LTO).
I had a quick look through
librustc_codegen_llvm and it doesn't seem like any other targets need to do this.
I presume the correct approach is to start all the way from the llvmrust C++ layer (because there's no way of adding target flags which can error on conflicts, otherwise), and then try to thread the information down from somewhere target-specific.
I note there are two places the information could potentially be added:
- The target-specific abi lowering code (
- The target definitions. Guidance on which might turn out to be better would be helfpful.