Skip to content

Commit

Permalink
Add target mappings for riscv64imac and riscv32imafc
Browse files Browse the repository at this point in the history
Similar change to #2551. Just filling in more mappings.
  • Loading branch information
nspin authored and emilio committed Feb 7, 2024
1 parent 4dd4523 commit aa63496
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -204,6 +204,7 @@
# Unreleased
## Added
## Changed
- Add target mappings for riscv64imac and riscv32imafc.
## Removed
## Fixed
## Security
Expand Down
18 changes: 18 additions & 0 deletions bindgen/lib.rs
Expand Up @@ -695,6 +695,11 @@ fn rust_to_clang_target(rust_target: &str) -> Box<str> {
let mut clang_target = "riscv64-".to_owned();
clang_target.push_str(rust_target.strip_prefix("riscv64gc-").unwrap());
return clang_target.into();
} else if rust_target.starts_with("riscv64imac-") {
let mut clang_target = "riscv64-".to_owned();
clang_target
.push_str(rust_target.strip_prefix("riscv64imac-").unwrap());
return clang_target.into();
} else if rust_target.ends_with("-espidf") {
let mut clang_target =
rust_target.strip_suffix("-espidf").unwrap().to_owned();
Expand All @@ -713,6 +718,11 @@ fn rust_to_clang_target(rust_target: &str) -> Box<str> {
clang_target
.push_str(rust_target.strip_prefix("riscv32imac-").unwrap());
return clang_target.into();
} else if rust_target.starts_with("riscv32imafc-") {
let mut clang_target = "riscv32-".to_owned();
clang_target
.push_str(rust_target.strip_prefix("riscv32imafc-").unwrap());
return clang_target.into();
}
rust_target.into()
}
Expand Down Expand Up @@ -1357,6 +1367,10 @@ fn test_rust_to_clang_target_riscv() {
rust_to_clang_target("riscv64gc-unknown-linux-gnu").as_ref(),
"riscv64-unknown-linux-gnu"
);
assert_eq!(
rust_to_clang_target("riscv64imac-unknown-none-elf").as_ref(),
"riscv64-unknown-none-elf"
);
assert_eq!(
rust_to_clang_target("riscv32imc-unknown-none-elf").as_ref(),
"riscv32-unknown-none-elf"
Expand All @@ -1365,6 +1379,10 @@ fn test_rust_to_clang_target_riscv() {
rust_to_clang_target("riscv32imac-unknown-none-elf").as_ref(),
"riscv32-unknown-none-elf"
);
assert_eq!(
rust_to_clang_target("riscv32imafc-unknown-none-elf").as_ref(),
"riscv32-unknown-none-elf"
);
}

#[test]
Expand Down

0 comments on commit aa63496

Please sign in to comment.