Commit Graph

8375 Commits

Author SHA1 Message Date
Matthias Krüger
60bbb533df Rollup merge of #147205 - alexcrichton:wasip3, r=davidtwco
Add a new `wasm32-wasip3` target to Rust

This commit adds a new tier 3 target to rustc, `wasm32-wasip3`. This follows in the footsteps of the previous `wasm32-wasip2` target and is used to represent binding to the WASIp3 set of APIs managed by the WASI subgroup to the WebAssembly Community Group.

As of now the WASIp3 set of APIs are not finalized nor standardized. They're in the process of doing so and the current trajectory is to have the APIs published in December of this year. The goal here is to get the wheels turning in Rust to have the target in a
more-ready-than-nonexistent state by the time this happens in December.

For now the `wasm32-wasip3` target looks exactly the same as `wasm32-wasip2` except that `target_env = "p3"` is specified. This indicates to crates in the ecosystem that WASIp3 APIs should be used, such as the [`wasip3` crate]. Over time this target will evolve as implementation in guest toolchains progress, notably:

* The standard library will use WASIp3 APIs natively once they're finalized in the WASI subgroup.
* Support through `wasi-libc` will be updated to use WASIp3 natively which Rust will then transitively use.
* Longer-term, features such as cooperative multithreading will be added to the WASIp3-track of targets to enable using `std::thread`, for example, on this target.

These changes are all expected to be non-breaking changes for users of this target. Runtimes supporting WASIp3, currently Wasmtime and Jco, support WASIp2 APIs as well and will work with components whether or not they import WASIp2, both WASIp2 and WASIp3, or just WASIp3 APIs. This means that changing the internal implementation details of libstd over time is expected to be a non-breaking change.

[`wasip3` crate]: https://crates.io/crates/wasip3
2025-10-07 19:39:07 +02:00
Stuart Cook
56c96aebfc Rollup merge of #147328 - EFanZh:lock-with, r=joboet
Implement non-poisoning `Mutex::with_mut`, `RwLock::with` and `RwLock::with_mut`

ACP: https://github.com/rust-lang/libs-team/issues/497.
2025-10-05 15:35:04 +11:00
Matthias Krüger
c389e2ed9e Rollup merge of #147190 - joboet:sys-net-cleanup, r=hkBst,tgross35
std: `sys::net` cleanups

This PR contains three improvements to the socket-based networking implementation (aa1263e768 is just to add the now missing `unsafe`). Best reviewed commit-by-commit.
2025-10-04 17:11:11 +02:00
Matthias Krüger
baea20ba44 Rollup merge of #146451 - DimitriiTrater:atan2_correctness_docs, r=tgross35
Fix atan2 inaccuracy in documentation

Fixes rust-lang/rust#136275
2025-10-04 17:11:09 +02:00
EFanZh
ba42380142 Implement non-poisoning Mutex::with_mut, RwLock::with and RwLock::with_mut
ACP: https://github.com/rust-lang/libs-team/issues/497.
2025-10-04 17:16:00 +08:00
Fletcher Porter
1485e7887b Document fully-qualified syntax in as' keyword doc 2025-10-03 17:31:55 +03:00
Alex Crichton
ce2087692f Add a new wasm32-wasip3 target to Rust
This commit adds a new tier 3 target to rustc, `wasm32-wasip3`. This
follows in the footsteps of the previous `wasm32-wasip2` target and is
used to represent binding to the WASIp3 set of APIs managed by the WASI
subgroup to the WebAssembly Community Group.

As of now the WASIp3 set of APIs are not finalized nor standardized.
They're in the process of doing so and the current trajectory is to have
the APIs published in December of this year. The goal here is to get the
wheels turning in Rust to have the target in a
more-ready-than-nonexistent state by the time this happens in December.

For now the `wasm32-wasip3` target looks exactly the same as
`wasm32-wasip2` except that `target_env = "p3"` is specified. This
indicates to crates in the ecosystem that WASIp3 APIs should be used,
such as the [`wasip3` crate]. Over time this target will evolve as
implementation in guest toolchains progress, notably:

* The standard library will use WASIp3 APIs natively once they're
  finalized in the WASI subgroup.
* Support through `wasi-libc` will be updated to use WASIp3 natively
  which Rust will then transitively use.
* Longer-term, features such as cooperative multithreading will be added
  to the WASIp3-track of targets to enable using `std::thread`, for
  example, on this target.

These changes are all expected to be non-breaking changes for users of
this target. Runtimes supporting WASIp3, currently Wasmtime and Jco,
support WASIp2 APIs as well and will work with components whether or not
they import WASIp2, both WASIp2 and WASIp3, or just WASIp3 APIs. This
means that changing the internal implementation details of libstd over
time is expected to be a non-breaking change.

[`wasip3` crate]: https://crates.io/crates/wasip3
2025-10-02 15:09:09 -07:00
Matthias Krüger
92aac1bdf6 Rollup merge of #146281 - Jules-Bertholet:static-align-thread-local, r=Mark-Simulacrum
Support `#[rustc_align_static]` inside `thread_local!`

Tracking issue: rust-lang/rust#146177

```rust
thread_local! {
    #[rustc_align_static(64)]
    static SO_ALIGNED: u64 = const { 0 };
}
```

This increases the amount of recursion the macro performs (once per attribute in addition to the previous once per item), making it easier to hit the recursion limit. I’ve added workarounds to limit the impact in the case of long doc comments, but this still needs a crater run just in case.

r? libs

``@rustbot`` label A-attributes A-macros A-thread-locals F-static_align T-libs
2025-10-02 10:27:48 +02:00
Jules Bertholet
94f00f4e4a Fix memory leak in os impl 2025-10-01 12:28:18 -04:00
Stuart Cook
06e059d45d Rollup merge of #147213 - ivmarkov:fix-hostname-espidf, r=joboet
Fix broken STD build for ESP-IDF

PRs rust-lang/rust#147162 and rust-lang/rust#146937 did [broke](https://github.com/esp-rs/esp-idf-sys/actions/runs/18151791720/job/51663969786) the STD build for `target_os = "espidf"` because that target [does not have neither a `gethostname`, not a `libc::_SC_HOST_NAME_MAX` by default](https://github.com/espressif/esp-idf/issues/14849).

While there is a [3rd party component for this syscall](https://components.espressif.com/components/espressif/sock_utils/versions/0.2.2/readme) in the ESP-IDF component registry, I don't think we should use it, because it does not come with ESP-IDF by default.

Therefore, the one-liner fix just re-routes ESP-IDF into the `unsupported` branch.
2025-10-01 22:15:03 +10:00
ivmarkov
b1c212f850 Fix broken STD build for ESP-IDF 2025-10-01 08:12:44 +00:00
bors
1e1a39441b Auto merge of #147198 - matthiaskrgr:rollup-b0ryvvu, r=matthiaskrgr
Rollup of 6 pull requests

Successful merges:

 - rust-lang/rust#143069 (Add fast-path for accessing the current thread id)
 - rust-lang/rust#146518 (Improve the documentation around `ZERO_AR_DATE`)
 - rust-lang/rust#146596 (Add a dummy codegen backend)
 - rust-lang/rust#146617 (Don’t suggest foreign `doc(hidden)` types in "the following other types implement trait" diagnostics)
 - rust-lang/rust#146635 (cg_llvm: Stop using `as_c_char_ptr` for coverage-related bindings)
 - rust-lang/rust#147184 (Fix the bevy implied bounds hack for the next solver)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-10-01 04:46:14 +00:00
Josh Simmons
cbaec31c10 Add fast-path for accessing the current thread id
Accessing the thread id is often used in profiling and debugging, as
well as some approaches for sound single-threaded access to data.

Currently the only way to access the thread id is by first obtaining a
handle to the current thread. While this is not exactly slow, it does
require an atomic inc-ref and dec-ref operation, as well as the
injection of `Thread`'s drop code into the caller.

This publicly exposes the existing fast-path for accessing the current
thread id.
2025-09-30 20:51:03 +02:00
Matthias Krüger
61b9467af8 Rollup merge of #142506 - clarfonthey:path-trailing-sep, r=joboet
Add `Path::has_trailing_sep` and related methods

Implements rust-lang/libs-team#335.

Tracking issue: rust-lang/rust#142503

Notable differences from ACP:

* `trim_trailing_sep` was added to `Path` since it felt reasonable to ensure that the inverse operation was available.
* Per suggestion of `@kennytm,` added `push_trailing_sep` and `pop_trailing_sep` to `PathBuf` in addition to `set_trailing_sep`.

This also updates some of the docs on various `Path` methods to use the term "trailing separator" instead of "trailing slash" for consistency.
2025-09-30 20:46:44 +02:00
joboet
3534594029 std: merge address family computation 2025-09-30 17:10:22 +02:00
joboet
aa1263e768 std: add missing unsafe blocks 2025-09-30 16:55:21 +02:00
joboet
eba1416c01 std: improve internal socket functions 2025-09-30 12:43:36 +02:00
joboet
d615d2ff34 std: call WinSock cleanup function directly instead of through its reexport 2025-09-30 11:59:08 +02:00
Matthias Krüger
8223831942 Rollup merge of #146937 - joboet:gethostname, r=Mark-Simulacrum
std: implement `hostname`

Resolves https://github.com/rust-lang/libs-team/issues/330
Tracking issue: https://github.com/rust-lang/rust/issues/135142

This is based on rust-lang/rust#135141, but I've reimplemented the UNIX version, which now:
* uses `sysconf(_SC_HOST_NAME_MAX)` as an initial buffer length
* returns `OutOfMemory` if the `Vec` allocation fails
* retries the operation if it detects that the name returned by `gethostname` was truncated

Additionally, as part of the rebase, I had to move some WinSock abstractions (initialisation and error access) to `sys::pal` so that they can be accessed from `sys::net::hostname`.

CC ``@orowith2os`` (and thank you for your work!)
2025-09-29 21:42:41 +02:00
joboet
97333f8c9a std: implement hostname 2025-09-29 10:24:54 +02:00
bors
772f380092 Auto merge of #147090 - Noratrieb:immediate-abort-stack-overflow, r=joboet
Skip stack overflow handler for panic=immediate-abort

std installs guard pages and a signal handler to ensure that stackoverflows 1) terminate abruptly and 2) print an nice message. Even for panic=immediate-abort, 1) is desirable, we don't want silent data corruption there. But 2) is completely unnecessary, as users deliberately *don't* want nice messages, they want minimum binary size.

Therefore, skip the entire guard signal handler setup, which saves a lot of bytes.

I tested this with a hello world binary using fat LTO, build-std, panic=immediate-abort, opt-level=s, strip=debuginfo.

`size` reports significant savings:

```
   text	   data	    bss	    dec	    hex	filename
  15252	   1032	    104	  16388	   4004	tiny-before
   6881	    964	     48	   7893	   1ed5	tiny-after2
```

`nm -U` goes from 71 to 56, getting rid of a bunch of stack overflow related symbols. The disk size goes from `31k` to `24k`.

The impact on the error message is minimal, as the message was already
missing.

before:
```
fish: Job 1, './tiny-so-before' terminated by signal SIGABRT (Abort)
```

after:
```
fish: Job 1, './tiny-so-after' terminated by signal SIGSEGV (Address boundary error)
```

I didn't test the Windows part, but it likely also has savings.
2025-09-29 01:32:14 +00:00
Matthias Krüger
322dca8551 Rollup merge of #140482 - devnexen:tcp_deferaccept_toduration, r=joboet
std::net: update tcp deferaccept delay type to Duration.

See comment [here](https://github.com/rust-lang/rust/issues/119639#issuecomment-2839330337).
2025-09-28 18:13:10 +02:00
Matthias Krüger
f4032bcb8a Rollup merge of #147110 - SebastianSpeitel:patch-1, r=saethlin
Fix typo

Noticed this when looking at the source on doc.rust-lang.org
2025-09-28 09:15:30 +02:00
Matthias Krüger
f22af64853 Rollup merge of #147093 - jackpot51:redox-path, r=bjorn3
redox: switch to colon as path separator

We recently changed this in order to better comply with assumptions about Unix-like systems. The current PATH is set to `/usr/bin` with no separators in order to ease the transition.
2025-09-28 09:15:29 +02:00
Matthias Krüger
0fd939658e Rollup merge of #146788 - sysrex:146756/discord_invite, r=workingjubilee
chore: removes deprecated discord.

This PR just changes the wording of the contributing document to remove the deprecated Discord.

Fixes https://github.com/rust-lang/rust/issues/146756.
2025-09-28 09:15:24 +02:00
Sebastian Speitel
3a20a4d0a5 Fix typo 2025-09-28 00:51:57 +02:00
Jules Bertholet
4d32b9a178 Hoist non-platform-specific code out of thread_local_inner! 2025-09-27 17:05:39 -04:00
David Carlier
19d0e72849 fix build for android 2025-09-27 20:38:45 +01:00
Jeremy Soller
760ed37769 redox: switch to colon as path separator 2025-09-27 08:25:47 -06:00
Noratrieb
660a3486fc Skip stack overflow handler for panic=immediate-abort
std installs guard pages and a signal handler to ensure that stackoverflows 1) terminate abruptly and 2) print an nice message. Even for panic=immediate-abort, 1) is desirable, we don't want silent data corruption there. But 2) is completely unnecessary, as users deliberately *don't* want nice messages, they want minimum binary size.

Therefore, skip the entire guard signal handler setup, which saves a lot of bytes.

I tested this with a hello world binary using fat LTO, build-std, panic=immediate-abort, opt-level=s, strip=debuginfo.

`size` reports significant savings:

```
   text	   data	    bss	    dec	    hex	filename
  15252	   1032	    104	  16388	   4004	tiny-before
   6881	    964	     48	   7893	   1ed5	tiny-after2
```

`nm -U` goes from 71 to 56, getting rid of a bunch of stack overflow related symbols. The disk size goes from `31k` to `24k`.

The impact on the error message is minimal, as the message was already
missing.

before:
```
fish: Job 1, './tiny-so-before' terminated by signal SIGABRT (Abort)
```

after:
```
fish: Job 1, './tiny-so-after' terminated by signal SIGSEGV (Address boundary error)
```
2025-09-27 14:16:06 +02:00
Guillaume Gomez
254a2139f6 Remove cfg(bootstrap) for doc_cfg feature following #141925 2025-09-27 11:29:49 +02:00
Guillaume Gomez
ec00723ba1 Fix autodiff feature activation 2025-09-27 11:29:49 +02:00
Guillaume Gomez
a7ed9bf6c7 fmt 2025-09-27 11:29:49 +02:00
Guillaume Gomez
fccba2c341 Remove doc_cfg_hide feature 2025-09-27 11:29:49 +02:00
Guillaume Gomez
63aefe0737 Strenghten checks for doc(auto_cfg(show/hide)) attributes 2025-09-27 11:29:48 +02:00
Guillaume Gomez
7c00bccd3b Implement RFC 3631 2025-09-27 11:29:48 +02:00
bors
959b450747 Auto merge of #146636 - Mark-Simulacrum:bootstrap-bump, r=jieyouxu
Bump bootstrap compiler to 1.91 beta

https://forge.rust-lang.org/release/process.html#default-branch-bootstrap-update-tuesday
2025-09-27 03:50:03 +00:00
Mark Rousskov
4e9716fbc5 Update CURRENT_RUSTC_VERSION post-bump 2025-09-26 18:41:32 -04:00
Jules Bertholet
a4e87e9406 Support #[rustc_align_static] inside thread_local! 2025-09-26 13:51:09 -04:00
David Carlier
c0de794949 std::net: update tcp deferaccept delay type to Duration. 2025-09-26 18:39:29 +01:00
Matthias Krüger
f104ae4252 Rollup merge of #145113 - petrochenkov:lessfinalize, r=lcnr
resolve: Do not finalize shadowed bindings

I.e. do not mark them as used, or non-speculatively loaded, or similar.
Previously they were sometimes finalized during early resolution, causing issues like https://github.com/rust-lang/rust/pull/144793#issuecomment-3168108005.
2025-09-26 18:11:08 +02:00
Matthias Krüger
87b8eca516 Rollup merge of #147049 - vexide:vex-std, r=workingjubilee
std: fix warning in VEXos stdio module

Fixes building `std` on the `armv7a-vex-v5` target due to an unnecessarily mutable argument in `Stdin`.

This was a stupid oversight on my part towards the end of rust-lang/rust#145973's review process. Missed a warning and had a bad bootstrap config that didn't tell me about it when testing changes.
2025-09-26 06:36:34 +02:00
Tropical
0ede3fe48c std: fix warning in VEXos stdio module 2025-09-25 16:34:20 -05:00
Vadim Petrochenkov
f89660e4aa resolve: Do not finalize shadowed bindings
I.e. do not mark them as used, or non-speculative loaded, or similar.
Previously they were sometimes finalized during early resolution, causing issues like https://github.com/rust-lang/rust/pull/144793#issuecomment-3168108005.
2025-09-25 20:36:14 +03:00
bors
6f34f4ee07 Auto merge of #147019 - Zalathar:rollup-boxzbmo, r=Zalathar
Rollup of 14 pull requests

Successful merges:

 - rust-lang/rust#145067 (RawVecInner: add missing `unsafe` to unsafe fns)
 - rust-lang/rust#145277 (Do not materialise X in [X; 0] when X is unsizing a const)
 - rust-lang/rust#145973 (Add `std` support for `armv7a-vex-v5`)
 - rust-lang/rust#146667 (Add an attribute to check the number of lanes in a SIMD vector after monomorphization)
 - rust-lang/rust#146735 (unstably constify float mul_add methods)
 - rust-lang/rust#146737 (f16_f128: enable some more tests in Miri)
 - rust-lang/rust#146766 (Add attributes for #[global_allocator] functions)
 - rust-lang/rust#146905 (llvm: update remarks support on LLVM 22)
 - rust-lang/rust#146982 (Remove erroneous normalization step in `tests/run-make/linker-warning`)
 - rust-lang/rust#147005 (Small string formatting cleanup)
 - rust-lang/rust#147007 (Explicitly note `&[SocketAddr]` impl of `ToSocketAddrs`)
 - rust-lang/rust#147008 (bootstrap.py: Respect build.jobs while building bootstrap tool)
 - rust-lang/rust#147013 (rustdoc: Fix documentation for `--doctest-build-arg`)
 - rust-lang/rust#147015 (Use `LLVMDisposeTargetMachine`)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-09-25 14:03:21 +00:00
DimitriiTrater
d834935b57 Fix atan2 inaccuracy in documentation 2025-09-25 13:35:42 +02:00
Stuart Cook
3053a18ec9 Rollup merge of #147007 - LawnGnome:tosocketaddrs-doc, r=tgross35
Explicitly note `&[SocketAddr]` impl of `ToSocketAddrs`

Although the examples below this list do imply that there's an impl of `ToSocketAddrs` for `&[SocketAddr]`, it's not actually noted in the list of default implementations.
2025-09-25 20:31:58 +10:00
Stuart Cook
8e62f95376 Rollup merge of #146735 - Qelxiros:const_mul_add, r=tgross35,RalfJung
unstably constify float mul_add methods

Tracking issue: rust-lang/rust#146724
r? `@tgross35`
2025-09-25 20:31:54 +10:00
Stuart Cook
0a34928ad8 Rollup merge of #145973 - vexide:vex-std, r=tgross35
Add `std` support for `armv7a-vex-v5`

This PR adds standard library support for the VEX V5 Brain (`armv7a-vex-v5` target). It is more-or-less an updated version of the library-side work done in rust-lang/rust#131530.

This was a joint effort between me, `@lewisfm,` `@max-niederman,` `@Gavin-Niederman` and several other members of the [`vexide` project](https://github.com/vexide/).

## Background

VEXos is a fairly unconventional operating system, with user code running in a restricted enviornment with regards to I/O capabilities and whatnot. As such, several OS-dependent APIs are unsupported or have partial support (such as `std::net`, `std::process`, and most of `std::thread`). A more comprehensive list of what does or doesn't work is outlined in the [updated target documentation](https://github.com/vexide/rust/blob/vex-std/src/doc/rustc/src/platform-support/armv7a-vex-v5.md). Despite these limitations, we believe that `libstd` support on this target still has value to users, especially given the popular use of this hardware for educational purposes. For some previous discussion on this matter, see [this comment](https://github.com/rust-lang/rust/pull/131530#issuecomment-2432856841).

## SDK Linkage

VEXos doesn't really ship with an official `libc` or POSIX-style platform API (and though it does port newlib, these are stubbed on top of the underlying SDK). Instead, VEX provides their own SDK for calling platform APIs. Their official SDK is kept proprietary (with public headers), though open-source implementations exist. Following the precedent of the `armv6k-nintendo-3ds` team's work in rust-lang/rust#95897, we've opted not to directly link `libstd` to any SDK with the expectation that users will provide their own with one of the following options:
-  [`vex-sdk-download`](https://github.com/vexide/vex-sdk/tree/main/packages/vex-sdk-download), which downloads an official proprietary SDK from VEX using a build script.
- [`vex-sdk-jumptable`](https://crates.io/crates/vex-sdk-jumptable), which is a compatible, open-source reimplementation of the SDK using firmware jumps.
- [`vex-sdk-pros`](https://github.com/vexide/vex-sdk/tree/main/packages/vex-sdk-pros), which uses the [PROS kernel](https://github.com/purduesigbots/pros) as a provider for SDK functions.
- Linking their own implementation or stubbing the functions required by libstd.

 The `vex-sdk` crate used in the VEXos PAL provides `libc`-style FFI bindings for any compatible system library, so any of these options *should* work fine. A functional demo project using `vex-sdk-download` can be found [here](https://github.com/vexide/armv7a-vex-v5-demo/tree/main).

## Future Work

This PR implements virtually everything we are currently able to implement given the current capabilities of the platform. The exception to this is file directory enumeration, though the implementation of that is sufficiently [gross enough](c6c5bad11e/packages/vexide-core/src/fs/mod.rs (L987)) to drive us away from supporting this officially.

Additionally, I have a working branch implementing the `panic_unwind` runtime for this target, which is something that would be nice to see in the future, though given the volume of compiler changes i've deemed it out-of-scope for this PR.
2025-09-25 20:31:53 +10:00
bors
7cfd7d328b Auto merge of #147003 - matthiaskrgr:rollup-b5z9uiz, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - rust-lang/rust#146556 (Fix duration_since panic on unix when std is built with integer overflow checks)
 - rust-lang/rust#146679 (Clarify Display for error should not include source)
 - rust-lang/rust#146753 (Improve the pretty print of UnstableFeature clause)
 - rust-lang/rust#146894 (Improve derive suggestion of const param)
 - rust-lang/rust#146950 (core: simplify `CStr::default()`)
 - rust-lang/rust#146958 (Fix infinite recursion in Path::eq with String)
 - rust-lang/rust#146971 (fix ICE in writeback due to bound regions)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-09-25 10:30:50 +00:00