How to make my own cross compile target such rv32imf-unknown-none-elf ? which runs on bare metal

is there any way to do this ?

i've tried to emit-llvm-ir, but inside the ir ,it always targets to the host platform, i dont know where to change it

This is documented in Adding a new target - Guide to Rustc Development.


Rebuilding rustc is probably overkill for your project. You likely just need to define a custom target and then use the -Zbuild-std option to build the standard library. Additionally, while don't know much about your target, rustc does support a few different riscv targets out of the box, it's worth running rustc --print target-list and seeing if any of them are appropriate.