Skip to content

Commit 2d5f62f

Browse files
committed
[RISCV] Enable LLVM backend.
1 parent 8c069ce commit 2d5f62f

File tree

4 files changed

+19
-2
lines changed

4 files changed

+19
-2
lines changed

config.toml.example

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
# not built by default and the experimental Rust compilation targets that depend
6363
# on them will not work unless the user opts in to building them. By default the
6464
# `WebAssembly` target is enabled when compiling LLVM from scratch.
65-
#experimental-targets = "WebAssembly"
65+
#experimental-targets = "WebAssembly;RISCV"
6666

6767
# Cap the number of parallel linker invocations when compiling LLVM.
6868
# This can be useful when building LLVM with debug info, which significantly

src/librustc_llvm/build.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,10 @@ fn main() {
100100
optional_components.push("hexagon");
101101
}
102102

103+
if major > 6 {
104+
optional_components.push("riscv");
105+
}
106+
103107
// FIXME: surely we don't need all these components, right? Stuff like mcjit
104108
// or interpreter the compiler itself never uses.
105109
let required_components = &["ipo",

src/librustc_llvm/lib.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,12 @@ pub fn initialize_available_targets() {
9090
LLVMInitializeMSP430Target,
9191
LLVMInitializeMSP430TargetMC,
9292
LLVMInitializeMSP430AsmPrinter);
93+
init_target!(llvm_component = "riscv",
94+
LLVMInitializeRISCVTargetInfo,
95+
LLVMInitializeRISCVTarget,
96+
LLVMInitializeRISCVTargetMC,
97+
LLVMInitializeRISCVAsmPrinter,
98+
LLVMInitializeRISCVAsmParser);
9399
init_target!(llvm_component = "sparc",
94100
LLVMInitializeSparcTargetInfo,
95101
LLVMInitializeSparcTarget,

src/rustllvm/PassWrapper.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,12 @@ bool LLVMRustPassManagerBuilderPopulateThinLTOPassManager(
171171
#define SUBTARGET_MSP430
172172
#endif
173173

174+
#ifdef LLVM_COMPONENT_RISCV
175+
#define SUBTARGET_RISCV SUBTARGET(RISCV)
176+
#else
177+
#define SUBTARGET_RISCV
178+
#endif
179+
174180
#ifdef LLVM_COMPONENT_SPARC
175181
#define SUBTARGET_SPARC SUBTARGET(Sparc)
176182
#else
@@ -192,7 +198,8 @@ bool LLVMRustPassManagerBuilderPopulateThinLTOPassManager(
192198
SUBTARGET_SYSTEMZ \
193199
SUBTARGET_MSP430 \
194200
SUBTARGET_SPARC \
195-
SUBTARGET_HEXAGON
201+
SUBTARGET_HEXAGON \
202+
SUBTARGET_RISCV \
196203

197204
#define SUBTARGET(x) \
198205
namespace llvm { \

0 commit comments

Comments
 (0)