Skip to content

Commit 876c5f9

Browse files
committed
compiletest: add {ignore,only}-rustc_abi-x86-sse2 directives
1 parent f77247a commit 876c5f9

File tree

4 files changed

+29
-1
lines changed

4 files changed

+29
-1
lines changed

src/tools/compiletest/src/common.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -517,6 +517,7 @@ pub struct TargetCfgs {
517517
pub all_abis: HashSet<String>,
518518
pub all_families: HashSet<String>,
519519
pub all_pointer_widths: HashSet<String>,
520+
pub all_rustc_abis: HashSet<String>,
520521
}
521522

522523
impl TargetCfgs {
@@ -536,6 +537,7 @@ impl TargetCfgs {
536537
let mut all_abis = HashSet::new();
537538
let mut all_families = HashSet::new();
538539
let mut all_pointer_widths = HashSet::new();
540+
let mut all_rustc_abis = HashSet::new();
539541

540542
// If current target is not included in the `--print=all-target-specs-json` output,
541543
// we check whether it is a custom target from the user or a synthetic target from bootstrap.
@@ -576,7 +578,9 @@ impl TargetCfgs {
576578
all_families.insert(family.clone());
577579
}
578580
all_pointer_widths.insert(format!("{}bit", cfg.pointer_width));
579-
581+
if let Some(rustc_abi) = &cfg.rustc_abi {
582+
all_rustc_abis.insert(rustc_abi.clone());
583+
}
580584
all_targets.insert(target.clone());
581585
}
582586

@@ -590,6 +594,7 @@ impl TargetCfgs {
590594
all_abis,
591595
all_families,
592596
all_pointer_widths,
597+
all_rustc_abis,
593598
}
594599
}
595600

@@ -676,6 +681,7 @@ pub struct TargetCfg {
676681
pub(crate) xray: bool,
677682
#[serde(default = "default_reloc_model")]
678683
pub(crate) relocation_model: String,
684+
pub(crate) rustc_abi: Option<String>,
679685

680686
// Not present in target cfg json output, additional derived information.
681687
#[serde(skip)]

src/tools/compiletest/src/directive-list.rs

+2
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ const KNOWN_DIRECTIVE_NAMES: &[&str] = &[
8787
"ignore-remote",
8888
"ignore-riscv64",
8989
"ignore-rustc-debug-assertions",
90+
"ignore-rustc_abi-x86-sse2",
9091
"ignore-s390x",
9192
"ignore-sgx",
9293
"ignore-sparc64",
@@ -198,6 +199,7 @@ const KNOWN_DIRECTIVE_NAMES: &[&str] = &[
198199
"only-nvptx64",
199200
"only-powerpc",
200201
"only-riscv64",
202+
"only-rustc_abi-x86-sse2",
201203
"only-s390x",
202204
"only-sparc",
203205
"only-sparc64",

src/tools/compiletest/src/header/cfg.rs

+8
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,14 @@ fn parse_cfg_name_directive<'a>(
234234
allowed_names: ["coverage-map", "coverage-run"],
235235
message: "when the test mode is {name}",
236236
}
237+
condition! {
238+
name: target_cfg.rustc_abi.as_ref().map(|abi| format!("rustc_abi-{abi}")).unwrap_or_default(),
239+
allowed_names: ContainsPrefixed {
240+
prefix: "rustc_abi-",
241+
inner: target_cfgs.all_rustc_abis.clone(),
242+
},
243+
message: "when the target `rustc_abi` is {name}",
244+
}
237245

238246
condition! {
239247
name: "dist",

src/tools/compiletest/src/header/tests.rs

+12
Original file line numberDiff line numberDiff line change
@@ -889,3 +889,15 @@ fn test_needs_target_has_atomic() {
889889
assert!(!check_ignore(&config, "//@ needs-target-has-atomic: 8, ptr"));
890890
assert!(check_ignore(&config, "//@ needs-target-has-atomic: 8, ptr, 128"));
891891
}
892+
893+
#[test]
894+
fn test_rustc_abi() {
895+
let config = cfg().target("i686-unknown-linux-gnu").build();
896+
assert_eq!(config.target_cfg().rustc_abi, Some("x86-sse2".to_string()));
897+
assert!(check_ignore(&config, "//@ ignore-rustc_abi-x86-sse2"));
898+
assert!(!check_ignore(&config, "//@ only-rustc_abi-x86-sse2"));
899+
let config = cfg().target("x86_64-unknown-linux-gnu").build();
900+
assert_eq!(config.target_cfg().rustc_abi, None);
901+
assert!(!check_ignore(&config, "//@ ignore-rustc_abi-x86-sse2"));
902+
assert!(check_ignore(&config, "//@ only-rustc_abi-x86-sse2"));
903+
}

0 commit comments

Comments
 (0)