Skip to content

Rollup of 8 pull requests #140245

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 20 commits into from
Apr 24, 2025
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
2678d04
mitigate MSVC unsoundness by not emitting alignment attributes on win…
RalfJung Apr 2, 2025
e702f96
check_align: we can still check low alignments on MSVC
RalfJung Apr 4, 2025
17664d1
Update doc of cygwin target
Berrysoft Apr 23, 2025
0a76ef8
Rename `compute_x` methods
BoxyUwU Apr 23, 2025
c6e6ac9
Module docs
BoxyUwU Apr 23, 2025
e3296cd
compiletest: `//@ add-core-stubs` implies `-Cforce-unwind-tables=yes`
jieyouxu Apr 23, 2025
c79f156
tests: account for CFI directives in `tests/assembly/x86-return-float…
jieyouxu Apr 23, 2025
f2ab763
rustc-dev-guide: document that `//@ add-core-stubs` imply `-Cforce-un…
jieyouxu Apr 23, 2025
f0399b8
triagebot: label minicore changes w/ `A-test-infra-minicore`
jieyouxu Apr 23, 2025
1162f42
Remove hack
compiler-errors Apr 23, 2025
16da97b
Revert overzealous parse recovery for single colons
fmease Apr 24, 2025
e88b289
Mention average in midpoint documentations
Urgau Apr 20, 2025
a8ebfb2
Rollup merge of #139261 - RalfJung:msvc-align-mitigation, r=oli-obk
matthiaskrgr Apr 24, 2025
d08a527
Rollup merge of #140075 - Urgau:midpoint-average, r=tgross35
matthiaskrgr Apr 24, 2025
93c1e05
Rollup merge of #140184 - Berrysoft:cygwin-target-doc, r=Noratrieb
matthiaskrgr Apr 24, 2025
60c2c34
Rollup merge of #140186 - BoxyUwU:compute_what, r=compiler-errors
matthiaskrgr Apr 24, 2025
a90f31e
Rollup merge of #140194 - jieyouxu:minicore-force-unwind-tables, r=bj…
matthiaskrgr Apr 24, 2025
984ef2c
Rollup merge of #140195 - jieyouxu:minicore-triagebot, r=jieyouxu
matthiaskrgr Apr 24, 2025
1553cfa
Rollup merge of #140214 - compiler-errors:remove-hack, r=lcnr
matthiaskrgr Apr 24, 2025
f45d2bd
Rollup merge of #140228 - fmease:revert-overzealous-colon-recovery, r…
matthiaskrgr Apr 24, 2025
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
26 changes: 19 additions & 7 deletions src/doc/rustc-dev-guide/src/tests/minicore.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,37 @@
ui/codegen/assembly test suites. It provides `core` stubs for tests that need to
build for cross-compiled targets but do not need/want to run.

<div class="warning">
Please note that [`minicore`] is only intended for `core` items, and explicitly
**not** `std` or `alloc` items because `core` items are applicable to a wider
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.

## Implied compiler flags

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

1. `-C panic=abort`
2. `-C force-unwind-tables=yes`

## Adding more `core` stubs

If you find a `core` item to be missing from the [`minicore`] stub, consider
adding it to the test auxiliary if it's likely to be used or is already needed
by more than one test.

<div class="warning">
Please note that [`minicore`] is only intended for `core` items, and explicitly
**not** `std` or `alloc` items because `core` items are applicable to a wider
range of tests.
</div>

## Example codegen test that uses `minicore`

```rust,no_run
Expand Down
8 changes: 6 additions & 2 deletions src/tools/compiletest/src/runtest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1710,12 +1710,16 @@ impl<'test> TestCx<'test> {
rustc.args(&self.props.compile_flags);

// FIXME(jieyouxu): we should report a fatal error or warning if user wrote `-Cpanic=` with
// something that's not `abort`, however, by moving this last we should override previous
// `-Cpanic=`s
// something that's not `abort` and `-Cforce-unwind-tables` with a value that is not `yes`,
// however, by moving this last we should override previous `-Cpanic`s and
// `-Cforce-unwind-tables`s. Note that checking here is very fragile, because we'd have to
// account for all possible compile flag splittings (they have some... intricacies and are
// not yet normalized).
//
// `minicore` requires `#![no_std]` and `#![no_core]`, which means no unwinding panics.
if self.props.add_core_stubs {
rustc.arg("-Cpanic=abort");
rustc.arg("-Cforce-unwind-tables=yes");
}

rustc
Expand Down
10 changes: 10 additions & 0 deletions tests/assembly/x86-return-float.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ use minicore::*;
pub fn return_f32(x: f32) -> f32 {
// CHECK: movss {{.*}}(%ebp), %xmm0
// CHECK-NEXT: popl %ebp
// linux-NEXT: .cfi_def_cfa
// CHECK-NEXT: retl
x
}
Expand All @@ -44,6 +45,7 @@ pub fn return_f32(x: f32) -> f32 {
pub fn return_f64(x: f64) -> f64 {
// CHECK: movsd {{.*}}(%ebp), %xmm0
// CHECK-NEXT: popl %ebp
// linux-NEXT: .cfi_def_cfa
// CHECK-NEXT: retl
x
}
Expand Down Expand Up @@ -313,9 +315,13 @@ pub unsafe fn call_other_f64(x: &mut (usize, f64)) {
#[no_mangle]
pub fn return_f16(x: f16) -> f16 {
// CHECK: pushl %ebp
// linux-NEXT: .cfi_def_cfa_offset
// linux-NEXT: .cfi_offset
// CHECK-NEXT: movl %esp, %ebp
// linux-NEXT: .cfi_def_cfa_register
// CHECK-NEXT: pinsrw $0, 8(%ebp), %xmm0
// CHECK-NEXT: popl %ebp
// linux-NEXT: .cfi_def_cfa
// CHECK-NEXT: retl
x
}
Expand All @@ -324,10 +330,14 @@ pub fn return_f16(x: f16) -> f16 {
#[no_mangle]
pub fn return_f128(x: f128) -> f128 {
// CHECK: pushl %ebp
// linux-NEXT: .cfi_def_cfa_offset
// linux-NEXT: .cfi_offset
// CHECK-NEXT: movl %esp, %ebp
// linux-NEXT: .cfi_def_cfa_register
// linux-NEXT: movaps 8(%ebp), %xmm0
// win-NEXT: movups 8(%ebp), %xmm0
// CHECK-NEXT: popl %ebp
// linux-NEXT: .cfi_def_cfa
// CHECK-NEXT: retl
x
}