Skip to content

Commit fb33d05

Browse files
committed
Rework riscv -march and -mabi detection
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.
1 parent 06c1289 commit fb33d05

File tree

1 file changed

+11
-17
lines changed

1 file changed

+11
-17
lines changed

src/lib.rs

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1958,25 +1958,19 @@ impl Build {
19581958
let mut parts = target.split('-');
19591959
if let Some(arch) = parts.next() {
19601960
let arch = &arch[5..];
1961-
if target.contains("linux") && arch.starts_with("64") {
1962-
cmd.args.push(("-march=rv64gc").into());
1963-
cmd.args.push("-mabi=lp64d".into());
1964-
} else if target.contains("freebsd") && arch.starts_with("64") {
1965-
cmd.args.push(("-march=rv64gc").into());
1966-
cmd.args.push("-mabi=lp64d".into());
1967-
} else if target.contains("openbsd") && arch.starts_with("64") {
1968-
cmd.args.push(("-march=rv64gc").into());
1969-
cmd.args.push("-mabi=lp64d".into());
1970-
} else if target.contains("linux") && arch.starts_with("32") {
1971-
cmd.args.push(("-march=rv32gc").into());
1972-
cmd.args.push("-mabi=ilp32d".into());
1973-
} else if arch.starts_with("64") {
1974-
cmd.args.push(("-march=rv".to_owned() + arch).into());
1975-
cmd.args.push("-mabi=lp64".into());
1961+
1962+
cmd.args.push(("-march=rv".to_owned() + arch).into());
1963+
1964+
// If riscv32gc-* or riscv64gc-* then double-float ABI,
1965+
// otherwise use soft-float ABI.
1966+
let float_abi = if arch.contains("g") { "d" } else { "" };
1967+
1968+
if arch.starts_with("64") {
1969+
cmd.args.push(("-mabi=lp64".to_owned() + float_abi).into());
19761970
} else {
1977-
cmd.args.push(("-march=rv".to_owned() + arch).into());
1978-
cmd.args.push("-mabi=ilp32".into());
1971+
cmd.args.push(("-mabi=ilp32".to_owned() + float_abi).into());
19791972
}
1973+
19801974
cmd.args.push("-mcmodel=medany".into());
19811975
}
19821976
}

0 commit comments

Comments
 (0)