Skip to content

Commit 516bfa1

Browse files
authored
Unrolled build for rust-lang#140194
Rollup merge of rust-lang#140194 - jieyouxu:minicore-force-unwind-tables, r=bjorn3 minicore: Have `//@ add-core-stubs` also imply `-Cforce-unwind-tables=yes` To preserve CFI directives in assembly tests, as `//@ add-core-stubs` already imply `-C panic=abort`. This is a blocker for rust-lang#140037 (comment). cc ```@RalfJung``` r? ```@bjorn3```
2 parents dc8fe1f + f2ab763 commit 516bfa1

File tree

3 files changed

+35
-9
lines changed

3 files changed

+35
-9
lines changed

src/doc/rustc-dev-guide/src/tests/minicore.md

+19-7
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,37 @@
66
ui/codegen/assembly test suites. It provides `core` stubs for tests that need to
77
build for cross-compiled targets but do not need/want to run.
88

9+
<div class="warning">
10+
Please note that [`minicore`] is only intended for `core` items, and explicitly
11+
**not** `std` or `alloc` items because `core` items are applicable to a wider
12+
range of tests.
13+
</div>
14+
915
A test can use [`minicore`] by specifying the `//@ add-core-stubs` directive.
1016
Then, mark the test with `#![feature(no_core)]` + `#![no_std]` + `#![no_core]`.
1117
Due to Edition 2015 extern prelude rules, you will probably need to declare
1218
`minicore` as an extern crate.
1319

20+
## Implied compiler flags
21+
1422
Due to the `no_std` + `no_core` nature of these tests, `//@ add-core-stubs`
1523
implies and requires that the test will be built with `-C panic=abort`.
16-
Unwinding panics are not supported.
24+
**Unwinding panics are not supported.**
25+
26+
Tests will also be built with `-C force-unwind-tables=yes` to preserve CFI
27+
directives in assembly tests.
28+
29+
TL;DR: `//@ add-core-stubs` implies two compiler flags:
30+
31+
1. `-C panic=abort`
32+
2. `-C force-unwind-tables=yes`
33+
34+
## Adding more `core` stubs
1735

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

22-
<div class="warning">
23-
Please note that [`minicore`] is only intended for `core` items, and explicitly
24-
**not** `std` or `alloc` items because `core` items are applicable to a wider
25-
range of tests.
26-
</div>
27-
2840
## Example codegen test that uses `minicore`
2941

3042
```rust,no_run

src/tools/compiletest/src/runtest.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -1710,12 +1710,16 @@ impl<'test> TestCx<'test> {
17101710
rustc.args(&self.props.compile_flags);
17111711

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

17211725
rustc

tests/assembly/x86-return-float.rs

+10
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ use minicore::*;
3535
pub fn return_f32(x: f32) -> f32 {
3636
// CHECK: movss {{.*}}(%ebp), %xmm0
3737
// CHECK-NEXT: popl %ebp
38+
// linux-NEXT: .cfi_def_cfa
3839
// CHECK-NEXT: retl
3940
x
4041
}
@@ -44,6 +45,7 @@ pub fn return_f32(x: f32) -> f32 {
4445
pub fn return_f64(x: f64) -> f64 {
4546
// CHECK: movsd {{.*}}(%ebp), %xmm0
4647
// CHECK-NEXT: popl %ebp
48+
// linux-NEXT: .cfi_def_cfa
4749
// CHECK-NEXT: retl
4850
x
4951
}
@@ -313,9 +315,13 @@ pub unsafe fn call_other_f64(x: &mut (usize, f64)) {
313315
#[no_mangle]
314316
pub fn return_f16(x: f16) -> f16 {
315317
// CHECK: pushl %ebp
318+
// linux-NEXT: .cfi_def_cfa_offset
319+
// linux-NEXT: .cfi_offset
316320
// CHECK-NEXT: movl %esp, %ebp
321+
// linux-NEXT: .cfi_def_cfa_register
317322
// CHECK-NEXT: pinsrw $0, 8(%ebp), %xmm0
318323
// CHECK-NEXT: popl %ebp
324+
// linux-NEXT: .cfi_def_cfa
319325
// CHECK-NEXT: retl
320326
x
321327
}
@@ -324,10 +330,14 @@ pub fn return_f16(x: f16) -> f16 {
324330
#[no_mangle]
325331
pub fn return_f128(x: f128) -> f128 {
326332
// CHECK: pushl %ebp
333+
// linux-NEXT: .cfi_def_cfa_offset
334+
// linux-NEXT: .cfi_offset
327335
// CHECK-NEXT: movl %esp, %ebp
336+
// linux-NEXT: .cfi_def_cfa_register
328337
// linux-NEXT: movaps 8(%ebp), %xmm0
329338
// win-NEXT: movups 8(%ebp), %xmm0
330339
// CHECK-NEXT: popl %ebp
340+
// linux-NEXT: .cfi_def_cfa
331341
// CHECK-NEXT: retl
332342
x
333343
}

0 commit comments

Comments
 (0)