Skip to content

Commit 75680bc

Browse files
committed
Handle difference between clang and rust targets on RISC-V
1 parent 1d25049 commit 75680bc

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/lib.rs

+12
Original file line numberDiff line numberDiff line change
@@ -2164,6 +2164,10 @@ fn rust_to_clang_target(rust_target: &str) -> String {
21642164
clang_target
21652165
.push_str(rust_target.strip_prefix("aarch64-apple-").unwrap());
21662166
return clang_target;
2167+
} else if rust_target.starts_with("riscv64gc-") {
2168+
let mut clang_target = "riscv64-".to_owned();
2169+
clang_target.push_str(rust_target.strip_prefix("riscv64gc-").unwrap());
2170+
return clang_target;
21672171
}
21682172
rust_target.to_owned()
21692173
}
@@ -2714,3 +2718,11 @@ fn commandline_flag_unit_test_function() {
27142718
fn test_rust_to_clang_target() {
27152719
assert_eq!(rust_to_clang_target("aarch64-apple-ios"), "arm64-apple-ios");
27162720
}
2721+
2722+
#[test]
2723+
fn test_rust_to_clang_target_riscv() {
2724+
assert_eq!(
2725+
rust_to_clang_target("riscv64gc-unknown-linux-gnu"),
2726+
"riscv64-unknown-linux-gnu"
2727+
)
2728+
}

0 commit comments

Comments
 (0)