Skip to content

Commit 1b49dbf

Browse files
committed
clang target specific handling (rscv)
1 parent ea35da9 commit 1b49dbf

File tree

1 file changed

+26
-37
lines changed
  • tests/run-make/core-ffi-typecheck-clang

1 file changed

+26
-37
lines changed

tests/run-make/core-ffi-typecheck-clang/rmake.rs

Lines changed: 26 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -6,40 +6,10 @@
66
// If this test fails because Rust adds a target that Clang does not support, this target should be
77
// added to SKIPPED_TARGETS.
88

9-
use run_make_support::{clang, regex, rfs, rustc};
9+
use run_make_support::{clang, llvm_components_contain, regex, rfs, rustc};
1010

1111
// It is not possible to run the Rust test-suite on these targets.
1212
const SKIPPED_TARGETS: &[&str] = &[
13-
"riscv32gc-unknown-linux-gnu",
14-
"riscv32gc-unknown-linux-musl",
15-
"riscv32im-risc0-zkvm-elf",
16-
"riscv32imac-esp-espidf",
17-
"riscv32imafc-esp-espidf",
18-
"riscv32imafc-unknown-nuttx-elf",
19-
"riscv32imc-esp-espidf",
20-
"riscv32imac-unknown-nuttx-elf",
21-
"riscv32imac-unknown-xous-elf",
22-
"riscv32imc-unknown-nuttx-elf",
23-
"riscv32e-unknown-none-elf",
24-
"riscv32em-unknown-none-elf",
25-
"riscv32emc-unknown-none-elf",
26-
"riscv32i-unknown-none-elf",
27-
"riscv32im-unknown-none-elf",
28-
"riscv32imc-unknown-none-elf",
29-
"riscv32ima-unknown-none-elf",
30-
"riscv32imac-unknown-none-elf",
31-
"riscv32imafc-unknown-none-elf",
32-
"riscv64gc-unknown-freebsd",
33-
"riscv64gc-unknown-fuchsia",
34-
"riscv64gc-unknown-hermit",
35-
"riscv64gc-unknown-linux-gnu",
36-
"riscv64gc-unknown-linux-musl",
37-
"riscv64gc-unknown-netbsd",
38-
"riscv64gc-unknown-none-elf",
39-
"riscv64gc-unknown-nuttx-elf",
40-
"riscv64gc-unknown-openbsd",
41-
"riscv64imac-unknown-none-elf",
42-
"riscv64imac-unknown-nuttx-elf",
4313
"wasm32v1-none",
4414
"xtensa-esp32-espidf",
4515
"xtensa-esp32-none-elf",
@@ -70,15 +40,34 @@ fn main() {
7040
continue;
7141
}
7242

73-
// Map the Rust target string to a Clang target string if needed.
74-
let ctarget = match MAPPED_TARGETS.iter().find(|(rtarget, _ctarget)| rtarget == &target) {
75-
Some((_rtarget, ctarget)) => ctarget,
76-
None => target,
77-
};
43+
// Map the Rust target string to a Clang target string if needed
44+
// Also replace riscv with necessary replacements to match clang
45+
// If neither just use target string
46+
let ctarget = MAPPED_TARGETS
47+
.iter()
48+
.find(|(rtarget, _)| *rtarget == target)
49+
.map(|(_, ctarget)| ctarget.to_string())
50+
.unwrap_or_else(|| {
51+
if target.starts_with("riscv") {
52+
target
53+
.replace("imac", "")
54+
.replace("gc", "")
55+
.replace("imafc", "")
56+
.replace("imc", "")
57+
.replace("ima", "")
58+
.replace("im", "")
59+
.replace("emc", "")
60+
.replace("em", "")
61+
.replace("e-", "-")
62+
.replace("i-", "-")
63+
} else {
64+
target.to_string()
65+
}
66+
});
7867

7968
// Run Clang's preprocessor for the relevant target, printing default macro definitions.
8069
let clang_output =
81-
clang().args(&["-E", "-dM", "-x", "c", "/dev/null", "-target", ctarget]).run();
70+
clang().args(&["-E", "-dM", "-x", "c", "/dev/null", "-target", &ctarget]).run();
8271

8372
let defines = String::from_utf8(clang_output.stdout()).expect("Invalid UTF-8");
8473

0 commit comments

Comments
 (0)