Skip to content

Commit bd9c671

Browse files
authored
Match abi and march settings for riscv on linux (#583)
* Match abi and march settings for riscv on linux linux distros have agreed on using lp64d on 64bit and ilp32d on 32bit for ABI, we also need to match the march values which can support these ABIs and therefore use rv64gc and rv32gc for march Fixes errors when compiling libstd-rs e.g. warning: Assembler messages: warning: Error: -march=rv64: first ISA extension must be `e', `i' or `g' warning: cc1plus: error: '-march=rv64': first ISA subset must be 'e', 'i' or 'g' * Recognise riscv musl tuples Signed-off-by: Khem Raj <raj.khem@gmail.com>
1 parent ae68934 commit bd9c671

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/lib.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1691,14 +1691,17 @@ impl Build {
16911691
let mut parts = target.split('-');
16921692
if let Some(arch) = parts.next() {
16931693
let arch = &arch[5..];
1694-
cmd.args.push(("-march=rv".to_owned() + arch).into());
16951694
if target.contains("linux") && arch.starts_with("64") {
1695+
cmd.args.push(("-march=rv64gc").into());
16961696
cmd.args.push("-mabi=lp64d".into());
16971697
} else if target.contains("linux") && arch.starts_with("32") {
1698+
cmd.args.push(("-march=rv32gc").into());
16981699
cmd.args.push("-mabi=ilp32d".into());
16991700
} else if arch.starts_with("64") {
1701+
cmd.args.push(("-march=rv".to_owned() + arch).into());
17001702
cmd.args.push("-mabi=lp64".into());
17011703
} else {
1704+
cmd.args.push(("-march=rv".to_owned() + arch).into());
17021705
cmd.args.push("-mabi=ilp32".into());
17031706
}
17041707
cmd.args.push("-mcmodel=medany".into());
@@ -2434,6 +2437,9 @@ impl Build {
24342437
"riscv-none-embed",
24352438
]),
24362439
"riscv64gc-unknown-linux-gnu" => Some("riscv64-linux-gnu"),
2440+
"riscv32gc-unknown-linux-gnu" => Some("riscv32-linux-gnu"),
2441+
"riscv64gc-unknown-linux-musl" => Some("riscv64-linux-musl"),
2442+
"riscv32gc-unknown-linux-musl" => Some("riscv32-linux-musl"),
24372443
"s390x-unknown-linux-gnu" => Some("s390x-linux-gnu"),
24382444
"sparc-unknown-linux-gnu" => Some("sparc-linux-gnu"),
24392445
"sparc64-unknown-linux-gnu" => Some("sparc64-linux-gnu"),

0 commit comments

Comments
 (0)