Skip to content

Commit

Permalink
added additional unsupported targets on clang and refactored a func n…
Browse files Browse the repository at this point in the history
…ame and replace portion
  • Loading branch information
ricci009 committed Jan 29, 2025
1 parent 1b49dbf commit 7edcddd
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 18 deletions.
48 changes: 38 additions & 10 deletions tests/run-make/core-ffi-typecheck-clang/rmake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ const SKIPPED_TARGETS: &[&str] = &[
"xtensa-esp32s2-none-elf",
"xtensa-esp32s3-espidf",
"xtensa-esp32s3-none-elf",
"csky-unknown-linux-gnuabiv2",
"csky-unknown-linux-gnuabiv2hf",
];

/// Map from a Rust target to the Clang target if they are not the same.
Expand All @@ -26,14 +28,40 @@ const MAPPED_TARGETS: &[(&str, &str)] = &[
("aarch64-apple-visionos-sim", "aarch64-apple-visionos"),
("aarch64-apple-watchos-sim", "aarch64-apple-watchos"),
("x86_64-apple-watchos-sim", "x86_64-apple-watchos"),
("aarch64-pc-windows-gnullvm", "aarch64-pc-windows-gnu"),
("aarch64-unknown-linux-gnu_ilp32", "aarch64-unknown-linux-gnu"),
("aarch64-unknown-none-softfloat", "aarch64-unknown-none"),
("aarch64-unknown-nto-qnx700", "aarch64-unknown-nto-700"),
("aarch64-unknown-nto-qnx710", "aarch64-unknown-nto-710"),
("aarch64-unknown-uefi", "aarch64-unknown"),
("aarch64_be-unknown-linux-gnu_ilp32", "aarch64_be-unknown-linux-gnu"),
("armv5te-unknown-linux-uclibceabi", "armv5te-unknown-linux"),
("armv7-sony-vita-newlibeabihf", "armv7-sony-vita"),
("armv7-unknown-linux-uclibceabi", "armv7-unknown-linux"),
("armv7-unknown-linux-uclibceabihf", "armv7-unknown-linux"),
("avr-unknown-gnu-atmega328", "avr-unknown-gnu"),
("csky-unknown-linux-gnuabiv2", "csky-unknown-linux-gnu"),
("i586-pc-nto-qnx700", "i586-pc-nto-700"),
("i686-pc-windows-gnullvm", "i686-pc-windows-gnu"),
("i686-unknown-uefi", "i686-unknown"),
("loongarch64-unknown-none-softfloat", "loongarch64-unknown-none"),
("mips-unknown-linux-uclibc", "mips-unknown-linux"),
("mipsel-unknown-linux-uclibc", "mipsel-unknown-linux"),
("powerpc-unknown-linux-gnuspe", "powerpc-unknown-linux-gnu"),
("powerpc-unknown-linux-muslspe", "powerpc-unknown-linux-musl"),
("powerpc-wrs-vxworks-spe", "powerpc-wrs-vxworks"),
("x86_64-fortanix-unknown-sgx", "x86_64-fortanix-unknown"),
("x86_64-pc-nto-qnx710", "x86_64-pc-nto-710"),
("x86_64-pc-windows-gnullvm", "x86_64-pc-windows-gnu"),
("x86_64-unknown-l4re-uclibc", "x86_64-unknown-l4re"),
];

fn main() {
let targets = get_target_list();

let minicore_path = run_make_support::source_root().join("tests/auxiliary/minicore.rs");

regex_mod();
preprocess_core_ffi();

for target in targets.lines() {
if SKIPPED_TARGETS.iter().any(|&to_skip_target| target == to_skip_target) {
Expand All @@ -50,14 +78,14 @@ fn main() {
.unwrap_or_else(|| {
if target.starts_with("riscv") {
target
.replace("imac", "")
.replace("gc", "")
.replace("imafc", "")
.replace("imc", "")
.replace("ima", "")
.replace("im", "")
.replace("emc", "")
.replace("em", "")
.replace("imac-", "-")
.replace("gc-", "-")
.replace("imafc-", "-")
.replace("imc-", "-")
.replace("ima-", "-")
.replace("im-", "-")
.replace("emc-", "-")
.replace("em-", "-")
.replace("e-", "-")
.replace("i-", "-")
} else {
Expand Down Expand Up @@ -172,7 +200,7 @@ fn char_is_signed(defines: &str) -> bool {
}

/// Parse core/ffi/mod.rs to retrieve only necessary macros and type defines
fn regex_mod() {
fn preprocess_core_ffi() {
let mod_path = run_make_support::source_root().join("library/core/src/ffi/mod.rs");
let mut content = rfs::read_to_string(&mod_path);

Expand Down
9 changes: 1 addition & 8 deletions tests/run-make/core-ffi-typecheck-clang/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,7 @@ cfg_if! {

// Verify Rust's 'c_char' has correct sign.
cfg_if! {
if #[cfg(target_arch = "csky")] {
// FIXME: c_char signedness misallignment on csky, should be signed on CLANG
const XFAIL_C_CHAR_SIGNED: bool = false;
pub const TEST_C_CHAR_UNSIGNED: () = if ffi::c_char::SIGNED != XFAIL_C_CHAR_SIGNED {
panic!("mismatched c_char signed, target_arch: csky");
};
}
else if #[cfg(target_arch = "msp430")] {
if #[cfg(target_arch = "msp430")] {
// FIXME: c_char signedness misallignment on msp430, should be signed on CLANG
const XFAIL_C_CHAR_SIGNED: bool = false;
pub const TEST_C_CHAR_UNSIGNED: () = if ffi::c_char::SIGNED != XFAIL_C_CHAR_SIGNED {
Expand Down

0 comments on commit 7edcddd

Please # to comment.