Closed djkoloski closed 6 months ago
I'll take a second look tomorrow. I got it compiling but didn't test any feature functionality.
It looks like all of the extensions are getting passed through -march
by slicing them off of the target name, with the exceptions of 32-bit linux
targets and 64-bit linux
, freebsd
, and netbsd
targets. Those override -march=rv32/64gc
exactly, as per this PR. In the default case though, these extensions are getting passed through generically. Here's the snippet in question:
if target.starts_with("riscv32") || target.starts_with("riscv64") {
// get the 32i/32imac/32imc/64gc/64imac/... part
let mut parts = target.split('-');
if let Some(arch) = parts.next() {
let arch = &arch[5..];
if arch.starts_with("64") {
if target.contains("linux")
| target.contains("freebsd")
| target.contains("netbsd")
| target.contains("linux")
{
cmd.args.push(("-march=rv64gc").into());
cmd.args.push("-mabi=lp64d".into());
} else {
cmd.args.push(("-march=rv".to_owned() + arch).into());
cmd.args.push("-mabi=lp64".into());
}
} else if arch.starts_with("32") {
if target.contains("linux") {
cmd.args.push(("-march=rv32gc").into());
cmd.args.push("-mabi=ilp32d".into());
} else {
cmd.args.push(("-march=rv".to_owned() + arch).into());
cmd.args.push("-mabi=ilp32".into());
}
} else {
cmd.args.push("-mcmodel=medany".into());
}
}
}
So this PR should be ready to merge. I was testing with riscv32imc-unknown-none-elf
so I should be hitting those branches.
Rust supports a variety of RISC-V targets which may include optional features in the first segment of the target triple. When invoking clang for these targets, we need to remove these features since clang doesn't use them.