-
Notifications
You must be signed in to change notification settings - Fork 12.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tests: add sanity-check assembly test for every target
Adds a basic assembly test checking that each target can produce assembly and update the target tier policy to require this. Signed-off-by: David Wood <david@davidtw.co>
- Loading branch information
Showing
8 changed files
with
803 additions
and
7 deletions.
There are no files selected for viewing
7 changes: 0 additions & 7 deletions
7
compiler/rustc_target/src/spec/targets/asmjs_unknown_emscripten.rs
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
//! Tests for target tier policy compliance. | ||
//! | ||
//! As of writing, only checks that sanity-check assembly test for targets doesn't miss any targets. | ||
|
||
use crate::walk::{filter_not_rust, walk}; | ||
use std::{collections::HashSet, path::Path}; | ||
|
||
const TARGET_DEFINITIONS_PATH: &str = "compiler/rustc_target/src/spec/targets/"; | ||
const ASSEMBLY_TEST_PATH: &str = "tests/assembly/targets/"; | ||
const REVISION_LINE_START: &str = "// revisions: "; | ||
const EXCEPTIONS: &[&str] = &[ | ||
// FIXME: disabled since it fails on CI saying the csky component is missing | ||
"csky_unknown_linux_gnuabiv2", | ||
"csky_unknown_linux_gnuabiv2hf", | ||
]; | ||
|
||
pub fn check(root_path: &Path, bad: &mut bool) { | ||
let mut targets_to_find = HashSet::new(); | ||
|
||
let definitions_path = root_path.join(TARGET_DEFINITIONS_PATH); | ||
for defn in ignore::WalkBuilder::new(&definitions_path) | ||
.max_depth(Some(1)) | ||
.filter_entry(|e| !filter_not_rust(e.path())) | ||
.build() | ||
{ | ||
let defn = defn.unwrap(); | ||
// Skip directory itself. | ||
if defn.path() == definitions_path { | ||
continue; | ||
} | ||
|
||
let path = defn.path(); | ||
let target_name = path.file_stem().unwrap().to_string_lossy().into_owned(); | ||
let _ = targets_to_find.insert(target_name); | ||
} | ||
|
||
walk(&root_path.join(ASSEMBLY_TEST_PATH), |_, _| false, &mut |_, contents| { | ||
for line in contents.lines() { | ||
let Some(_) = line.find(REVISION_LINE_START) else { | ||
continue; | ||
}; | ||
let (_, target_name) = line.split_at(REVISION_LINE_START.len()); | ||
targets_to_find.remove(target_name); | ||
} | ||
}); | ||
|
||
for target in targets_to_find { | ||
if !EXCEPTIONS.contains(&target.as_str()) { | ||
tidy_error!(bad, "{ASSEMBLY_TEST_PATH}: missing assembly test for {target}") | ||
} | ||
} | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// assembly-output: emit-asm | ||
// ignore-tidy-linelength | ||
// revisions: nvptx64_nvidia_cuda | ||
// [nvptx64_nvidia_cuda] compile-flags: --target nvptx64-nvidia-cuda | ||
// [nvptx64_nvidia_cuda] needs-llvm-components: nvptx | ||
|
||
// Sanity-check that each target can produce assembly code. | ||
|
||
#![feature(no_core, lang_items)] | ||
#![no_std] | ||
#![no_core] | ||
#![crate_type = "lib"] | ||
|
||
#[lang = "sized"] | ||
trait Sized {} | ||
|
||
pub fn test() -> u8 { | ||
42 | ||
} | ||
|
||
// CHECK: .version |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
// assembly-output: emit-asm | ||
// ignore-tidy-linelength | ||
// revisions: aarch64_pc_windows_msvc | ||
// [aarch64_pc_windows_msvc] compile-flags: --target aarch64-pc-windows-msvc | ||
// [aarch64_pc_windows_msvc] needs-llvm-components: aarch64 | ||
// revisions: aarch64_pc_windows_gnullvm | ||
// [aarch64_pc_windows_gnullvm] compile-flags: --target aarch64-pc-windows-gnullvm | ||
// [aarch64_pc_windows_gnullvm] needs-llvm-components: aarch64 | ||
// revisions: aarch64_unknown_uefi | ||
// [aarch64_unknown_uefi] compile-flags: --target aarch64-unknown-uefi | ||
// [aarch64_unknown_uefi] needs-llvm-components: aarch64 | ||
// revisions: aarch64_uwp_windows_msvc | ||
// [aarch64_uwp_windows_msvc] compile-flags: --target aarch64-uwp-windows-msvc | ||
// [aarch64_uwp_windows_msvc] needs-llvm-components: aarch64 | ||
// revisions: avr_unknown_gnu_atmega328 | ||
// [avr_unknown_gnu_atmega328] compile-flags: --target avr-unknown-gnu-atmega328 | ||
// [avr_unknown_gnu_atmega328] needs-llvm-components: avr | ||
// revisions: bpfeb_unknown_none | ||
// [bpfeb_unknown_none] compile-flags: --target bpfeb-unknown-none | ||
// [bpfeb_unknown_none] needs-llvm-components: bpf | ||
// revisions: bpfel_unknown_none | ||
// [bpfel_unknown_none] compile-flags: --target bpfel-unknown-none | ||
// [bpfel_unknown_none] needs-llvm-components: bpf | ||
// revisions: i586_pc_windows_msvc | ||
// [i586_pc_windows_msvc] compile-flags: --target i586-pc-windows-msvc | ||
// [i586_pc_windows_msvc] needs-llvm-components: x86 | ||
// revisions: i686_pc_windows_gnu | ||
// [i686_pc_windows_gnu] compile-flags: --target i686-pc-windows-gnu | ||
// [i686_pc_windows_gnu] needs-llvm-components: x86 | ||
// revisions: i686_pc_windows_msvc | ||
// [i686_pc_windows_msvc] compile-flags: --target i686-pc-windows-msvc | ||
// [i686_pc_windows_msvc] needs-llvm-components: x86 | ||
// revisions: i686_pc_windows_gnullvm | ||
// [i686_pc_windows_gnullvm] compile-flags: --target i686-pc-windows-gnullvm | ||
// [i686_pc_windows_gnullvm] needs-llvm-components: x86 | ||
// revisions: i686_uwp_windows_gnu | ||
// [i686_uwp_windows_gnu] compile-flags: --target i686-uwp-windows-gnu | ||
// [i686_uwp_windows_gnu] needs-llvm-components: x86 | ||
// revisions: i686_unknown_uefi | ||
// [i686_unknown_uefi] compile-flags: --target i686-unknown-uefi | ||
// [i686_unknown_uefi] needs-llvm-components: x86 | ||
// revisions: i686_uwp_windows_msvc | ||
// [i686_uwp_windows_msvc] compile-flags: --target i686-uwp-windows-msvc | ||
// [i686_uwp_windows_msvc] needs-llvm-components: x86 | ||
// revisions: i686_win7_windows_msvc | ||
// [i686_win7_windows_msvc] compile-flags: --target i686-win7-windows-msvc | ||
// [i686_win7_windows_msvc] needs-llvm-components: x86 | ||
// revisions: powerpc64_ibm_aix | ||
// [powerpc64_ibm_aix] compile-flags: --target powerpc64-ibm-aix | ||
// [powerpc64_ibm_aix] needs-llvm-components: powerpc | ||
// revisions: thumbv7a_uwp_windows_msvc | ||
// [thumbv7a_uwp_windows_msvc] compile-flags: --target thumbv7a-uwp-windows-msvc | ||
// [thumbv7a_uwp_windows_msvc] needs-llvm-components: arm | ||
// revisions: thumbv7a_pc_windows_msvc | ||
// [thumbv7a_pc_windows_msvc] compile-flags: --target thumbv7a-pc-windows-msvc | ||
// [thumbv7a_pc_windows_msvc] needs-llvm-components: arm | ||
// revisions: x86_64_pc_windows_gnu | ||
// [x86_64_pc_windows_gnu] compile-flags: --target x86_64-pc-windows-gnu | ||
// [x86_64_pc_windows_gnu] needs-llvm-components: x86 | ||
// revisions: x86_64_pc_windows_gnullvm | ||
// [x86_64_pc_windows_gnullvm] compile-flags: --target x86_64-pc-windows-gnullvm | ||
// [x86_64_pc_windows_gnullvm] needs-llvm-components: x86 | ||
// revisions: x86_64_pc_windows_msvc | ||
// [x86_64_pc_windows_msvc] compile-flags: --target x86_64-pc-windows-msvc | ||
// [x86_64_pc_windows_msvc] needs-llvm-components: x86 | ||
// revisions: x86_64_unknown_uefi | ||
// [x86_64_unknown_uefi] compile-flags: --target x86_64-unknown-uefi | ||
// [x86_64_unknown_uefi] needs-llvm-components: x86 | ||
// revisions: x86_64_uwp_windows_gnu | ||
// [x86_64_uwp_windows_gnu] compile-flags: --target x86_64-uwp-windows-gnu | ||
// [x86_64_uwp_windows_gnu] needs-llvm-components: x86 | ||
// revisions: x86_64_uwp_windows_msvc | ||
// [x86_64_uwp_windows_msvc] compile-flags: --target x86_64-uwp-windows-msvc | ||
// [x86_64_uwp_windows_msvc] needs-llvm-components: x86 | ||
// revisions: x86_64_win7_windows_msvc | ||
// [x86_64_win7_windows_msvc] compile-flags: --target x86_64-win7-windows-msvc | ||
// [x86_64_win7_windows_msvc] needs-llvm-components: x86 | ||
|
||
// Sanity-check that each target can produce assembly code. | ||
|
||
#![feature(no_core, lang_items)] | ||
#![no_std] | ||
#![no_core] | ||
#![crate_type = "lib"] | ||
|
||
#[lang = "sized"] | ||
trait Sized {} | ||
|
||
pub fn test() -> u8 { | ||
42 | ||
} | ||
|
||
// CHECK: .file |