|
6 | 6 | // If this test fails because Rust adds a target that Clang does not support, this target should be
|
7 | 7 | // added to SKIPPED_TARGETS.
|
8 | 8 |
|
9 |
| -use run_make_support::{clang, regex, rfs, rustc}; |
| 9 | +use run_make_support::{clang, llvm_components_contain, regex, rfs, rustc}; |
10 | 10 |
|
11 | 11 | // It is not possible to run the Rust test-suite on these targets.
|
12 | 12 | 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", |
43 | 13 | "wasm32v1-none",
|
44 | 14 | "xtensa-esp32-espidf",
|
45 | 15 | "xtensa-esp32-none-elf",
|
@@ -70,15 +40,34 @@ fn main() {
|
70 | 40 | continue;
|
71 | 41 | }
|
72 | 42 |
|
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 | + }); |
78 | 67 |
|
79 | 68 | // Run Clang's preprocessor for the relevant target, printing default macro definitions.
|
80 | 69 | 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(); |
82 | 71 |
|
83 | 72 | let defines = String::from_utf8(clang_output.stdout()).expect("Invalid UTF-8");
|
84 | 73 |
|
|
0 commit comments