Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions src/doc/rustc-dev-guide/src/tests/minicore.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,21 @@ range of tests.

</div>

A test can use [`minicore`] by specifying the `//@ add-core-stubs` directive.
Then, mark the test with `#![feature(no_core)]` + `#![no_std]` + `#![no_core]`.
Due to Edition 2015 extern prelude rules, you will probably need to declare
`minicore` as an extern crate.
A test can use [`minicore`] by specifying the `//@ add-minicore` directive.
Then, mark the test with `#![feature(no_core)]` + `#![no_std]` + `#![no_core]`,
and import the crate into the test with `extern crate minicore` (edition 2015)
or `use minicore` (edition 2018+).

## Implied compiler flags

Due to the `no_std` + `no_core` nature of these tests, `//@ add-core-stubs`
Due to the `no_std` + `no_core` nature of these tests, `//@ add-minicore`
implies and requires that the test will be built with `-C panic=abort`.
**Unwinding panics are not supported.**

Tests will also be built with `-C force-unwind-tables=yes` to preserve CFI
directives in assembly tests.

TL;DR: `//@ add-core-stubs` implies two compiler flags:
TL;DR: `//@ add-minicore` implies two compiler flags:

1. `-C panic=abort`
2. `-C force-unwind-tables=yes`
Expand All @@ -48,7 +48,7 @@ attributes (e.g. `on_unimplemented`) should be replicated exactly in `minicore`.
## Example codegen test that uses `minicore`

```rust,no_run
//@ add-core-stubs
//@ add-minicore
//@ revisions: meow bark
//@[meow] compile-flags: --target=x86_64-unknown-linux-gnu
//@[meow] needs-llvm-components: x86
Expand Down
20 changes: 10 additions & 10 deletions src/tools/compiletest/src/directives.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ pub(crate) struct TestProps {
pub no_auto_check_cfg: bool,
/// Build and use `minicore` as `core` stub for `no_core` tests in cross-compilation scenarios
/// that don't otherwise want/need `-Z build-std`.
pub add_core_stubs: bool,
pub add_minicore: bool,
/// Add these flags to the build of `minicore`.
pub core_stubs_compile_flags: Vec<String>,
/// Whether line annotatins are required for the given error kind.
Expand Down Expand Up @@ -254,7 +254,7 @@ mod directives {
pub const LLVM_COV_FLAGS: &'static str = "llvm-cov-flags";
pub const FILECHECK_FLAGS: &'static str = "filecheck-flags";
pub const NO_AUTO_CHECK_CFG: &'static str = "no-auto-check-cfg";
pub const ADD_CORE_STUBS: &'static str = "add-core-stubs";
pub const ADD_MINICORE: &'static str = "add-minicore";
pub const CORE_STUBS_COMPILE_FLAGS: &'static str = "core-stubs-compile-flags";
pub const DISABLE_GDB_PRETTY_PRINTERS: &'static str = "disable-gdb-pretty-printers";
pub const COMPARE_OUTPUT_BY_LINES: &'static str = "compare-output-by-lines";
Expand Down Expand Up @@ -311,7 +311,7 @@ impl TestProps {
llvm_cov_flags: vec![],
filecheck_flags: vec![],
no_auto_check_cfg: false,
add_core_stubs: false,
add_minicore: false,
core_stubs_compile_flags: vec![],
dont_require_annotations: Default::default(),
disable_gdb_pretty_printers: false,
Expand Down Expand Up @@ -601,7 +601,7 @@ impl TestProps {

config.set_name_directive(ln, NO_AUTO_CHECK_CFG, &mut self.no_auto_check_cfg);

self.update_add_core_stubs(ln, config);
self.update_add_minicore(ln, config);

if let Some(flags) =
config.parse_name_value_directive(ln, CORE_STUBS_COMPILE_FLAGS)
Expand Down Expand Up @@ -753,12 +753,12 @@ impl TestProps {
self.pass_mode
}

fn update_add_core_stubs(&mut self, ln: &DirectiveLine<'_>, config: &Config) {
let add_core_stubs = config.parse_name_directive(ln, directives::ADD_CORE_STUBS);
if add_core_stubs {
fn update_add_minicore(&mut self, ln: &DirectiveLine<'_>, config: &Config) {
let add_minicore = config.parse_name_directive(ln, directives::ADD_MINICORE);
if add_minicore {
if !matches!(config.mode, TestMode::Ui | TestMode::Codegen | TestMode::Assembly) {
panic!(
"`add-core-stubs` is currently only supported for ui, codegen and assembly test modes"
"`add-minicore` is currently only supported for ui, codegen and assembly test modes"
);
}

Expand All @@ -767,10 +767,10 @@ impl TestProps {
if self.local_pass_mode().is_some_and(|pm| pm == PassMode::Run) {
// `minicore` can only be used with non-run modes, because it's `core` prelude stubs
// and can't run.
panic!("`add-core-stubs` cannot be used to run the test binary");
panic!("`add-minicore` cannot be used to run the test binary");
}

self.add_core_stubs = add_core_stubs;
self.add_minicore = add_minicore;
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/tools/compiletest/src/directives/directive_names.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/// a best-effort approximation for diagnostics. Add new directives to this list when needed.
pub(crate) const KNOWN_DIRECTIVE_NAMES: &[&str] = &[
// tidy-alphabetical-start
"add-core-stubs",
"add-minicore",
"assembly-output",
"aux-bin",
"aux-build",
Expand Down
6 changes: 3 additions & 3 deletions src/tools/compiletest/src/runtest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1312,7 +1312,7 @@ impl<'test> TestCx<'test> {
input: Option<String>,
root_testpaths: &TestPaths,
) -> ProcRes {
if self.props.add_core_stubs {
if self.props.add_minicore {
let minicore_path = self.build_minicore();
rustc.arg("--extern");
rustc.arg(&format!("minicore={}", minicore_path));
Expand Down Expand Up @@ -1457,7 +1457,7 @@ impl<'test> TestCx<'test> {

aux_rustc.arg("-L").arg(&aux_dir);

if aux_props.add_core_stubs {
if aux_props.add_minicore {
let minicore_path = self.build_minicore();
aux_rustc.arg("--extern");
aux_rustc.arg(&format!("minicore={}", minicore_path));
Expand Down Expand Up @@ -1899,7 +1899,7 @@ impl<'test> TestCx<'test> {
// change the default.
//
// `minicore` requires `#![no_std]` and `#![no_core]`, which means no unwinding panics.
if self.props.add_core_stubs {
if self.props.add_minicore {
rustc.arg("-Cpanic=abort");
rustc.arg("-Cforce-unwind-tables=yes");
}
Expand Down
2 changes: 1 addition & 1 deletion tests/assembly-llvm/aarch64-pointer-auth.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Test that PAC instructions are emitted when branch-protection is specified.

//@ add-core-stubs
//@ add-minicore
//@ revisions: GCS PACRET PAUTHLR_NOP PAUTHLR
//@ assembly-output: emit-asm
//@ needs-llvm-components: aarch64
Expand Down
2 changes: 1 addition & 1 deletion tests/assembly-llvm/asm/aarch64-el2vmsa.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//@ add-core-stubs
//@ add-minicore
//@ assembly-output: emit-asm
//@ compile-flags: --target aarch64-unknown-linux-gnu
//@ needs-llvm-components: aarch64
Expand Down
2 changes: 1 addition & 1 deletion tests/assembly-llvm/asm/aarch64-modifiers.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//@ add-core-stubs
//@ add-minicore
//@ assembly-output: emit-asm
//@ compile-flags: -Copt-level=3 -C panic=abort
//@ compile-flags: --target aarch64-unknown-linux-gnu
Expand Down
2 changes: 1 addition & 1 deletion tests/assembly-llvm/asm/aarch64-types.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//@ add-core-stubs
//@ add-minicore
//@ revisions: aarch64 arm64ec
//@ assembly-output: emit-asm
//@ [aarch64] compile-flags: --target aarch64-unknown-linux-gnu
Expand Down
2 changes: 1 addition & 1 deletion tests/assembly-llvm/asm/arm-modifiers.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//@ add-core-stubs
//@ add-minicore
//@ assembly-output: emit-asm
//@ compile-flags: -Copt-level=3 -C panic=abort
//@ compile-flags: --target armv7-unknown-linux-gnueabihf
Expand Down
2 changes: 1 addition & 1 deletion tests/assembly-llvm/asm/arm-types.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//@ add-core-stubs
//@ add-minicore
//@ revisions: base d32 neon
//@ assembly-output: emit-asm
//@ compile-flags: --target armv7-unknown-linux-gnueabihf
Expand Down
2 changes: 1 addition & 1 deletion tests/assembly-llvm/asm/avr-modifiers.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//@ add-core-stubs
//@ add-minicore
//@ assembly-output: emit-asm
//@ compile-flags: --target avr-none -C target-cpu=atmega328p
//@ needs-llvm-components: avr
Expand Down
2 changes: 1 addition & 1 deletion tests/assembly-llvm/asm/avr-types.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//@ add-core-stubs
//@ add-minicore
//@ assembly-output: emit-asm
//@ compile-flags: --target avr-none -C target-cpu=atmega328p
//@ needs-llvm-components: avr
Expand Down
2 changes: 1 addition & 1 deletion tests/assembly-llvm/asm/bpf-types.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//@ add-core-stubs
//@ add-minicore
//@ assembly-output: emit-asm
//@ compile-flags: --target bpfel-unknown-none -C target_feature=+alu32
//@ needs-llvm-components: bpf
Expand Down
2 changes: 1 addition & 1 deletion tests/assembly-llvm/asm/hexagon-types.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//@ add-core-stubs
//@ add-minicore
//@ assembly-output: emit-asm
//@ compile-flags: --target hexagon-unknown-linux-musl
//@ compile-flags: -Zmerge-functions=disabled
Expand Down
2 changes: 1 addition & 1 deletion tests/assembly-llvm/asm/loongarch-type.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//@ add-core-stubs
//@ add-minicore
//@ revisions: loongarch32 loongarch64

//@ assembly-output: emit-asm
Expand Down
2 changes: 1 addition & 1 deletion tests/assembly-llvm/asm/m68k-types.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//@ add-core-stubs
//@ add-minicore
//@ assembly-output: emit-asm
//@ compile-flags: --target m68k-unknown-linux-gnu
//@ needs-llvm-components: m68k
Expand Down
2 changes: 1 addition & 1 deletion tests/assembly-llvm/asm/mips-types.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//@ add-core-stubs
//@ add-minicore
//@ revisions: mips32 mips64
//@ assembly-output: emit-asm
//@[mips32] compile-flags: --target mips-unknown-linux-gnu
Expand Down
2 changes: 1 addition & 1 deletion tests/assembly-llvm/asm/msp430-types.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//@ add-core-stubs
//@ add-minicore
//@ assembly-output: emit-asm
//@ compile-flags: --target msp430-none-elf
//@ needs-llvm-components: msp430
Expand Down
2 changes: 1 addition & 1 deletion tests/assembly-llvm/asm/nvptx-types.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//@ add-core-stubs
//@ add-minicore
//@ assembly-output: emit-asm
//@ compile-flags: --target nvptx64-nvidia-cuda
//@ needs-llvm-components: nvptx
Expand Down
2 changes: 1 addition & 1 deletion tests/assembly-llvm/asm/powerpc-types.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//@ add-core-stubs
//@ add-minicore
//@ revisions: powerpc powerpc_altivec powerpc_vsx powerpc64 powerpc64_vsx
//@ assembly-output: emit-asm
//@[powerpc] compile-flags: --target powerpc-unknown-linux-gnu
Expand Down
2 changes: 1 addition & 1 deletion tests/assembly-llvm/asm/riscv-types.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//@ add-core-stubs
//@ add-minicore
//@ revisions: riscv64 riscv32 riscv64-zfhmin riscv32-zfhmin riscv64-zfh riscv32-zfh
//@ assembly-output: emit-asm

Expand Down
2 changes: 1 addition & 1 deletion tests/assembly-llvm/asm/s390x-types.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//@ add-core-stubs
//@ add-minicore
//@ revisions: s390x s390x_vector
//@ assembly-output: emit-asm
//@[s390x] compile-flags: --target s390x-unknown-linux-gnu
Expand Down
2 changes: 1 addition & 1 deletion tests/assembly-llvm/asm/sparc-types.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//@ add-core-stubs
//@ add-minicore
//@ revisions: sparc sparcv8plus sparc64
//@ assembly-output: emit-asm
//@[sparc] compile-flags: --target sparc-unknown-none-elf
Expand Down
2 changes: 1 addition & 1 deletion tests/assembly-llvm/asm/wasm-types.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//@ add-core-stubs
//@ add-minicore
//@ assembly-output: emit-asm
//@ compile-flags: --target wasm32-unknown-unknown
//@ needs-llvm-components: webassembly
Expand Down
2 changes: 1 addition & 1 deletion tests/assembly-llvm/asm/x86-modifiers.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//@ add-core-stubs
//@ add-minicore
//@ revisions: x86_64 i686
//@ assembly-output: emit-asm
//@ compile-flags: -Copt-level=3 -C panic=abort
Expand Down
2 changes: 1 addition & 1 deletion tests/assembly-llvm/asm/x86-types.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//@ add-core-stubs
//@ add-minicore
//@ revisions: x86_64 i686
//@ assembly-output: emit-asm
//@[x86_64] compile-flags: --target x86_64-unknown-linux-gnu
Expand Down
2 changes: 1 addition & 1 deletion tests/assembly-llvm/cmse.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//@ add-core-stubs
//@ add-minicore
//@ revisions: hard soft
//@ assembly-output: emit-asm
//@ [hard] compile-flags: --target thumbv8m.main-none-eabihf --crate-type lib -Copt-level=1
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//! `compiletest` self-test to check that `add-core-stubs` is incompatible with run pass modes.
//! `compiletest` self-test to check that `add-minicore` is incompatible with run pass modes.
//@ add-core-stubs
//@ add-minicore
//@ run-pass
//@ should-fail
2 changes: 1 addition & 1 deletion tests/assembly-llvm/dwarf4.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Makes sure that `-C dwarf-version=4` causes `rustc` to emit DWARF version 4.
//@ assembly-output: emit-asm
//@ add-core-stubs
//@ add-minicore
//@ compile-flags: -g --target x86_64-unknown-linux-gnu -C dwarf-version=4 -Copt-level=0
//@ needs-llvm-components: x86

Expand Down
2 changes: 1 addition & 1 deletion tests/assembly-llvm/dwarf5.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Makes sure that `-C dwarf-version=5` causes `rustc` to emit DWARF version 5.
//@ add-core-stubs
//@ add-minicore
//@ assembly-output: emit-asm
//@ compile-flags: -g --target x86_64-unknown-linux-gnu -C dwarf-version=5 -Copt-level=0
//@ needs-llvm-components: x86
Expand Down
2 changes: 1 addition & 1 deletion tests/assembly-llvm/loongarch-float-struct-abi.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//@ add-core-stubs
//@ add-minicore
//@ assembly-output: emit-asm
//@ compile-flags: -Copt-level=3 --target loongarch64-unknown-linux-gnu
//@ needs-llvm-components: loongarch
Expand Down
2 changes: 1 addition & 1 deletion tests/assembly-llvm/naked-functions/aix.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//@ revisions: elfv1-be aix
//@ add-core-stubs
//@ add-minicore
//@ assembly-output: emit-asm
//
//@[elfv1-be] compile-flags: --target powerpc64-unknown-linux-gnu
Expand Down
2 changes: 1 addition & 1 deletion tests/assembly-llvm/naked-functions/wasm32.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//@ revisions: wasm32-unknown wasm64-unknown wasm32-wasip1
//@ add-core-stubs
//@ add-minicore
//@ assembly-output: emit-asm
//@ [wasm32-unknown] compile-flags: --target wasm32-unknown-unknown
//@ [wasm64-unknown] compile-flags: --target wasm64-unknown-unknown
Expand Down
2 changes: 1 addition & 1 deletion tests/assembly-llvm/pic-relocation-model.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//@ add-core-stubs
//@ add-minicore
//@ revisions: x64
//@ assembly-output: emit-asm
//@ [x64] compile-flags: --target x86_64-unknown-linux-gnu -Crelocation-model=pic
Expand Down
2 changes: 1 addition & 1 deletion tests/assembly-llvm/pie-relocation-model.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//@ add-core-stubs
//@ add-minicore
//@ revisions: x64
//@ assembly-output: emit-asm
//@ [x64] compile-flags: --target x86_64-unknown-linux-gnu -Crelocation-model=pie
Expand Down
2 changes: 1 addition & 1 deletion tests/assembly-llvm/powerpc64-struct-abi.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//@ add-core-stubs
//@ add-minicore
//@ revisions: elfv1-be elfv2-be elfv2-le aix
//@ assembly-output: emit-asm
//@ compile-flags: -Copt-level=3
Expand Down
2 changes: 1 addition & 1 deletion tests/assembly-llvm/reg-struct-return.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
//! `-Zreg-struct-return` is activated
//! * Caller side, verifying callers do receive returned structs in registers when
//! `-Zreg-struct-return` is activated
//@ add-core-stubs
//@ add-minicore
//@ assembly-output: emit-asm
//@ compile-flags: -O --target=i686-unknown-linux-gnu -Crelocation-model=static
//@ revisions: WITH WITHOUT
Expand Down
2 changes: 1 addition & 1 deletion tests/assembly-llvm/regparm-module-flag.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Test the regparm ABI with builtin and non-builtin calls
// Issue: https://github.com/rust-lang/rust/issues/145271
//@ add-core-stubs
//@ add-minicore
//@ assembly-output: emit-asm
//@ compile-flags: -O --target=i686-unknown-linux-gnu -Crelocation-model=static
//@ revisions: REGPARM1 REGPARM2 REGPARM3
Expand Down
2 changes: 1 addition & 1 deletion tests/assembly-llvm/riscv-float-struct-abi.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//@ add-core-stubs
//@ add-minicore
//@ assembly-output: emit-asm
//@ compile-flags: -Copt-level=3 --target riscv64gc-unknown-linux-gnu
//@ needs-llvm-components: riscv
Expand Down
2 changes: 1 addition & 1 deletion tests/assembly-llvm/riscv-soft-abi-with-float-features.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//@ add-core-stubs
//@ add-minicore
//@ assembly-output: emit-asm
//@ compile-flags: --target riscv64imac-unknown-none-elf -Ctarget-feature=+f,+d
//@ needs-llvm-components: riscv
Expand Down
2 changes: 1 addition & 1 deletion tests/assembly-llvm/s390x-backchain-toggle.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//@ add-core-stubs
//@ add-minicore
//@ revisions: enable-backchain disable-backchain default-backchain
//@ assembly-output: emit-asm
//@ compile-flags: -Copt-level=3 --crate-type=lib --target=s390x-unknown-linux-gnu
Expand Down
2 changes: 1 addition & 1 deletion tests/assembly-llvm/s390x-vector-abi.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//@ revisions: z10 z10_vector z13 z13_no_vector
//@ add-core-stubs
//@ add-minicore
// ignore-tidy-linelength
//@ assembly-output: emit-asm
//@ compile-flags: -Copt-level=3 -Z merge-functions=disabled
Expand Down
2 changes: 1 addition & 1 deletion tests/assembly-llvm/sanitizer/kcfi/emit-arity-indicator.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Verifies that KCFI arity indicator is emitted.
//
//@ add-core-stubs
//@ add-minicore
//@ revisions: x86_64
//@ assembly-output: emit-asm
//@[x86_64] compile-flags: --target x86_64-unknown-linux-gnu -Cllvm-args=-x86-asm-syntax=intel -Ctarget-feature=-crt-static -Cpanic=abort -Zsanitizer=kcfi -Zsanitizer-kcfi-arity -Copt-level=0
Expand Down
2 changes: 1 addition & 1 deletion tests/assembly-llvm/simd-bitmask.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//@ add-core-stubs
//@ add-minicore
//@ revisions: x86 x86-avx2 x86-avx512 aarch64
//@ [x86] compile-flags: --target=x86_64-unknown-linux-gnu -C llvm-args=-x86-asm-syntax=intel
//@ [x86] needs-llvm-components: x86
Expand Down
Loading
Loading