From: David Craven Date: Tue, 24 Jul 2018 10:03:28 +0000 (+0200) Subject: [RISCV] Enable LLVM backend. X-Git-Url: https://git.lizzy.rs/?a=commitdiff_plain;h=2d5f62fb48536d69aa7de0d7504df278271ccf25;p=rust.git [RISCV] Enable LLVM backend. --- diff --git a/config.toml.example b/config.toml.example index 99073416334..cc40e96b316 100644 --- a/config.toml.example +++ b/config.toml.example @@ -62,7 +62,7 @@ # not built by default and the experimental Rust compilation targets that depend # on them will not work unless the user opts in to building them. By default the # `WebAssembly` target is enabled when compiling LLVM from scratch. -#experimental-targets = "WebAssembly" +#experimental-targets = "WebAssembly;RISCV" # Cap the number of parallel linker invocations when compiling LLVM. # This can be useful when building LLVM with debug info, which significantly diff --git a/src/librustc_llvm/build.rs b/src/librustc_llvm/build.rs index 5910e55def3..4e24a26983d 100644 --- a/src/librustc_llvm/build.rs +++ b/src/librustc_llvm/build.rs @@ -100,6 +100,10 @@ fn main() { optional_components.push("hexagon"); } + if major > 6 { + optional_components.push("riscv"); + } + // FIXME: surely we don't need all these components, right? Stuff like mcjit // or interpreter the compiler itself never uses. let required_components = &["ipo", diff --git a/src/librustc_llvm/lib.rs b/src/librustc_llvm/lib.rs index 05f6b5b5fbd..ffa97bd6fa5 100644 --- a/src/librustc_llvm/lib.rs +++ b/src/librustc_llvm/lib.rs @@ -90,6 +90,12 @@ fn init() { } LLVMInitializeMSP430Target, LLVMInitializeMSP430TargetMC, LLVMInitializeMSP430AsmPrinter); + init_target!(llvm_component = "riscv", + LLVMInitializeRISCVTargetInfo, + LLVMInitializeRISCVTarget, + LLVMInitializeRISCVTargetMC, + LLVMInitializeRISCVAsmPrinter, + LLVMInitializeRISCVAsmParser); init_target!(llvm_component = "sparc", LLVMInitializeSparcTargetInfo, LLVMInitializeSparcTarget, diff --git a/src/rustllvm/PassWrapper.cpp b/src/rustllvm/PassWrapper.cpp index a13e4ffa8f8..7305dc71cbf 100644 --- a/src/rustllvm/PassWrapper.cpp +++ b/src/rustllvm/PassWrapper.cpp @@ -171,6 +171,12 @@ bool LLVMRustPassManagerBuilderPopulateThinLTOPassManager( #define SUBTARGET_MSP430 #endif +#ifdef LLVM_COMPONENT_RISCV +#define SUBTARGET_RISCV SUBTARGET(RISCV) +#else +#define SUBTARGET_RISCV +#endif + #ifdef LLVM_COMPONENT_SPARC #define SUBTARGET_SPARC SUBTARGET(Sparc) #else @@ -192,7 +198,8 @@ bool LLVMRustPassManagerBuilderPopulateThinLTOPassManager( SUBTARGET_SYSTEMZ \ SUBTARGET_MSP430 \ SUBTARGET_SPARC \ - SUBTARGET_HEXAGON + SUBTARGET_HEXAGON \ + SUBTARGET_RISCV \ #define SUBTARGET(x) \ namespace llvm { \