Skip to content

Commit

Permalink
Add target mappings for riscv32imc and riscv32imac (#2551)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
TheConner authored Jun 10, 2023
1 parent 2261681 commit d56f53d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@
+ `log` removed in favor of `logging`
+ `which` removed in favor of `which-logging`
+ `annotate-snippets` removed in favor of `experimental`
* Add target mappings for riscv32imc and riscv32imac.

## Removed

Expand Down
19 changes: 18 additions & 1 deletion bindgen/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -686,6 +686,15 @@ fn rust_to_clang_target(rust_target: &str) -> String {
clang_target.strip_prefix("riscv32imc-").unwrap();
}
return clang_target;
} else if rust_target.starts_with("riscv32imc-") {
let mut clang_target = "riscv32-".to_owned();
clang_target.push_str(rust_target.strip_prefix("riscv32imc-").unwrap());
return clang_target;
} else if rust_target.starts_with("riscv32imac-") {
let mut clang_target = "riscv32-".to_owned();
clang_target
.push_str(rust_target.strip_prefix("riscv32imac-").unwrap());
return clang_target;
}
rust_target.to_owned()
}
Expand Down Expand Up @@ -1285,7 +1294,15 @@ fn test_rust_to_clang_target_riscv() {
assert_eq!(
rust_to_clang_target("riscv64gc-unknown-linux-gnu"),
"riscv64-unknown-linux-gnu"
)
);
assert_eq!(
rust_to_clang_target("riscv32imc-unknown-none-elf"),
"riscv32-unknown-none-elf"
);
assert_eq!(
rust_to_clang_target("riscv32imac-unknown-none-elf"),
"riscv32-unknown-none-elf"
);
}

#[test]
Expand Down

0 comments on commit d56f53d

Please sign in to comment.