Skip to content

Commit

Permalink
Rework riscv -march and -mabi detection
Browse files Browse the repository at this point in the history
Currently all the riscv*gc targets use the 'd' double-float ABI, and
soft-float otherwise. There's no need to detect the operating system
type. Fixes rust-lang#795.
  • Loading branch information
dramforever committed Mar 5, 2023
1 parent 06c1289 commit fb33d05
Showing 1 changed file with 11 additions and 17 deletions.
28 changes: 11 additions & 17 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1958,25 +1958,19 @@ impl Build {
let mut parts = target.split('-');
if let Some(arch) = parts.next() {
let arch = &arch[5..];
if target.contains("linux") && arch.starts_with("64") {
cmd.args.push(("-march=rv64gc").into());
cmd.args.push("-mabi=lp64d".into());
} else if target.contains("freebsd") && arch.starts_with("64") {
cmd.args.push(("-march=rv64gc").into());
cmd.args.push("-mabi=lp64d".into());
} else if target.contains("openbsd") && arch.starts_with("64") {
cmd.args.push(("-march=rv64gc").into());
cmd.args.push("-mabi=lp64d".into());
} else if target.contains("linux") && arch.starts_with("32") {
cmd.args.push(("-march=rv32gc").into());
cmd.args.push("-mabi=ilp32d".into());
} else if arch.starts_with("64") {
cmd.args.push(("-march=rv".to_owned() + arch).into());
cmd.args.push("-mabi=lp64".into());

cmd.args.push(("-march=rv".to_owned() + arch).into());

// If riscv32gc-* or riscv64gc-* then double-float ABI,
// otherwise use soft-float ABI.
let float_abi = if arch.contains("g") { "d" } else { "" };

if arch.starts_with("64") {
cmd.args.push(("-mabi=lp64".to_owned() + float_abi).into());
} else {
cmd.args.push(("-march=rv".to_owned() + arch).into());
cmd.args.push("-mabi=ilp32".into());
cmd.args.push(("-mabi=ilp32".to_owned() + float_abi).into());
}

cmd.args.push("-mcmodel=medany".into());
}
}
Expand Down

0 comments on commit fb33d05

Please sign in to comment.