Cross Compiling Using LLVM for Risc-v on x-86 machine

I want to compile a c file for risc-v using a x-86 machine. I want a step to step guide for the same.

Thanks

That’s GCC not LLVM; clearly not the right answer when someone asks in an LLVM forum.

The short answer is: build LLVM+Clang following the default configuration, and clang -target riscv64 will act as a cross-compiler. There are numerous resources on the Internet about how to use Clang as a cross-compiler, even ChatGPT can probably regurgitate something close enough to true for those that like to use that kind of thing.

@jrtc27
I used to build cross compilers in this way before, but it wouldn’t to build riscv target on x86 without “–gcc-toolchain” .
now LLVM can be used in combination with the RISC-V GNU Compiler Toolchain to build RISC-V applications.
GitHub - riscv-collab/riscv-gnu-toolchain: GNU toolchain for RISC-V, including GCC
i did some tests and it work .

If there are any mistakes, please point them out, thanks.