Commit Graph

100 Commits

Author SHA1 Message Date
Ralf Jung
56ee492a6e move strict provenance lints to new feature gate, remove old feature gates 2024-10-21 15:22:17 +01:00
Jubilee Young
f21f4cd60e library: Compute RUST_EXCEPTION_CLASS from native-endian bytes
This makes it appear correctly in hexdumps on both LE and BE platforms.
2024-09-26 11:34:17 -07:00
Josh Stone
f4d9d1a0ea Use &raw in the standard library
Since the stabilization in #127679 has reached stage0, 1.82-beta, we can
start using `&raw` freely, and even the soft-deprecated `ptr::addr_of!`
and `ptr::addr_of_mut!` can stop allowing the unstable feature.

I intentionally did not change any documentation or tests, but the rest
of those macro uses are all now using `&raw const` or `&raw mut` in the
standard library.
2024-09-25 17:03:20 -07:00
Huang Qi
24f622cf80 Initial std library support for NuttX
Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
2024-09-24 15:35:40 +08:00
Michael Goulet
c682aa162b Reformat using the new identifier sorting from rustfmt 2024-09-22 19:11:29 -04:00
bors
5ba6db1b64 Auto merge of #124895 - obeis:static-mut-hidden-ref, r=compiler-errors
Disallow hidden references to mutable static

Closes #123060

Tracking:
- https://github.com/rust-lang/rust/issues/123758
2024-09-20 17:25:34 +00:00
Jubilee Young
fef7373d13 library: Compute Rust exception class from its string repr 2024-09-14 20:26:37 -07:00
Obei Sideg
3b0ce1bc33
Update tests for hidden references to mutable static 2024-09-13 14:10:56 +03:00
bors
12b26c13fb Auto merge of #129941 - BoxyUwU:bump-boostrap, r=albertlarsan68
Bump boostrap compiler to new beta

Accidentally left some comments on the update cfgs commit directly xd
2024-09-07 20:37:30 +00:00
Boxy
0091b8ab2a update cfgs 2024-09-05 17:24:01 +01:00
Jan Sommer
6f435cb07f Port std library to RTEMS 2024-09-03 09:19:29 +02:00
bors
f8060d282d Auto merge of #128083 - Mark-Simulacrum:bump-bootstrap, r=albertlarsan68
Bump bootstrap compiler to new beta

https://forge.rust-lang.org/release/process.html#master-bootstrap-update-t-2-day-tuesday
2024-07-30 17:49:08 +00:00
Nicholas Nethercote
84ac80f192 Reformat use declarations.
The previous commit updated `rustfmt.toml` appropriately. This commit is
the outcome of running `x fmt --all` with the new formatting options.
2024-07-29 08:26:52 +10:00
Mark Rousskov
5eca36d27a step cfg(bootstrap) 2024-07-28 14:46:29 -04:00
Matthias Krüger
1b4b0e9a4d
Rollup merge of #125834 - workingjubilee:weaken-thir-unsafeck-for-addr-of-static-mut, r=compiler-errors
treat `&raw (const|mut) UNSAFE_STATIC` implied deref as safe

Fixes rust-lang/rust#125833

As reported in that and related issues, `static mut STATIC_MUT: T` is very often used in embedded code, and is in many ways equivalent to `static STATIC_CELL: SyncUnsafeCell<T>`. The Rust expression of `&raw mut STATIC_MUT` and `SyncUnsafeCell::get(&STATIC_CELL)` are approximately equal, and both evaluate to `*mut T`. The library function is safe because it has *declared itself* to be safe. However, the raw ref operator is unsafe because all uses of `static mut` are considered unsafe, even though the static's value is not used by this expression (unlike, for example, `&STATIC_MUT`).

We can fix this unnatural difference by simply adding the proper exclusion for the safety check inside the THIR unsafeck, so that we do not declare it unsafe if it is not.

While the primary concern here is `static mut`, this change is made for all instances of an "unsafe static", which includes a static declared inside `extern "abi" {}`. Hypothetically, we could go as far as generalizing this to all instances of `&raw (const|mut) *ptr`, but today we do not, as we have not actually considered the range of possible expressions that use a similar encoding. We do not even extend this to thread-local equivalents, because they have less clear semantics.
2024-07-23 13:06:54 +02:00
Jubilee Young
bf454afcaa library: vary unsafety in bootstrapping for SEH 2024-07-22 14:54:36 -07:00
bjorn3
45b0f68e34 Use the native unwind function in miri where possible 2024-07-01 18:02:40 +00:00
bors
5ced3dad57 Auto merge of #125853 - tesuji:promote-fail-fast, r=cjgillot
promote_consts: some clean-up after experimenting

This is some clean-up after experimenting in #125916,
Prefer to review commit-by-commit.
2024-06-21 16:00:14 +00:00
bors
1ca578e68e Auto merge of #126736 - matthiaskrgr:rollup-rb20oe3, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #126380 (Add std Xtensa targets support)
 - #126636 (Resolve Clippy `f16` and `f128` `unimplemented!`/`FIXME`s )
 - #126659 (More status-quo tests for the `#[coverage(..)]` attribute)
 - #126711 (Make Option::as_[mut_]slice const)
 - #126717 (Clean up some comments near `use` declarations)
 - #126719 (Fix assertion failure for some `Expect` diagnostics.)
 - #126730 (Add opaque type corner case test)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-06-20 13:36:42 +00:00
Nicholas Nethercote
665821cb60 Add blank lines after module-level //! comments.
Most modules have such a blank line, but some don't. Inserting the blank
line makes it clearer that the `//!` comments are describing the entire
module, rather than the `use` declaration(s) that immediately follows.
2024-06-20 09:23:20 +10:00
Gary Guo
ebdfcd93a3 Stabilise c_unwind 2024-06-19 13:54:51 +01:00
Lzu Tao
06aee7ee03 use rustc-dep-of-std in panic_unwind
Wihout it, std keeps rebuiling when unchanged.
But we could use `--keep-stage=1` to make it not rebuild.
2024-06-16 09:38:30 +00:00
Chris Denton
b1f1039d8b
Replace libc::c_int with core::ffi::c_int
And remove the libc crate when it isn't needed
2024-04-14 07:11:51 +00:00
niluxv
f63d5d1dcd
Refactor panic_unwind/seh.rs pointer use; x86 now conforms to strict-provenance 2024-04-11 20:47:52 +02:00
Mara Bos
5e4cc6f694 SeqCst->Relaxed in panic_unwind/emcc.
SeqCst is unnecessary here.
2024-03-19 15:27:11 +01:00
Jubilee
1279830068
Rollup merge of #121438 - coolreader18:wasm32-panic-unwind, r=cuviper
std support for wasm32 panic=unwind

Tracking issue: #118168

This adds std support for `-Cpanic=unwind` on wasm, and with it slightly more fleshed out rustc support. Now, the stable default is still panic=abort without exception-handling, but if you `-Zbuild-std` with `RUSTFLAGS=-Cpanic=unwind`, you get wasm exception-handling try/catch blocks in the binary:

```rust
#[no_mangle]
pub fn foo_bar(x: bool) -> *mut u8 {
    let s = Box::<str>::from("hello");
    maybe_panic(x);
    Box::into_raw(s).cast()
}

#[inline(never)]
#[no_mangle]
fn maybe_panic(x: bool) {
    if x {
        panic!("AAAAA");
    }
}
```
```wat
;; snip...
(try $label$5
 (do
  (call $maybe_panic
   (local.get $0)
  )
  (br $label$1)
 )
 (catch_all
  (global.set $__stack_pointer
   (local.get $1)
  )
  (call $__rust_dealloc
   (local.get $2)
   (i32.const 5)
   (i32.const 1)
  )
  (rethrow $label$5)
 )
)
;; snip...
```
2024-03-11 09:29:34 -07:00
Ralf Jung
a3c0f3af9c miri: rename miri_start_panic → miri_start_unwind 2024-02-26 11:10:18 +01:00
Pavel Grigorenko
58c8c0853f
Get rid of some #[allow(static_mut_refs)] 2024-02-23 18:02:25 +03:00
Noa
125b26acf6
Use Itanium ABI for thrown exceptions 2024-02-22 17:39:49 -06:00
Noa
658a0a20ea
Unconditionally pass -wasm-enable-eh 2024-02-22 16:52:48 -06:00
Noa
3908a935ef
std support for wasm32 panic=unwind 2024-02-22 16:45:26 -06:00
Obei Sideg
408eeae59d Improve wording of static_mut_ref
Rename `static_mut_ref` lint to `static_mut_refs`.
2024-02-18 06:01:40 +03:00
Mark Rousskov
9a5034a20e Step all bootstrap cfgs forward
This also takes care of other bootstrap-related changes.
2024-02-08 07:44:34 -05:00
Obei Sideg
a8aa6878f6 Update test for E0796 and static_mut_ref lint 2024-01-07 17:29:25 +03:00
Sean Cross
28203172de panic_unwind: support unwinding on xous
Now that `unwind` supports Xous, enable unwinding panics on Xous.

Signed-off-by: Sean Cross <sean@xobs.io>
2023-11-16 15:23:09 +08:00
niluxv
e7a3c341dd
Use pointers instead of usize addresses for landing pads
This bring unwind and personality code more in line with strict-provenance
2023-10-10 09:59:39 +02:00
Mara Bos
76d9b3689c Rename BoxMeUp to PanicPayload. 2023-09-20 19:24:52 +02:00
Mark Rousskov
0a916062aa Bump cfg(bootstrap) 2023-08-23 20:05:14 -04:00
Benedikt Radtke
3f3262e592 stabilize abi_thiscall 2023-08-07 14:11:03 +02:00
Nilstrieb
5830ca216d Add internal_features lint
It lints against features that are inteded to be internal to the
compiler and standard library. Implements MCP #596.

We allow `internal_features` in the standard library and compiler as those
use many features and this _is_ the standard library from the "internal to the compiler and
standard library" after all.

Marking some features as internal wasn't exactly the most scientific approach, I just marked some
mostly obvious features. While there is a categorization in the macro,
it's not very well upheld (should probably be fixed in another PR).

We always pass `-Ainternal_features` in the testsuite
About 400 UI tests and several other tests use internal features.
Instead of throwing the attribute on each one, just always allow them.
There's nothing wrong with testing internal features^^
2023-08-03 14:50:50 +02:00
Gary Guo
723aee2e56 Partial stabilisation of c_unwind 2023-04-29 13:01:44 +01:00
bjorn3
b874502a20 Remove unnecessary raw pointer in __rust_start_panic arg
It is no longer necessary as __rust_start_panic switched to the Rust abi.
2023-03-26 16:40:18 +00:00
jonathanCogan
72067c77bd Replace libstd, libcore, liballoc in docs. 2022-12-30 14:00:40 +01:00
Matthias Krüger
747f29fbab
Rollup merge of #103989 - arlosi:arm32-panic, r=Amanieu
Fix build of std for thumbv7a-pc-windows-msvc

Attempting to build std for the tier-3 target `thumbv7a-pc-windows-msvc` fails with the following error:
```
Building stage1 std artifacts (x86_64-pc-windows-msvc -> thumbv7a-pc-windows-msvc)
..
LLVM ERROR: WinEH not implemented for this target
error: could not compile `panic_unwind`
```

EH (unwinding) is not supported by LLVM for 32 bit arm msvc targets. This changes panic unwind to use the dummy implementation for `thumbv7a-pc-windows-msvc`.
2022-11-19 15:35:20 +01:00
Arlo Siemsen
7c60236036 Fix build of thumbv7a-pc-windows-msvc 2022-11-04 14:35:56 -07:00
Collin Baker
dfab01b6e0 Remove std's transitive dependency on cfg-if 0.1
After rust-lang/rust#101946 this completes the move to cfg-if 1.0 by:
* Updating getrandom 0.1.14->0.1.16
* Updating panic_abort, panic_unwind, and unwind to cfg-if 1.0
2022-11-02 18:01:20 -04:00
Gary Guo
4e6d60c837 Fix alloc size 2022-10-23 20:30:16 +01:00
Gary Guo
979d1a2c78 Apply suggestion
Co-authored-by: Amanieu d'Antras <amanieu@gmail.com>
2022-10-23 20:30:16 +01:00
Gary Guo
86c65d2c1c Implement Rust foreign exception protection for EMCC and SEH 2022-10-23 20:30:16 +01:00
Gary Guo
e521a8d46b Prevent foreign Rust exceptions from being caught 2022-10-23 20:30:16 +01:00