Commit Graph

6769 Commits

Author SHA1 Message Date
bors
f7b5e5471b Auto merge of #131895 - jieyouxu:rollup-jyt3pic, r=jieyouxu
Rollup of 3 pull requests

Successful merges:

 - #126207 (std::unix::stack_overflow::drop_handler addressing todo through libc …)
 - #131864 (Never emit `vptr` for empty/auto traits)
 - #131870 (compiletest: Store test collection context/state in two structs)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-10-18 17:23:35 +00:00
许杰友 Jieyou Xu (Joe)
39af44dae9
Rollup merge of #126207 - devnexen:stack_overflow_libc_upd, r=joboet
std::unix::stack_overflow::drop_handler addressing todo through libc …

…update
2024-10-18 14:52:25 +01:00
bors
b0c2d2e5b0 Auto merge of #131841 - paulmenage:futex-abstraction, r=joboet
Abstract the state type for futexes

In the same way that we expose `SmallAtomic` and `SmallPrimitive` to allow Windows to use a value other than an `AtomicU32` for its futex state, switch the primary futex state type from `AtomicU32` to `futex::Futex`.  The `futex::Futex` type should be usable as an atomic value with underlying primitive type equal to `futex::Primitive`. (`SmallAtomic` is also renamed to `SmallFutex`).

This allows supporting the futex API on systems where the underlying kernel futex implementation requires more user state than simply an `AtomicU32`.

All in-tree futex implementations simply define {`Futex`,`Primitive`} directly as {`AtomicU32`,`u32`}.
2024-10-18 13:43:57 +00:00
许杰友 Jieyou Xu (Joe)
af85d5280a
Rollup merge of #131866 - jieyouxu:thread_local, r=jhpratt
Avoid use imports in `thread_local_inner!`

Previously, the use imports in `thread_local_inner!` can shadow user-provided types or type aliases of the names `Storage`, `EagerStorage`, `LocalStorage` and `LocalKey`. This PR fixes that by dropping the use imports and instead refer to the std-internal types via fully qualified paths. A basic test is added to ensure `thread_local!`s with static decls with type names that match the aforementioned std-internal type names can successfully compile.

Fixes #131863.
2024-10-18 12:00:53 +01:00
Jan Sommer
e20636a786 Add entropy source for RTEMS 2024-10-18 10:26:59 +02:00
Matthias Krüger
4e9901faa9
Rollup merge of #131823 - thesummer:bump-libc-0.2.160, r=workingjubilee
Bump libc to 0.2.161

Bumps libc to the latest release version 0.2.161 which
- includes libc support for the tier 3 RTEMS target
- fixes segfaults on 32-bit FreeBSD targets
- gets musl's `posix_spawn_file_actions_addchdir_np` for some spawn opts
2024-10-18 06:59:06 +02:00
Matthias Krüger
994bdbb23f
Rollup merge of #131654 - betrusted-io:xous-various-fixes, r=thomcc
Various fixes for Xous

This patchset includes several fixes for Xous that have crept in over the last few months:

* The `adjust_process()` syscall was incorrect
* Warnings have started appearing in `alloc` -- adopt the same approach as wasm, until wasm figures out a workaround
* Dead code warnings have appeared in the networking code. Add `allow(dead_code)` as these structs are used as IPC values
* Add support for `args` and `env`, which have been useful for running tests
* Update `unwinding` to `0.2.3` which fixes the recent regression due to changes in `asm!()` code
2024-10-18 06:59:05 +02:00
许杰友 Jieyou Xu (Joe)
7b2320c3df Avoid shadowing user provided types or type aliases in thread_local!
By using qualified imports, i.e. `$crate::...::LocalKey`.
2024-10-18 10:27:41 +08:00
Jan Sommer
a09c54d4d3 Bump libc to 0.2.161 2024-10-17 23:11:45 +02:00
David Carlier
e569c5c92f
std::unix::stack_overflow::drop_handler addressing todo through libc update 2024-10-17 21:34:51 +01:00
Paul Menage
cf7ff15a0d Abstract the state type for futexes
In the same way that we expose SmallAtomic and SmallPrimitive to allow
Windows to use a value other than an AtomicU32 for its futex state, this
patch switches the primary futex state type from AtomicU32 to
futex::Atomic.  The futex::Atomic type should be usable as an atomic
value with underlying primitive type equal to futex::Primitive.

This allows supporting the futex API on systems where the underlying
kernel futex implementation requires more state than simply an
AtomicU32.

All in-tree futex implementations simply define {Atomic,Primitive}
directly as {AtomicU32,u32}.
2024-10-17 12:21:53 -07:00
Callum Ryan
09f75b9862
Add must_use to CommandExt::exec 2024-10-17 05:46:11 -07:00
bors
bed75e7c21 Auto merge of #131767 - cuviper:bump-stage0, r=Mark-Simulacrum
Bump bootstrap compiler to 1.83.0-beta.1

https://forge.rust-lang.org/release/process.html#master-bootstrap-update-tuesday
2024-10-16 14:40:08 +00:00
Urgau
66dc09f3da
Rollup merge of #131746 - slanterns:once_box_order, r=joboet
Relax a memory order in `once_box`

per https://github.com/rust-lang/rust/pull/131094#discussion_r1788536445.

In the successful path we don't need `Acquire` since we don't care if the store in `f()` happened in other threads has become visible to the current thread. We'll use our own results instead and just using `Release` to ensure other threads can see our store to `Box` when they fail the `compare_exchange` will suffice.

Also took https://marabos.nl/atomics/memory-ordering.html#example-lazy-initialization-with-indirection as a reference.

`@rustbot` label: +T-libs

r? `@ibraheemdev`
2024-10-16 12:03:42 +02:00
Josh Stone
acb09bf741 update bootstrap configs 2024-10-15 20:30:23 -07:00
Josh Stone
f204e2c23b replace placeholder version
(cherry picked from commit 567fd9610c)
2024-10-15 20:13:55 -07:00
Slanterns
937d13b8ef
relax a memory order in once_box 2024-10-16 00:42:23 +08:00
Michael Goulet
2f3f001423
Rollup merge of #130568 - eduardosm:const-float-methods, r=RalfJung,tgross35
Make some float methods unstable `const fn`

Some float methods are now `const fn` under the `const_float_methods` feature gate.

I also made some unstable methods `const fn`, keeping their constness under their respective feature gate.

In order to support `min`, `max`, `abs` and `copysign`, the implementation of some intrinsics had to be moved from Miri to rustc_const_eval (cc `@RalfJung).`

Tracking issue: https://github.com/rust-lang/rust/issues/130843

```rust
impl <float> {
    // #[feature(const_float_methods)]
    pub const fn recip(self) -> Self;
    pub const fn to_degrees(self) -> Self;
    pub const fn to_radians(self) -> Self;
    pub const fn max(self, other: Self) -> Self;
    pub const fn min(self, other: Self) -> Self;
    pub const fn clamp(self, min: Self, max: Self) -> Self;
    pub const fn abs(self) -> Self;
    pub const fn signum(self) -> Self;
    pub const fn copysign(self, sign: Self) -> Self;

    // #[feature(float_minimum_maximum)]
    pub const fn maximum(self, other: Self) -> Self;
    pub const fn minimum(self, other: Self) -> Self;

    // Only f16/f128 (f32/f64 already const)
    pub const fn is_sign_positive(self) -> bool;
    pub const fn is_sign_negative(self) -> bool;
    pub const fn next_up(self) -> Self;
    pub const fn next_down(self) -> Self;
}
```

r? libs-api

try-job: dist-s390x-linux
2024-10-15 12:33:35 -04:00
Michael Goulet
34636e6e7c
Rollup merge of #129794 - Ayush1325:uefi-os-expand, r=joboet
uefi: Implement getcwd and chdir

- Using EFI Shell Protocol. These functions do not make much sense unless a shell is present.
- Return the exe dir in case shell protocol is missing.

r? `@joboet`
2024-10-15 12:33:35 -04:00
Eduardo Sánchez Muñoz
c09ed3e767 Make some float methods unstable const fn
Some float methods are now `const fn` under the `const_float_methods` feature gate.

In order to support `min`, `max`, `abs` and `copysign`, the implementation of some intrinsics had to be moved from Miri to rustc_const_eval.
2024-10-15 10:46:33 +02:00
bors
88f311479d Auto merge of #131724 - matthiaskrgr:rollup-ntgkkk8, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #130608 (Implemented `FromStr` for `CString` and `TryFrom<CString>` for `String`)
 - #130635 (Add `&pin (mut|const) T` type position sugar)
 - #130747 (improve error messages for `C-cmse-nonsecure-entry` functions)
 - #131137 (Add 1.82 release notes)
 - #131328 (Remove unnecessary sorts in `rustc_hir_analysis`)
 - #131496 (Stabilise `const_make_ascii`.)
 - #131706 (Fix two const-hacks)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-10-15 05:02:38 +00:00
bors
785c83015c Auto merge of #129458 - EnzymeAD:enzyme-frontend, r=jieyouxu
Autodiff Upstreaming - enzyme frontend

This is an upstream PR for the `autodiff` rustc_builtin_macro that is part of the autodiff feature.

For the full implementation, see: https://github.com/rust-lang/rust/pull/129175

**Content:**
It contains a new `#[autodiff(<args>)]` rustc_builtin_macro, as well as a `#[rustc_autodiff]` builtin attribute.
The autodiff macro is applied on function `f` and will expand to a second function `df` (name given by user).
It will add a dummy body to `df` to make sure it type-checks. The body will later be replaced by enzyme on llvm-ir level,
we therefore don't really care about the content. Most of the changes (700 from 1.2k) are in `compiler/rustc_builtin_macros/src/autodiff.rs`, which expand the macro. Nothing except expansion is implemented for now.
I have a fallback implementation for relevant functions in case that rustc should be build without autodiff support. The default for now will be off, although we want to flip it later (once everything landed) to on for nightly. For the sake of CI, I have flipped the defaults, I'll revert this before merging.

**Dummy function Body:**
The first line is an `inline_asm` nop to make inlining less likely (I have additional checks to prevent this in the middle end of rustc. If `f` gets inlined too early, we can't pass it to enzyme and thus can't differentiate it.
If `df` gets inlined too early, the call site will just compute this dummy code instead of the derivatives, a correctness issue. The following black_box lines make sure that none of the input arguments is getting optimized away before we replace the body.

**Motivation:**
The user facing autodiff macro can verify the user input. Then I write it as args to the rustc_attribute, so from here on I can know that these values should be sensible. A rustc_attribute also turned out to be quite nice to attach this information to the corresponding function and carry it till the backend.
This is also just an experiment, I expect to adjust the user facing autodiff macro based on user feedback, to improve usability.

As a simple example of what this will do, we can see this expansion:
From:
```
#[autodiff(df, Reverse, Duplicated, Const, Active)]
pub fn f1(x: &[f64], y: f64) -> f64 {
    unimplemented!()
}
```
to
```
#[rustc_autodiff]
#[inline(never)]
pub fn f1(x: &[f64], y: f64) -> f64 {
    ::core::panicking::panic("not implemented")
}
#[rustc_autodiff(Reverse, Duplicated, Const, Active,)]
#[inline(never)]
pub fn df(x: &[f64], dx: &mut [f64], y: f64, dret: f64) -> f64 {
    unsafe { asm!("NOP"); };
    ::core::hint::black_box(f1(x, y));
    ::core::hint::black_box((dx, dret));
    ::core::hint::black_box(f1(x, y))
}
```
I will add a few more tests once I figured out why rustc rebuilds every time I touch a test.

Tracking:

- https://github.com/rust-lang/rust/issues/124509

try-job: dist-x86_64-msvc
2024-10-15 01:30:01 +00:00
George Bateman
4e438f7d6b
Fix two const-hacks 2024-10-14 20:50:40 +01:00
Ayush Singh
f8ac1c44db
uefi: Implement getcwd and chdir
- Using EFI Shell Protocol. These functions do not make much sense
  unless a shell is present.
- Return the exe dir in case shell protocol is missing.

Signed-off-by: Ayush Singh <ayush@beagleboard.org>
2024-10-14 11:05:22 +05:30
Matthias Krüger
5d63a3db9c
Rollup merge of #131616 - RalfJung:const_ip, r=tgross35
merge const_ipv4 / const_ipv6 feature gate into 'ip' feature gate

https://github.com/rust-lang/rust/issues/76205 has been closed a while ago, but there are still some functions that reference it. Those functions are all unstable *and* const-unstable. There's no good reason to use a separate feature gate for their const-stability, so this PR moves their const-stability under the same gate as their regular stability, and therefore removes the remaining references to https://github.com/rust-lang/rust/issues/76205.
2024-10-14 06:04:29 +02:00
Matthias Krüger
55f8b9e7d8
Rollup merge of #128967 - devnexen:get_path_fbsd_upd, r=joboet
std::fs::get_path freebsd update.

what matters is we re doing the right things as doing sizeof, rather than passing KINFO_FILE_SIZE (only defined on intel architectures), the kernel
 making sure it matches the expectation in its side.
2024-10-14 06:04:26 +02:00
Matthias Krüger
b9651d00d4
Rollup merge of #131646 - RalfJung:unix-miri-fallbacks, r=joboet
sys/unix: add comments for some Miri fallbacks
2024-10-13 18:27:21 +02:00
Sean Cross
99de67af35 library: xous: mark alloc as FIXME(static_mut_refs)
The allocator on Xous is now throwing warnings because the allocator
needs to be mutable, and allocators hand out mutable pointers, which
the `static_mut_refs` lint now catches.

Give the same treatment to Xous as wasm, at least until a solution is
devised for fixing the warning on wasm.

Signed-off-by: Sean Cross <sean@xobs.io>
2024-10-13 22:24:51 +08:00
Sean Cross
4c23cdf741 xous: ffi: correct syscall number for adjust_process
The AdjustProcessLimit syscall was using the correct call number.

Signed-off-by: Sean Cross <sean@xobs.io>
2024-10-13 22:24:51 +08:00
Sean Cross
3d00c5cd5e net: fix dead code warning
Signed-off-by: Sean Cross <sean@xobs.io>
2024-10-13 22:24:51 +08:00
Sean Cross
7304cf4765 std: xous: add support for args and env
Process arguments and environment variables are both passed by way of
Application Parameters. These are a TLV format that gets passed in as
the second process argument.

This patch combines both as they are very similar in their decode.

Signed-off-by: Sean Cross <sean@osdyne.com>
2024-10-13 22:24:51 +08:00
Ralf Jung
a87f5ca917 sys/unix: add comments for some Miri fallbacks 2024-10-13 12:35:06 +02:00
Ralf Jung
8d0a0b000c remove outdated comment now that Miri is on CI 2024-10-13 12:30:23 +02:00
Ralf Jung
2ae3b1b09a sys/windows: remove miri hack that is only needed for win7 2024-10-13 12:30:23 +02:00
Ralf Jung
1ebfd97051 merge const_ipv4 / const_ipv6 feature gate into 'ip' feature gate 2024-10-13 09:55:34 +02:00
Matthias Krüger
c0f16828a1
Rollup merge of #131503 - theemathas:stdin_read_line_docs, r=Mark-Simulacrum
More clearly document Stdin::read_line

These are common pitfalls for beginners, so I think it's worth making the subtleties more visible.
2024-10-12 23:00:57 +02:00
Trevor Gross
ca3c822068
Rollup merge of #131233 - joboet:stdout-before-main, r=tgross35
std: fix stdout-before-main

Fixes #130210.

Since #124881, `ReentrantLock` uses `ThreadId` to identify threads. This has the unfortunate consequence of breaking uses of `Stdout` before main: Locking the `ReentrantLock` that synchronizes the output will initialize the thread ID before the handle for the main thread is set in `rt::init`. But since that would overwrite the current thread ID, `thread::set_current` triggers an abort.

This PR fixes the problem by using the already initialized thread ID for constructing the main thread handle and allowing `set_current` calls that do not change the thread's ID.
2024-10-12 11:08:43 -05:00
joboet
9f91c5099f
std: fix stdout-before-main
Fixes #130210.

Since #124881, `ReentrantLock` uses `ThreadId` to identify threads. This has the unfortunate consequence of breaking uses of `Stdout` before main: Locking the `ReentrantLock` that synchronizes the output will initialize the thread ID before the handle for the main thread is set in `rt::init`. But since that would overwrite the current thread ID, `thread::set_current` triggers an abort.

This PR fixes the problem by using the already initialized thread ID for constructing the main thread handle and allowing `set_current` calls that do not change the thread's ID.
2024-10-12 13:01:36 +02:00
Trevor Gross
02cf62c596
Rollup merge of #130962 - nyurik:opts-libs, r=cuviper
Migrate lib's `&Option<T>` into `Option<&T>`

Trying out my new lint https://github.com/rust-lang/rust-clippy/pull/13336 - according to the [video](https://www.youtube.com/watch?v=6c7pZYP_iIE), this could lead to some performance and memory optimizations.

Basic thoughts expressed in the video that seem to make sense:
* `&Option<T>` in an API breaks encapsulation:
  * caller must own T and move it into an Option to call with it
  * if returned, the owner must store it as Option<T> internally in order to return it
* Performance is subject to compiler optimization, but at the basics, `&Option<T>` points to memory that has `presence` flag + value, whereas `Option<&T>` by specification is always optimized to a single pointer.
2024-10-11 23:57:44 -04:00
Manuel Drehwald
624c071b99 Single commit implementing the enzyme/autodiff frontend
Co-authored-by: Lorenz Schmidt <bytesnake@mailbox.org>
2024-10-11 19:13:31 +02:00
Tim (Theemathas) Chirananthavat
203573701a More clearly document Stdin::read_line
These are common pitfalls for beginners, so I think it's worth
making the subtleties more visible.
2024-10-10 23:12:03 +07:00
Kajetan Puchalski
335f67b652 rustc_target: Add sme-b16b16 as an explicit aarch64 target feature
LLVM 20 split out what used to be called b16b16 and correspond to aarch64
FEAT_SVE_B16B16 into sve-b16b16 and sme-b16b16.
Add sme-b16b16 as an explicit feature and update the codegen accordingly.
2024-10-10 10:24:57 +00:00
Matthias Krüger
7a76489454
Rollup merge of #131462 - cuviper:open_buffered-error, r=RalfJung
Mention allocation errors for `open_buffered`

This documents that `File::open_buffered` may return an error on allocation failure.
2024-10-09 23:03:50 +02:00
Matthias Krüger
866869bbbd
Rollup merge of #131449 - nickrum:wasip2-net-decouple-fd, r=alexcrichton
Decouple WASIp2 sockets from WasiFd

This is a follow up to #129638, decoupling WASIp2's socket implementation from WASIp1's `WasiFd` as discussed with `@alexcrichton.`

Quite a few trait implementations in `std::os::fd` rely on the fact that there is an additional layer of abstraction between `Socket` and `OwnedFd`. I thus had to add a thin `WasiSocket` wrapper struct that just "forwards" to `OwnedFd`. Alternatively, I could have added a lot of conditional compilation to `std::os::fd`, which feels even worse.

Since `WasiFd::sock_accept` is no longer accessible from `TcpListener` and since WASIp2 has proper support for accepting sockets through `Socket::accept`, the `std::os::wasi::net` module has been removed from WASIp2, which only contains a single `TcpListenerExt` trait with a `sock_accept` method as well as an implementation for `TcpListener`. Let me know if this is an acceptable solution.
2024-10-09 23:03:50 +02:00
Matthias Krüger
627d0b4067
Rollup merge of #130827 - fmease:library-mv-obj-save-dyn-compat, r=ibraheemdev
Library: Rename "object safe" to "dyn compatible"

Completed T-lang FCP: https://github.com/rust-lang/lang-team/issues/286#issuecomment-2338905118.
Tracking issue: https://github.com/rust-lang/rust/issues/130852

Regarding https://github.com/rust-lang/rust/labels/relnotes, I guess I will manually open a https://github.com/rust-lang/rust/labels/relnotes-tracking-issue since this change affects everything (compiler, library, tools, docs, books, everyday language).

r? ghost
2024-10-09 23:03:47 +02:00
Josh Stone
7b52e6bc47 Mention allocation errors for open_buffered 2024-10-09 12:43:23 -07:00
León Orell Valerian Liehr
e08dc0491a
Library: Rename "object safe" to "dyn compatible" 2024-10-09 18:48:29 +02:00
Nicola Krumschmidt
01e248ff97
Decouple WASIp2 sockets from WasiFd 2024-10-09 14:39:28 +02:00
Yuri Astrakhan
a278f15724 Update library/std/src/sys/pal/unix/process/process_vxworks.rs
Co-authored-by: Josh Stone <cuviper@gmail.com>
2024-10-08 23:26:30 -04:00
Yuri Astrakhan
442d766cc1 fix ref in process_vxworks.rs 2024-10-08 23:26:30 -04:00