Commit Graph

24632 Commits

Author SHA1 Message Date
Trevor Gross
2fcea9fb68 Rollup merge of #143859 - orlp:thread-into-raw-align, r=jhpratt
Guarantee 8 bytes of alignment in Thread::into_raw

When using `AtomicPtr` for synchronization it's incredibly useful when you've got a couple bits you can stuff metadata in. By guaranteeing that `Thread`'s `Inner` struct is aligned to 8 bytes everyone can use the bottom 3 bits to signal other things, such as a critical section, etc.

This guarantee is thus very useful and costs us nothing.
2025-07-26 02:19:29 -05:00
Trevor Gross
3b99668f83 Rollup merge of #143272 - tgross35:bump-fortanix, r=jhpratt,jethrogb
Upgrade the `fortanix-sgx-abi` dependency

0.6.1 removes the `compiler-builtins` dependency, part of RUST-142265. The breaking change from 0.5 to 0.6 is for an update to the `insecure_time` API [1].

I validated that `./x c library --target x86_64-fortanix-unknown-sgx` completes successfully with this change.

Link: a34e9767f3 [1]
2025-07-26 02:19:27 -05:00
Matthias Krüger
a2681f943c Rollup merge of #144314 - kornelski:pivot-safely, r=jhpratt
Hint that choose_pivot returns index in bounds

Instead of using `unsafe` in multiple places, one `hint::assert_unchecked` allows use of safe code instead.

Part of #rust-lang/rust#144326
2025-07-25 11:16:37 +02:00
Matthias Krüger
e3b07352a6 Rollup merge of #143970 - SunkenPotato:update_mem_copy_docs, r=scottmcm
Update core::mem::copy documentation

Update the documentation of `core::mem::copy` to include a `const` on the definition of the function.
2025-07-25 11:16:34 +02:00
Matthias Krüger
dd159ee24e Rollup merge of #143424 - hkBst:auto-deref, r=jhpratt
clippy fix: rely on autoderef

Changes instances of `&**self` to `self`.
2025-07-25 11:16:34 +02:00
León Orell Valerian Liehr
488fc49e05 Rollup merge of #144278 - Qelxiros:rev-into-inner, r=tgross35
add Rev::into_inner

Tracking issue: rust-lang/rust#144277
2025-07-24 15:08:25 +02:00
León Orell Valerian Liehr
0897a9f069 Rollup merge of #144247 - RalfJung:ldexp, r=tgross35
coretests/num: use ldexp instead of hard-coding a power of 2

r? `````@tgross35`````
2025-07-24 15:08:24 +02:00
León Orell Valerian Liehr
319d54f3ec Rollup merge of #143838 - Ayush1325:uefi-tcp4-config-data, r=tgross35
std: net: uefi: Add support to query connection data

- Use EFI_TCP4_GET_MODE_DATA to be able to query for ttl, nodelay, peer_addr and socket_addr.
- peer_addr is needed for implementation of `accept`.
- cc `````@nicholasbishop`````
- Also a heads up. The UEFI spec seems to be wrong or something for [EFI_TCP4_CONFIG_DATA](https://uefi.org/specs/UEFI/2.11/28_Network_Protocols_TCP_IP_and_Configuration.html#efi-tcp4-protocol-getmodedata). `ControlOption` should be a pointer as seen in [edk2](a1b509c1a4/MdePkg/Include/Protocol/Tcp4.h (L97)).
2025-07-24 15:08:20 +02:00
Jeremy Smart
6f1b56c499 add Rev::into_inner 2025-07-23 22:03:03 -04:00
Ralf Jung
37480bc9e6 coretests/num: use ldexp instead of hard-coding a power of 2 2025-07-23 16:33:58 +02:00
Matthias Krüger
546929f276 Rollup merge of #144234 - roblabla:fix-win7-tls-dtors, r=ChrisDenton
Fix broken TLS destructors on 32-bit win7

Fixes rust-lang/rust#141300

On the 32-bit win7 target, we use OS TLS instead of native TLS, due to issues with how the OS handles alignment. Unfortunately, this caused issues due to the TLS destructors not running, causing memory leaks among other problems.

On Windows, to support OS TLS, the TlsAlloc family of function is used by Rust. This function does not support TLS destructors at all. However, rust has some code to emulate those destructors, by leveraging the TLS support functionality found in the MSVC CRT (specifically, in tlssup.c of the CRT).

To use this functionality, the user must do two things:

1. They must put the address to their callback in a section between `.CRT$XLB` and `.CRT$XLY`.
2. They must add a reference to `_tls_used` (or `__tls_used` on x86) to make sure the TLS support code in tlssup.c isn't garbage collected by the linker.

Prior to this commit, this second bit wasn't being done properly by the Rust TLS support code. Instead of adding a reference to _tls_used, it instead had a reference to its own callback to prevent it from getting GC'd by the linker. While this is _also_ necessary, not having a reference on _tls_used made the entire support non-functional.

This commit reworks the code to:

1. Add an unconditional `#[used]` attribute on the CALLBACK, which should be enough to prevent it from getting GC'd by the linker.
2. Add a reference to `_tls_used`, which should pull the TLS support code into the Rust programs and not let it be GC'd by the linker.
2025-07-23 15:59:29 +02:00
Kornel
01fdafc9aa Hint that choose_pivot returns index in bounds 2025-07-23 12:01:44 +01:00
bors
5a30e4307f Auto merge of #143412 - Kobzol:std-detect-in-stdlib, r=Amanieu
Move `std_detect` into stdlib

This PR moves the `std_detect` crate from `stdarch` to be a part of rust-lang/rust instead.

The first commit actually moves the whole directory from the stdarch Josh subtree, so that git blame history is kept intact. Then I had to make a few changes to appease `tidy`.

The most complex thing here is porting the tests. We can't have `std_detect` both in r-l/r and stdarch, because they could get desynchronized, so we have to perform the move more or less "atomically", which means that we also have to port all the existing `std_detect` tests from the `stdarch` repository.

The stdarch repo runs the following `std_detect` tests:

### Build
The `build-std-detect.sh` script (e2b6512aed/ci/build-std-detect.sh) builds `std_detect` using the nightly compiler for several targets. This will be subsumed by normal `x build library` on our Tier 1/2 targets. However, the stdarch repository also tests the following targets:
- aarch64-unknown-freebsd
- armv6-unknown-freebsd
- powerpc-unknown-freebsd
- powerpc64-unknown-freebsd
- aarch64-unknown-openbsd

Which we don't build/test on our CI currently. I think we have mostly two options here:
1) Ignore these targets
2) Create a special CI job that will build stage 1 rustc and then cross-compile std (or just the `std_detect` crate?) for these targets.

### Documentation
The `dox.sh` script (3fec5adcd5/ci/dox.sh) builds and documents `std_detect` for several targets. All of them are Tier 2/we have `dist-` jobs for them, so I think that we can just skip this and let our normal CI subsume it?

### Tests
The `run.sh` script (1b201cec2c/ci/run.sh) runs `cargo test` on `std_detect` with a bunch of variations of feature flags. This will be subsumed by `x test library` in our CI. The only problem is that `stdarch` runs these tests for a ludicrous number of targets:
```
        - tuple: i686-unknown-linux-gnu
        - tuple: x86_64-unknown-linux-gnu
        - tuple: arm-unknown-linux-gnueabihf
        - tuple: armv7-unknown-linux-gnueabihf
        - tuple: aarch64-unknown-linux-gnu
        - tuple: aarch64_be-unknown-linux-gnu
        - tuple: riscv32gc-unknown-linux-gnu
        - tuple: riscv64gc-unknown-linux-gnu
        - tuple: powerpc-unknown-linux-gnu
        - tuple: powerpc64-unknown-linux-gnu
        - tuple: powerpc64le-unknown-linux-gnu
        - tuple: s390x-unknown-linux-gnu
        - tuple: i586-unknown-linux-gnu
        - tuple: nvptx64-nvidia-cuda
        - tuple: thumbv6m-none-eabi
        - tuple: thumbv7m-none-eabi
        - tuple: thumbv7em-none-eabi
        - tuple: thumbv7em-none-eabihf
        - tuple: loongarch64-unknown-linux-gnu
        - tuple: wasm32-wasip1
        - tuple: x86_64-apple-darwin
        - tuple: x86_64-apple-ios-macabi
        - tuple: aarch64-apple-darwin
        - tuple: aarch64-apple-ios-macabi
        - tuple: x86_64-pc-windows-msvc
        - tuple: i686-pc-windows-msvc
        - tuple: aarch64-pc-windows-msvc
        - tuple: x86_64-pc-windows-gnu
        - tuple: aarch64-unknown-linux-gnu
        - tuple: aarch64_be-unknown-linux-gnu
        - tuple: armv7-unknown-linux-gnueabihf
        - tuple: loongarch64-unknown-linux-gnu
        - tuple: powerpc-unknown-linux-gnu
        - tuple: powerpc64-unknown-linux-gnu
        - tuple: powerpc64le-unknown-linux-gnu
        - tuple: riscv32gc-unknown-linux-gnu
        - tuple: riscv64gc-unknown-linux-gnu
        - tuple: s390x-unknown-linux-gnu
        - tuple: x86_64-unknown-linux-gnu
        - tuple: aarch64-apple-darwin
        - tuple: aarch64-apple-ios-macabi
```
We definitely do not run *tests* for all of these targets on our CI.

# Outcome
We have decided to just subsume std_detect tests by our normal test suite for now, and not create a separate CI job. Therefore, this PR performs the following changes in target testing for `std_detect`:

The following T3 targets would go from "build" to "nothing":
```
aarch64-unknown-freebsd (T3)
armv6-unknown-freebsd (T3)
powerpc-unknown-freebsd (T3)
powerpc64-unknown-freebsd (T3)
aarch64-unknown-openbsd (T3)
```

The following T3 targets would go from "test" to "nothing":
```
aarch64_be-unknown-linux-gnu (T3)
riscv32gc-unknown-liux-gnu (T3)
```

The following T2 targets would go from "test" to "build":
```
arm-unknown-linux-gnueabihf (T2)
armv7-unknown-linux-gnueabihf (T2)
riscv64gc-unknown-linux-gnu (T2)
powerpc-unknown-linux-gnu (T2)
powerpc64-unknown-linux-gnu (T2)
powerpc64le-unknown-linux-gnu (T2)
s390x-unknown-linux-gnu (T2)
i586-unknown-linux-gnu (T2)
loongarch64-unknown-linux-gnu (T2)
wasm32-wasip1 (T2)
x86_64-apple-ios-macabi (T2)
aarch64-apple-ios-macabi (T2)
aarch64-pc-windows-msvc (T2)
armv7-unknown-linux-gnueabihf (T2)
loongarch64-unknown-linux-gnu (T2)
powerpc-unknown-linux-gnu (T2)
```

I have confirmed in https://github.com/rust-lang/stdarch/pull/1873 that the current version of this PR would pass stdarch's CI testsuite.

r? `@ghost`

try-job: armhf-gnu
try-job: arm-android
2025-07-23 09:52:16 +00:00
Ayush Singh
eb9c65476c std: net: uefi: Add support to query connection data
- Use EFI_TCP4_GET_MODE_DATA to be able to query for ttl, nodelay,
  peer_addr and socket_addr.
- peer_addr is needed for implementation of `accept`.

Signed-off-by: Ayush Singh <ayush@beagleboard.org>
2025-07-23 11:23:41 +05:30
bors
a7a1618e6c Auto merge of #144249 - GuillaumeGomez:asm-tests, r=jieyouxu
Rename `tests/{assembly,codegen}` into `tests/{assembly,codegen}-llvm` and ignore these testsuites if configured backend doesn't match

Follow-up of https://github.com/rust-lang/rust/pull/144125.

This PR changes `compiletest` so that `asm` tests are only run if they match the current codegen backend. To better reflect it, I renamed the `tests/ui/asm` folder into `tests/ui/asm-llvm`. Like that, we can add new asm tests for other backends if we want without needing to add extra code to `compiletest`.

Next step will be to use the new code annotations added in rust-lang/rust#144125 to ignore ui tests failing in cg_gcc until it's fixed on our side.

cc `@antoyo` `@oli-obk`
r? `@Kobzol`
2025-07-22 18:39:58 +00:00
Jakub Beránek
9a1179c4de Embed auxv files directly into the test binary 2025-07-22 20:22:16 +02:00
Jakub Beránek
81d90d8257 Improve error messages of auxv loading 2025-07-22 20:22:16 +02:00
Jakub Beránek
5e52677a82 Remove licenses from std-detect
They are subsumed by the main repo licenses.
2025-07-22 20:22:16 +02:00
Jakub Beránek
847f8db5ad Remove std_detect from stdarch's CI 2025-07-22 20:22:16 +02:00
Jakub Beránek
608297247a Remove std_detect from stdarch examples 2025-07-22 20:22:16 +02:00
Jakub Beránek
ffa97a647e Fix warning 2025-07-22 20:22:16 +02:00
Jakub Beránek
e07a1bbb79 Move tests around to appease tidy 2025-07-22 20:22:16 +02:00
Jakub Beránek
8dc2abb5c3 Update stdarch README 2025-07-22 20:17:49 +02:00
Jakub Beránek
ee6f2c5276 Reformat std_detect 2025-07-22 20:17:46 +02:00
Jakub Beránek
b23ab7888a Make std_detect a direct dependency of std 2025-07-22 20:17:23 +02:00
Jakub Beránek
5b2de8ab27 Move std_detect from library/stdarch to library 2025-07-22 20:17:06 +02:00
bors
2e53675668 Auto merge of #144222 - Kobzol:stdarch-push, r=folkertdev
stdarch subtree update

Subtree update of `stdarch` to 5531955678.

Created using https://github.com/rust-lang/josh-sync.

I saw that there were non-trivial changes made to `std_detect` in `stdarch` recently. So I want to get them merged here before we move forward with https://github.com/rust-lang/rust/pull/143412.

r? `@folkertdev`
2025-07-22 15:25:31 +00:00
Guillaume Gomez
a27f3e3fd1 Rename tests/codegen into tests/codegen-llvm 2025-07-22 14:28:48 +02:00
bors
c0b282f0cc Auto merge of #144205 - hkBst:flt2dec, r=workingjubilee
flt2dec: replace for loop by iter_mut

Perf is explored in https://github.com/rust-lang/rust/issues/144118, which initially showed small losses, but then also showed significant gains. Both are real, but given the smallness of the losses, this seems a good change.
2025-07-22 08:28:29 +00:00
许杰友 Jieyou Xu (Joe)
551cef9fc9 Rollup merge of #144212 - bjorn3:remove_unique_lang_item, r=oli-obk
Remove the ptr_unique lang item

Miri no longer uses it since https://github.com/rust-lang/miri/pull/4307.
2025-07-22 00:54:30 +08:00
许杰友 Jieyou Xu (Joe)
1f8b531b54 Rollup merge of #143768 - Randl:const-try, r=oli-obk
Constify Try, From, TryFrom and relevant traits
2025-07-22 00:54:26 +08:00
bors
3f9f20f71d Auto merge of #144154 - tgross35:update-builtins, r=tgross35
compiler-builtins subtree update

Subtree update of `compiler-builtins` to 2cdde03950.

Created using https://github.com/rust-lang/josh-sync.

Fixes: https://github.com/rust-lang/rust/issues/144076

r? `@ghost`
2025-07-21 12:47:33 +00:00
roblabla
58537fb869 Fix broken TLS destructors on 32-bit win7
On the 32-bit win7 target, we use OS TLS instead of native TLS, due to
issues with how the OS handles alignment. Unfortunately, this caused
issues due to the TLS destructors not running, causing memory leaks
among other problems.

On Windows, to support OS TLS, the TlsAlloc family of function is used
by Rust. This function does not support TLS destructors at all. However,
rust has some code to emulate those destructors, by leveraging the TLS
support functionality found in the MSVC CRT (specifically, in tlssup.c
of the CRT). Specifically, the CRT provides the ability to register
callbacks that are called (among other things) on thread destruction. By
registering our own callback, we can run through a list of registered
destructors functions to execute.

To use this functionality, the user must do two things:

1. They must put the address to their callback in a section between
   `.CRT$XLB` and `.CRT$XLY`.
2. They must add a reference to `_tls_used` (or `__tls_used` on x86) to
   make sure the TLS support code in tlssup.c isn't garbage collected by
   the linker.

Prior to this commit, this second bit wasn't being done properly by the
Rust TLS support code. Instead of adding a reference to _tls_used, it
instead had a reference to its own callback to prevent it from getting
GC'd by the linker. While this is _also_ necessary, not having a
reference on _tls_used made the entire support non-functional.

This commit reworks the code to:

1. Add an unconditional `#[used]` attribute on the CALLBACK, which
   should be enough to prevent it from getting GC'd by the linker.
2. Add a reference to `_tls_used`, which should pull the TLS support
   code into the Rust programs and not let it be GC'd by the linker.
2025-07-21 13:11:47 +02:00
Evgenii Zheltonozhskii
3c76e3d002 Constify Try, From, TryFrom 2025-07-21 12:49:45 +03:00
Ralf Jung
d2be1c8d00 Option::as_slice: fix comment 2025-07-20 22:39:10 +02:00
Marijn Schouten
f147716e7d flt2dec: use fill instead of loop 2025-07-20 18:45:11 +00:00
Guillaume Gomez
5ba1251b55 Rollup merge of #143423 - hkBst:clippy-fix-1, r=workingjubilee
address clippy formatting nits

- int_log10.rs: change top level doc comments to outer
- collect.rs: remove empty line after doc comment
- clippy fix: markdown indentation for indented items after line break: a markdown list item continued over multiples lines, but those following lines which are part of the same item are not indented
- clippy fix: bound in one place: when there is a bound in angle brackets and another bound on the same variable in a where clause
2025-07-20 15:34:04 +02:00
Guillaume Gomez
0162cc50e3 Rollup merge of #143282 - nxsaken:strict_sub_signed, r=jhpratt
Add `uX::strict_sub_signed`

rust-lang/rust#116090 missed `strict_sub_signed`, adding it here.
Part of rust-lang/rust#118260.

r? ``@m-ou-se``
2025-07-20 15:34:04 +02:00
bjorn3
fdf8bdb7a2 Remove the ptr_unique lang item
Miri no longer uses it.
2025-07-20 09:50:58 +00:00
Matthias Krüger
72588c8eb0 Rollup merge of #144169 - RalfJung:type-id-fix, r=oli-obk
interpret: fix TypeId pointers being considered data pointers

Fixes https://github.com/rust-lang/miri/issues/4477
r? ````@oli-obk````
2025-07-20 08:56:10 +02:00
Matthias Krüger
5e5ac49bbb Rollup merge of #144111 - clarfonthey:maybe-uninit-deprecated, r=jhpratt
Remove deprecated `MaybeUninit` slice methods

These were left in to make migration a bit easier, although they should be removed now since they were never stable.
2025-07-20 08:56:08 +02:00
Matthias Krüger
a8c2e540ec Rollup merge of #143604 - nxsaken:const_float_round_methods, r=RalfJung
Stabilize `const_float_round_methods`

Closes rust-lang/rust#141555, waiting for FCP.
2025-07-20 08:56:06 +02:00
Matthias Krüger
6d7d366fd3 Rollup merge of #141260 - LuigiPiucco:volatile-null, r=RalfJung
Allow volatile access to non-Rust memory, including address 0

This PR relaxes the `ub_check` in the `read_volatile`/`write_volatile` pointer operations to allow passing null. This is needed to support processors which hard-code peripheral registers on address 0, like the AVR chip ATtiny1626. LLVM understands this as valid and handles it correctly, as tested in my [PR to add a note about it](6387c82255 (diff-81bbb96298c32fa901beb82ab3b97add27a410c01d577c1f8c01000ed2055826)) (rustc generates the same LLVM IR as expected there when this PR is applied, and consequently the same AVR assembly).

Follow-up and implementation of the discussions in:
- https://internals.rust-lang.org/t/pre-rfc-conditionally-supported-volatile-access-to-address-0/12881/7
- https://github.com/Rahix/avr-device/pull/185;
- [#t-lang > Adding the possibility of volatile access to address 0](https://rust-lang.zulipchat.com/#narrow/channel/213817-t-lang/topic/Adding.20the.20possibility.20of.20volatile.20access.20to.20address.200/with/513303502)
- https://discourse.llvm.org/t/rfc-volatile-access-to-non-dereferenceable-memory-may-be-well-defined/86303

r? ````@RalfJung````

Also fixes https://github.com/rust-lang/unsafe-code-guidelines/issues/29 (about as good as it'll get, null will likely never be a "normal" address in Rust)
2025-07-20 08:56:05 +02:00
ltdk
56288857d8 Remove deprecated MaybeUninit slice methods 2025-07-19 22:33:15 -04:00
Nurzhan Sakén
caf4f111bc Add #[rustc_intrinsic_const_stable_indirect] to float rounding
intrinsics
2025-07-20 00:09:32 +04:00
Nurzhan Sakén
ca01e7de6f Stabilize const_float_round_methods 2025-07-20 00:08:58 +04:00
Rémy Rakic
4ef92bec5a fix load-bearing typo 2025-07-19 15:17:04 +00:00
bors
12865ffd0d Auto merge of #144166 - matthiaskrgr:rollup-wccepuo, r=matthiaskrgr
Rollup of 10 pull requests

Successful merges:

 - rust-lang/rust#141076 (fix Zip unsoundness (again))
 - rust-lang/rust#142444 (adding run-make test to autodiff)
 - rust-lang/rust#143704 (Be a bit more careful around exotic cycles in in the inliner)
 - rust-lang/rust#144073 (Don't test panic=unwind in panic_main.rs on Fuchsia)
 - rust-lang/rust#144083 (miri sleep tests: increase slack)
 - rust-lang/rust#144092 (bootstrap: Detect musl hosts)
 - rust-lang/rust#144098 (Do not lint private-in-public for RPITIT)
 - rust-lang/rust#144103 (Rename `emit_unless` to `emit_unless_delay`)
 - rust-lang/rust#144108 (Ignore tests/run-make/link-eh-frame-terminator/rmake.rs when cross-compiling)
 - rust-lang/rust#144115 (fix outdated comment)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-07-19 11:10:04 +00:00
Ralf Jung
7672e4ed85 interpret: fix TypeId pointers being considered data pointers 2025-07-19 10:29:13 +02:00
Matthias Krüger
fff53f1dbb Rollup merge of #141076 - the8472:fix-zip-panic-safety2, r=workingjubilee
fix Zip unsoundness (again)

Some history: The Zip TrustedRandomAccess specialization has tried to emulate the side-effects of the naive implementation for a long time, including backwards iteration. #82292 tried to fix unsoundness (#82291) in that side-effect-preservation code, but this introduced some panic-safety unsoundness (#86443), but the fix #86452 didn't fix it for nested Zip iterators (#137255).

Rather than piling yet another fix ontop of this heap of fixes this PR reduces the number of cases in which side-effects will be preserved; the necessary API guarantee change was approved in #83791 but we haven't made use of that so far.

fixes #137255
2025-07-19 08:55:33 +02:00