Skip to content

Commit d56f53d

Browse files
authored
Add target mappings for riscv32imc and riscv32imac (#2551)
Similar problem as the one mentioned in #2136, just continuing by adding the 32 bit risc tuple mappings. Tuples like riscv32imc- and riscv32imac- should map to the clang riscv32- tuple. Fixed by adding mappings and tests for the mappings. Projects that now failed to build the "riscv32imac-unknown-none-elf" target tuple now build without issue.
1 parent 2261681 commit d56f53d

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@
196196
+ `log` removed in favor of `logging`
197197
+ `which` removed in favor of `which-logging`
198198
+ `annotate-snippets` removed in favor of `experimental`
199+
* Add target mappings for riscv32imc and riscv32imac.
199200

200201
## Removed
201202

bindgen/lib.rs

+18-1
Original file line numberDiff line numberDiff line change
@@ -686,6 +686,15 @@ fn rust_to_clang_target(rust_target: &str) -> String {
686686
clang_target.strip_prefix("riscv32imc-").unwrap();
687687
}
688688
return clang_target;
689+
} else if rust_target.starts_with("riscv32imc-") {
690+
let mut clang_target = "riscv32-".to_owned();
691+
clang_target.push_str(rust_target.strip_prefix("riscv32imc-").unwrap());
692+
return clang_target;
693+
} else if rust_target.starts_with("riscv32imac-") {
694+
let mut clang_target = "riscv32-".to_owned();
695+
clang_target
696+
.push_str(rust_target.strip_prefix("riscv32imac-").unwrap());
697+
return clang_target;
689698
}
690699
rust_target.to_owned()
691700
}
@@ -1285,7 +1294,15 @@ fn test_rust_to_clang_target_riscv() {
12851294
assert_eq!(
12861295
rust_to_clang_target("riscv64gc-unknown-linux-gnu"),
12871296
"riscv64-unknown-linux-gnu"
1288-
)
1297+
);
1298+
assert_eq!(
1299+
rust_to_clang_target("riscv32imc-unknown-none-elf"),
1300+
"riscv32-unknown-none-elf"
1301+
);
1302+
assert_eq!(
1303+
rust_to_clang_target("riscv32imac-unknown-none-elf"),
1304+
"riscv32-unknown-none-elf"
1305+
);
12891306
}
12901307

12911308
#[test]

0 commit comments

Comments
 (0)