Commit Graph

264592 Commits

Author SHA1 Message Date
Jubilee Young 169b2f0e6d library: Stabilize new_uninit for Box, Rc, and Arc
A partial stabilization that only affects:
- AllocType<T>::new_uninit
- AllocType<T>::assume_init
- AllocType<[T]>::new_uninit_slice
- AllocType<[T]>::assume_init
where "AllocType" is Box, Rc, or Arc
2024-08-27 10:17:05 -07:00
Matthias Krüger ac0cc709c3
Rollup merge of #129652 - RalfJung:ptr-to-ref, r=traviscross
fix Pointer to reference conversion docs

The aliasing rules documented in https://github.com/rust-lang/rust/pull/128157 are wrong, this fixes them.
2024-08-27 18:59:30 +02:00
Matthias Krüger 5e226dd18b
Rollup merge of #129649 - RalfJung:unadjusted-abi-mismatch, r=petrochenkov
ABI compat check: detect unadjusted ABI mismatches
2024-08-27 18:59:30 +02:00
Matthias Krüger 489eb230dd
Rollup merge of #129648 - nnethercote:unreachable_pub-2, r=Urgau
More `unreachable_pub`

Add `unreachable_pub` checking to some more compiler crates. A follow-up to #126013.

r? ``@Urgau``
2024-08-27 18:59:29 +02:00
Matthias Krüger 02491259c2
Rollup merge of #129645 - beetrees:fix-float-docs, r=tgross35
Fix typos in floating-point primitive type docs

Fixes a few typos. Also reflows the text of a couple of paragraphs in the source code to the standard line width to make the source easier to read (will have no effect on the rendered documentation).
2024-08-27 18:59:29 +02:00
Matthias Krüger 3299e30abc
Rollup merge of #129635 - compiler-errors:unsafe-blocks, r=spastorino
Use unsafe extern blocks throughout the compiler

Making this change in preparation for edition 2024.

r? spastorino
2024-08-27 18:59:28 +02:00
Matthias Krüger df9c87cc2a
Rollup merge of #129634 - compiler-errors:tidy-2024, r=albertlarsan68
Fix tidy to allow `edition = "2024"` in `Cargo.toml`

Needed to upgrade to edition 2024 eventually.
2024-08-27 18:59:28 +02:00
Matthias Krüger 6ab180577f
Rollup merge of #129581 - RalfJung:exit, r=joshtriplett
exit: explain our expectations for the exit handlers registered in a Rust program

This documents the position of ``@Amanieu`` and others in https://github.com/rust-lang/rust/issues/126600: a library with an atexit handler that destroys state that other threads could still be working on is buggy. We do not consider it acceptable for a library to say "you must call the following cleanup function before exiting from `main` or calling `exit`". I don't know if this is established ``@rust-lang/libs-api``  consensus so I presume this will have to go through FCP.

Given that Rust supports concurrency, I don't think there is any way to write a sound Rust wrapper around a library that has such a required cleanup function: even if we made `exit` unsafe, and the Rust wrapper used the scope-with-callback approach to ensure it can run cleanup code before returning from the wrapper (like `thread::scope`), one could still call this wrapper in a second thread and then return from `main` while the wrapper runs. Making this sound would require `std` to provide a way to "block" returning from `main`, so that while the wrapper runs returning from `main` waits until the wrapper is done... that just doesn't seem feasible.

The `exit` docs do not seem like the best place to document this, but I also couldn't think of a better one.
2024-08-27 18:59:27 +02:00
Matthias Krüger 849c240c1e
Rollup merge of #129507 - RalfJung:per-fn-const_precise_live_drops, r=wesleywiser
make it possible to enable const_precise_live_drops per-function

This makes const_precise_live_drops work with rustc_allow_const_fn_unstable so that we can stabilize individual functions that rely on const_precise_live_drops.

The goal is that we can use that to stabilize some of https://github.com/rust-lang/rust/issues/67441 without having to stabilize const_precise_live_drops.
2024-08-27 18:59:27 +02:00
jdonszelmann a507ec644c
add uitest for naked functions and the repr attr on functions 2024-08-27 17:17:55 +02:00
jdonszelmann c3000ad3ba
add repr to the allowlist for naked functions, and test that it works 2024-08-27 17:17:47 +02:00
Jack Wrenn 1ad218f3af safe transmute: Rename `BikeshedIntrinsicFrom` to `TransmuteFrom`
As our implementation of MCP411 nears completion and we begin to
solicit testing, it's no longer reasonable to expect testers to
type or remember `BikeshedIntrinsicFrom`. The name degrades the
ease-of-reading of documentation, and the overall experience of
using compiler safe transmute.

Tentatively, we'll instead adopt `TransmuteFrom`.

This name seems to be the one most likely to be stabilized, after
discussion on Zulip [1]. We may want to revisit the ordering of
`Src` and `Dst` before stabilization, at which point we'd likely
consider `TransmuteInto` or `Transmute`.

[1] https://rust-lang.zulipchat.com/#narrow/stream/216762-project-safe-transmute/topic/What.20should.20.60BikeshedIntrinsicFrom.60.20be.20named.3F
2024-08-27 14:05:54 +00:00
bors 600edc948a Auto merge of #128134 - joboet:move_pal_alloc, r=cupiver
std: move allocators to `sys`

Part of #117276.
2024-08-27 13:51:39 +00:00
Kajetan Puchalski 0f871b5baa tests: Update with new aarch64 target features
Additionally, remove optional matching for +v8a given that the minimum LLVM version is now past 14.
2024-08-27 12:06:30 +00:00
Ralf Jung ab4a743a38 fix Pointer to reference conversion docs 2024-08-27 12:28:43 +02:00
Kajetan Puchalski 3a0fbb5d4e rustc_codegen_llvm: Filter out unavailable LLVM features
Convert to_llvm_features to return Option<LLVMFeature> so that it can
return None if the requested feature is not available for the current
LLVM version.

Add match rules to filter out aarch64 features not available in LLVM 17.
2024-08-27 11:13:01 +01:00
Kajetan Puchalski 4fc4019cbc rustc_target: Remove fpmr target feature
FEAT_FPMR has been removed from upstream LLVM as of LLVM 19.
Remove the feature from the target features list and temporarily hack
the LLVM codegen to always enable it until the minimum LLVM version is
bumped to 19.
2024-08-27 11:11:47 +01:00
Kajetan Puchalski c3518067c7 rustc_target: Add SME aarch64 features
Add SME aarch64 features already supported by LLVM and Linux.

This commit adds compiler support for the following features:

- FEAT_SME
- FEAT_SME_F16F16
- FEAT_SME_F64F64
- FEAT_SME_F8F16
- FEAT_SME_F8F32
- FEAT_SME_FA64
- FEAT_SME_I16I64
- FEAT_SME_LUTv2
- FEAT_SME2
- FEAT_SME2p1
- FEAT_SSVE_FP8DOT2
- FEAT_SSVE_FP8DOT4
- FEAT_SSVE_FP8FMA
2024-08-27 11:11:47 +01:00
Kajetan Puchalski 4f847bd326 rustc_target: Add various aarch64 features
Add various aarch64 features already supported by LLVM and Linux.

The features are marked as unstable using a newly added symbol, i.e.
aarch64_unstable_target_feature.

Additionally include some comment fixes to ensure consistency of
feature names with the Arm ARM and support for architecture version
target features up to v9.5a.

This commit adds compiler support for the following features:

- FEAT_CSSC
- FEAT_ECV
- FEAT_FAMINMAX
- FEAT_FLAGM2
- FEAT_FP8
- FEAT_FP8DOT2
- FEAT_FP8DOT4
- FEAT_FP8FMA
- FEAT_FPMR
- FEAT_HBC
- FEAT_LSE128
- FEAT_LSE2
- FEAT_LUT
- FEAT_MOPS
- FEAT_LRCPC3
- FEAT_SVE_B16B16
- FEAT_SVE2p1
- FEAT_WFxT
2024-08-27 11:11:47 +01:00
joboet e9566ce9e9
bless miri test 2024-08-27 11:58:20 +02:00
joboet d456814842
std: move allocators to `sys` 2024-08-27 11:58:19 +02:00
Ralf Jung ab7b03e3f4 ABI compat check: detect unadjusted ABI mismatches 2024-08-27 09:04:59 +02:00
bors ae9f5019f9 Auto merge of #129647 - tgross35:rollup-jume49s, r=tgross35
Rollup of 9 pull requests

Successful merges:

 - #126985 (Implement `-Z embed-source` (DWARFv5 source code embedding extension))
 - #127922 (Add unsafe to extern blocks in style guide)
 - #128731 (simd_shuffle intrinsic: allow argument to be passed as vector)
 - #128935 (More work on `zstd` compression)
 - #128942 (miri weak memory emulation: put previous value into initial store buffer)
 - #129418 (rustc: Simplify getting sysroot library directory)
 - #129490 (Add Trusty OS as tier 3 target)
 - #129536 (Add `f16` and `f128` inline ASM support for `aarch64`)
 - #129559 (float types: document NaN bit pattern guarantees)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-08-27 06:50:08 +00:00
Trevor Gross 75ae913ec0
Rollup merge of #129559 - RalfJung:float-nan-semantics, r=thomcc
float types: document NaN bit pattern guarantees

Part of https://github.com/rust-lang/rust/issues/128288: document the guarantees we make for NaN bit patterns.

Cc ``@tgross35``
2024-08-27 01:46:53 -05:00
Trevor Gross 8ea70e9537
Rollup merge of #129536 - beetrees:f16-f128-inline-asm-aarch64, r=Amanieu
Add `f16` and `f128` inline ASM support for `aarch64`

Adds `f16` and `f128` inline ASM support for `aarch64`. SIMD vector types are taken from [the ARM intrinsics list](https://developer.arm.com/architectures/instruction-sets/intrinsics/#f:`@navigationhierarchiesreturnbasetype=[float]&f:@navigationhierarchieselementbitsize=[16]&f:@navigationhierarchiesarchitectures=[A64]).` Based on the work of `@lengrongfu` in #127043.

Relevant issue: #125398
Tracking issue: #116909

`@rustbot` label +F-f16_and_f128

try-job: aarch64-gnu
try-job: aarch64-apple
2024-08-27 01:46:53 -05:00
Trevor Gross 3c131a3f54
Rollup merge of #129490 - randomPoison:trusty-os-support, r=Urgau
Add Trusty OS as tier 3 target

This PR adds support for the [Trusty secure operating system](https://source.android.com/docs/security/features/trusty) as a Tier 3 supported target. This upstreams [the patch that we have been using](https://cs.android.com/android/platform/superproject/+/master:external/rust/crates/libc/patches/trusty.patch;l=1;drc=122e586e93a534160230dc10ae3474cf31dd8f7f) internally. This also revives https://github.com/rust-lang/rust/pull/103895 which was closed due to inactivity, and is being resumed now that time allows.

And MCP has already been done for adding this platform: rust-lang/compiler-team/issues/568

# Target Tier Policy Acknowledgements

> A tier 3 target must have a designated developer or developers (the "target maintainers") on record to be CCed when issues arise regarding the target. (The mechanism to track and CC such developers may evolve over time.)

- Nicole LeGare (``@randomPoison)``
- Stephen Crane (``@rinon)``
- As a fallback trusty-dev-team@google.com can be contacted

> Targets must use naming consistent with any existing targets; for instance, a target for the same CPU or OS as an existing Rust target should use the same name for that CPU or OS. Targets should normally use the same names and naming conventions as used elsewhere in the broader ecosystem beyond Rust (such as in other toolchains), unless they have a very good reason to diverge. Changing the name of a target can be highly disruptive, especially once the target reaches a higher tier, so getting the name right is important even for a tier 3 target.

The two new Trusty targets, `aarch64-unknown-trusty` and `armv7-unknown-trusty` both follow the existing naming convention for similar targets.

> Target names should not introduce undue confusion or ambiguity unless absolutely necessary to maintain ecosystem compatibility. For example, if the name of the target makes people extremely likely to form incorrect beliefs about what it targets, the name should be changed or augmented to disambiguate it.

👍

> Tier 3 targets may have unusual requirements to build or use, but must not create legal issues or impose onerous legal terms for the Rust project or for Rust developers or users.

There are no known legal issues or license incompatibilities.

> Neither this policy nor any decisions made regarding targets shall create any binding agreement or estoppel by any party. If any member of an approving Rust team serves as one of the maintainers of a target, or has any legal or employment requirement (explicit or implicit) that might affect their decisions regarding a target, they must recuse themselves from any approval decisions regarding the target's tier status, though they may otherwise participate in discussions.

👍

> Tier 3 targets should attempt to implement as much of the standard libraries as possible and appropriate (core for most targets, alloc for targets that can support dynamic memory allocation, std for targets with an operating system or equivalent layer of system-provided functionality), but may leave some code unimplemented (either unavailable or stubbed out as appropriate), whether because the target makes it impossible to implement or challenging to implement. The authors of pull requests are not obligated to avoid calling any portions of the standard library on the basis of a tier 3 target not implementing those portions.

This PR only adds the targets for the platform. `std` support will be added once platform support is added to the libc crate, which depends on the language targets being added to rustc.

> The target must provide documentation for the Rust community explaining how to build for the target, using cross-compilation if possible. If the target supports running binaries, or running tests (even if they do not pass), the documentation must explain how to run such binaries or tests for the target, using emulation if possible or dedicated hardware if necessary.

👍

> Tier 3 targets must not impose burden on the authors of pull requests, or other developers in the community, to maintain the target. In particular, do not post comments (automated or manual) on a PR that derail or suggest a block on the PR based on a tier 3 target. Do not send automated messages or notifications (via any medium, including via ``@)`` to a PR author or others involved with a PR regarding a tier 3 target, unless they have opted into such messages.

👍

> Patches adding or updating tier 3 targets must not break any existing tier 2 or tier 1 target, and must not knowingly break another tier 3 target without approval of either the compiler team or the maintainers of the other tier 3 target.

👍

> Tier 3 targets must be able to produce assembly using at least one of rustc's supported backends from any host target. (Having support in a fork of the backend is not sufficient, it must be upstream.)

👍
2024-08-27 01:46:52 -05:00
Trevor Gross 42cd3c60df
Rollup merge of #129418 - petrochenkov:libsearch2, r=jieyouxu
rustc: Simplify getting sysroot library directory

It was very non-obvious that `sess.target_tlib_path`, `make_target_lib_path(...)`, and `sess.target_filesearch(...).search_paths()` result in the same sysroot library directory paths.
They are however, indeed the same, because `sess.target_tlib_path` is initialized to `make_target_lib_path(...)` on `Session` creation, and they are used interchangeably.

There are still some redundant calls to `make_target_lib_path` and other inconsistent ways to obtain sysroot directories, but fixing that requires some behavior changes, while this PR is a pure refactoring.
Some places in the compiler even disagree on the number of sysroots - 1 (explicit `--sysroot` *or* default sysroot), 2 (explicit `--sysroot` *and* default sysroot), or an unclear number of `sysroot_candidates` every of which is considered.
The logic currently using `sess.target_tlib_path` or equivalents assumes one sysroot.
2024-08-27 01:46:51 -05:00
Trevor Gross 427019e37f
Rollup merge of #128942 - RalfJung:interpret-weak-memory, r=saethlin
miri weak memory emulation: put previous value into initial store buffer

Fixes https://github.com/rust-lang/miri/issues/2164 by doing a read before each atomic write so that we can initialize the store buffer. The read suppresses memory access hooks and UB exceptions, to avoid otherwise influencing the program behavior. If the read fails, we store that as `None` in the store buffer, so that when an atomic read races with the first atomic write to some memory and previously the memory was uninitialized, we can report UB due to reading uninit memory.

``@cbeuw`` this changes a bit the way we initialize the store buffers. Not sure if you still remember all this code, but if you could have a look to make sure this still makes sense, that would be great. :)

r? ``@saethlin``
2024-08-27 01:46:51 -05:00
Trevor Gross e209b05037
Rollup merge of #128935 - lqd:needs-zstd, r=Kobzol
More work on `zstd` compression

r? ``@Kobzol`` as we've discussed this.

This is a draft to show the current approach of supporting zstd in compiletest, and making the tests using it unconditional.

Knowing whether llvm/lld was built with `LLVM_ENABLE_ZSTD` is quite hard, so there are two strategies. There are details in the code, and we can discuss this approach. Until we know the config used to build CI artifacts, it seems our options are somewhat limited in any case.

zlib compression seems always enabled, so we only check this in its dedicated test, allowing the test to ignore errors due to zstd not being supported.

The zstd test is made unconditional in what it tests, by relying on `needs-llvm-zstd` to be ignored when `llvm.libzstd` isn't enabled in `config.toml`.

try-job: x86_64-gnu
try-job: x86_64-msvc
try-job: x86_64-gnu-distcheck
2024-08-27 01:46:50 -05:00
Trevor Gross d2ff033302
Rollup merge of #128731 - RalfJung:simd-shuffle-vector, r=workingjubilee
simd_shuffle intrinsic: allow argument to be passed as vector

See https://github.com/rust-lang/rust/issues/128738 for context.

I'd like to get rid of [this hack](6c0b89dfac/compiler/rustc_codegen_ssa/src/mir/block.rs (L922-L935)). https://github.com/rust-lang/rust/pull/128537 almost lets us do that since constant SIMD vectors will then be passed as immediate arguments. However, simd_shuffle for some reason actually takes an *array* as argument, not a vector, so the hack is still required to ensure that the array becomes an immediate (which then later stages of codegen convert into a vector, as that's what LLVM needs).

This PR prepares simd_shuffle to also support a vector as the `idx` argument. Once this lands, stdarch can hopefully be updated to pass `idx` as a vector, and then support for arrays can be removed, which finally lets us get rid of that hack.
2024-08-27 01:46:50 -05:00
Trevor Gross 9c132b29e7
Rollup merge of #127922 - spastorino:unsafe-extern-blocks-in-style-guide, r=compiler-errors
Add unsafe to extern blocks in style guide

This goes after this is merged:

- https://github.com/rust-lang/rust/pull/127921

r? ``@traviscross``

Tracking:

- https://github.com/rust-lang/rust/issues/123743
2024-08-27 01:46:49 -05:00
Trevor Gross 9c26ebe32e
Rollup merge of #126985 - Mrmaxmeier:dwarf-embed-source, r=davidtwco
Implement `-Z embed-source` (DWARFv5 source code embedding extension)

Implement https://github.com/rust-lang/compiler-team/issues/764 MCP which adds an unstable flag that exposes LLVM's [DWARFv5 source code embedding](https://dwarfstd.org/issues/180201.1.html) support.
2024-08-27 01:46:49 -05:00
Nicholas Nethercote 22cdd632f1 Add `warn(unreachable_pub)` to `rustc_llvm`. 2024-08-27 15:28:26 +10:00
Nicholas Nethercote e7f1922abd Add `warn(unreachable_pub)` to `rustc_lint_defs`. 2024-08-27 15:25:49 +10:00
Nicholas Nethercote f10284162f Add `warn(unreachable_pub)` to `rustc_lint`. 2024-08-27 15:24:11 +10:00
Nicholas Nethercote 6c84c55c9f Add `warn(unreachable_pub)` to `rustc_lexer`. 2024-08-27 15:12:46 +10:00
Nicholas Nethercote a941a4be77 Add `warn(unreachable_pub)` to `rustc_interface`. 2024-08-27 15:11:54 +10:00
Nicholas Nethercote 688792715b Add `warn(unreachable_pub)` to `rustc_infer`. 2024-08-27 14:47:56 +10:00
Nicholas Nethercote 46fe09f3f3 Add `warn(unreachable_pub)` to `rustc_index`. 2024-08-27 14:33:24 +10:00
Nicholas Nethercote 37becf7bdc Add `warn(unreachable_pub)` to `rustc_incremental`. 2024-08-27 14:30:20 +10:00
beetrees d0548359b5
Reflow a couple of paragraphs in floating-point primitive docs 2024-08-27 05:26:28 +01:00
beetrees 969f9702da
Fix typos in floating-point primitive type docs 2024-08-27 05:25:34 +01:00
Nicholas Nethercote 7fc0444340 Add `warn(unreachable_pub)` to `rustc_hir_typeck`. 2024-08-27 14:22:07 +10:00
Michael Howell a1746b4202 rustdoc: fix missing resource suffix on `crates.js`
Fixes a regression introduced in #128252.
2024-08-26 20:42:32 -07:00
Nicholas Nethercote 3aae994ca2 Add `warn(unreachable_pub)` to `rustc_hir_pretty`. 2024-08-27 13:25:40 +10:00
Nicholas Nethercote 5acf4e7b4b Add `warn(unreachable_pub)` to `rustc_hir_analysis`. 2024-08-27 13:14:50 +10:00
Nicholas Nethercote bffa2244ed Add `warn(unreachable_pub)` to `rustc_hir`. 2024-08-27 12:59:20 +10:00
Nicholas Nethercote fa18140994 Add `warn(unreachable_pub)` to `rustc_graphviz`. 2024-08-27 12:58:29 +10:00
Nicholas Nethercote a510813e03 Add `warn(unreachable_pub)` to `rustc_fluent_macro`. 2024-08-27 12:56:54 +10:00
Nicholas Nethercote 0d8d05c07f Add `warn(unreachable_pub)` to `rustc_feature`. 2024-08-27 12:55:54 +10:00