authorbors <bors@rust-lang.org> 2024-08-31 20:59:27 UTC
committerbors <bors@rust-lang.org> 2024-08-31 20:59:27 UTC
loga7399ba69d37b019677a9c47fe89ceb8dd82db2d
tree70cd4cf67b0b0ed7570e293f29e1992dfd7e861c
parentd571ae851d93541bef826c3c48c1e9ad99da77d6
parent4151fd407e41bfdcd166ebe07ed06d8303921c6c

Auto merge of #129831 - matthiaskrgr:rollup-befq6zx, r=matthiaskrgr

Rollup of 11 pull requests Successful merges: - #128523 (Add release notes for 1.81.0) - #129605 (Add missing `needs-llvm-components` directives for run-make tests that need target-specific codegen) - #129650 (Clean up `library/profiler_builtins/build.rs`) - #129651 (skip stage 0 target check if `BOOTSTRAP_SKIP_TARGET_SANITY` is set) - #129684 (Enable Miri to pass pointers through FFI) - #129762 (Update the `wasm-component-ld` binary dependency) - #129782 (couple more crash tests) - #129816 (tidy: say which feature gate has a stability issue mismatch) - #129818 (make the const-unstable-in-stable error more clear) - #129824 (Fix code examples buttons not appearing on click on mobile) - #129826 (library: Fix typo in `core::mem`) r? `@ghost` `@rustbot` modify labels: rollup

41 files changed, 645 insertions(+), 187 deletions(-)

Cargo.lock+32-23
......@@ -2463,7 +2463,7 @@ dependencies = [
24632463 "indexmap",
24642464 "memchr",
24652465 "ruzstd 0.7.0",
2466 "wasmparser",
2466 "wasmparser 0.215.0",
24672467]
24682468
24692469[[package]]
......@@ -3133,7 +3133,7 @@ dependencies = [
31333133 "regex",
31343134 "serde_json",
31353135 "similar",
3136 "wasmparser",
3136 "wasmparser 0.216.0",
31373137]
31383138
31393139[[package]]
......@@ -5779,9 +5779,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
57795779
57805780[[package]]
57815781name = "wasi-preview1-component-adapter-provider"
5782version = "23.0.2"
5782version = "24.0.0"
57835783source = "registry+https://github.com/rust-lang/crates.io-index"
5784checksum = "f91d3d13afef569b9fc80cfbb807c87c16ef49bd3ac1a93285ea6a264b600d2d"
5784checksum = "36e6cadfa74538edd5409b6f8c79628436529138e9618b7373bec7aae7805835"
57855785
57865786[[package]]
57875787name = "wasm-bindgen"
......@@ -5840,16 +5840,16 @@ checksum = "c62a0a307cb4a311d3a07867860911ca130c3494e8c2719593806c08bc5d0484"
58405840
58415841[[package]]
58425842name = "wasm-component-ld"
5843version = "0.5.6"
5843version = "0.5.7"
58445844source = "registry+https://github.com/rust-lang/crates.io-index"
5845checksum = "51449c63d1ce69f92b8465a084ed5b91f1a7eb583fa95796650a6bfcffc4f9cb"
5845checksum = "13261270d3ac58ffae0219ae34f297a7e24f9ee3b13b29be579132c588a83519"
58465846dependencies = [
58475847 "anyhow",
58485848 "clap",
58495849 "lexopt",
58505850 "tempfile",
58515851 "wasi-preview1-component-adapter-provider",
5852 "wasmparser",
5852 "wasmparser 0.216.0",
58535853 "wat",
58545854 "wit-component",
58555855 "wit-parser",
......@@ -5864,19 +5864,19 @@ dependencies = [
58645864
58655865[[package]]
58665866name = "wasm-encoder"
5867version = "0.215.0"
5867version = "0.216.0"
58685868source = "registry+https://github.com/rust-lang/crates.io-index"
5869checksum = "4fb56df3e06b8e6b77e37d2969a50ba51281029a9aeb3855e76b7f49b6418847"
5869checksum = "04c23aebea22c8a75833ae08ed31ccc020835b12a41999e58c31464271b94a88"
58705870dependencies = [
58715871 "leb128",
5872 "wasmparser",
5872 "wasmparser 0.216.0",
58735873]
58745874
58755875[[package]]
58765876name = "wasm-metadata"
5877version = "0.215.0"
5877version = "0.216.0"
58785878source = "registry+https://github.com/rust-lang/crates.io-index"
5879checksum = "0c6bb07c5576b608f7a2a9baa2294c1a3584a249965d695a9814a496cb6d232f"
5879checksum = "47c8154d703a6b0e45acf6bd172fa002fc3c7058a9f7615e517220aeca27c638"
58805880dependencies = [
58815881 "anyhow",
58825882 "indexmap",
......@@ -5885,7 +5885,7 @@ dependencies = [
58855885 "serde_json",
58865886 "spdx",
58875887 "wasm-encoder",
5888 "wasmparser",
5888 "wasmparser 0.216.0",
58895889]
58905890
58915891[[package]]
......@@ -5893,6 +5893,15 @@ name = "wasmparser"
58935893version = "0.215.0"
58945894source = "registry+https://github.com/rust-lang/crates.io-index"
58955895checksum = "53fbde0881f24199b81cf49b6ff8f9c145ac8eb1b7fc439adb5c099734f7d90e"
5896dependencies = [
5897 "bitflags 2.6.0",
5898]
5899
5900[[package]]
5901name = "wasmparser"
5902version = "0.216.0"
5903source = "registry+https://github.com/rust-lang/crates.io-index"
5904checksum = "bcdee6bea3619d311fb4b299721e89a986c3470f804b6d534340e412589028e3"
58965905dependencies = [
58975906 "ahash",
58985907 "bitflags 2.6.0",
......@@ -5904,9 +5913,9 @@ dependencies = [
59045913
59055914[[package]]
59065915name = "wast"
5907version = "215.0.0"
5916version = "216.0.0"
59085917source = "registry+https://github.com/rust-lang/crates.io-index"
5909checksum = "1ff1d00d893593249e60720be04a7c1f42f1c4dc3806a2869f4e66ab61eb54cb"
5918checksum = "f7eb1f2eecd913fdde0dc6c3439d0f24530a98ac6db6cb3d14d92a5328554a08"
59105919dependencies = [
59115920 "bumpalo",
59125921 "leb128",
......@@ -5917,9 +5926,9 @@ dependencies = [
59175926
59185927[[package]]
59195928name = "wat"
5920version = "1.215.0"
5929version = "1.216.0"
59215930source = "registry+https://github.com/rust-lang/crates.io-index"
5922checksum = "670bf4d9c8cf76ae242d70ded47c546525b6dafaa6871f9bcb065344bf2b4e3d"
5931checksum = "ac0409090fb5154f95fb5ba3235675fd9e579e731524d63b6a2f653e1280c82a"
59235932dependencies = [
59245933 "wast",
59255934]
......@@ -6206,9 +6215,9 @@ dependencies = [
62066215
62076216[[package]]
62086217name = "wit-component"
6209version = "0.215.0"
6218version = "0.216.0"
62106219source = "registry+https://github.com/rust-lang/crates.io-index"
6211checksum = "f725e3885fc5890648be5c5cbc1353b755dc932aa5f1aa7de968b912a3280743"
6220checksum = "7e2ca3ece38ea2447a9069b43074ba73d96dde1944cba276c54e41371745f9dc"
62126221dependencies = [
62136222 "anyhow",
62146223 "bitflags 2.6.0",
......@@ -6219,15 +6228,15 @@ dependencies = [
62196228 "serde_json",
62206229 "wasm-encoder",
62216230 "wasm-metadata",
6222 "wasmparser",
6231 "wasmparser 0.216.0",
62236232 "wit-parser",
62246233]
62256234
62266235[[package]]
62276236name = "wit-parser"
6228version = "0.215.0"
6237version = "0.216.0"
62296238source = "registry+https://github.com/rust-lang/crates.io-index"
6230checksum = "935a97eaffd57c3b413aa510f8f0b550a4a9fe7d59e79cd8b89a83dcb860321f"
6239checksum = "a4d108165c1167a4ccc8a803dcf5c28e0a51d6739fd228cc7adce768632c764c"
62316240dependencies = [
62326241 "anyhow",
62336242 "id-arena",
......@@ -6238,7 +6247,7 @@ dependencies = [
62386247 "serde_derive",
62396248 "serde_json",
62406249 "unicode-xid",
6241 "wasmparser",
6250 "wasmparser 0.216.0",
62426251]
62436252
62446253[[package]]
RELEASES.md+114
......@@ -1,3 +1,117 @@
1Version 1.81.0 (2024-09-05)
2==========================
3
4<a id="1.81.0-Language"></a>
5
6Language
7--------
8
9- [Abort on uncaught panics in `extern "C"` functions.](https://github.com/rust-lang/rust/pull/116088/)
10- [Fix ambiguous cases of multiple `&` in elided self lifetimes.](https://github.com/rust-lang/rust/pull/117967/)
11- [Stabilize `#[expect]` for lints (RFC 2383),](https://github.com/rust-lang/rust/pull/120924/) like `#[allow]` with a warning if the lint is _not_ fulfilled.
12- [Change method resolution to constrain hidden types instead of rejecting method candidates.](https://github.com/rust-lang/rust/pull/123962/)
13- [Bump `elided_lifetimes_in_associated_constant` to deny.](https://github.com/rust-lang/rust/pull/124211/)
14- [`offset_from`: always allow pointers to point to the same address.](https://github.com/rust-lang/rust/pull/124921/)
15- [Allow constraining opaque types during subtyping in the trait system.](https://github.com/rust-lang/rust/pull/125447/)
16- [Allow constraining opaque types during various unsizing casts.](https://github.com/rust-lang/rust/pull/125610/)
17- [Deny keyword lifetimes pre-expansion.](https://github.com/rust-lang/rust/pull/126762/)
18
19<a id="1.81.0-Compiler"></a>
20
21Compiler
22--------
23
24- [Make casts of pointers to trait objects stricter.](https://github.com/rust-lang/rust/pull/120248/)
25- [Check alias args for well-formedness even if they have escaping bound vars.](https://github.com/rust-lang/rust/pull/123737/)
26- [Deprecate no-op codegen option `-Cinline-threshold=...`.](https://github.com/rust-lang/rust/pull/124712/)
27- [Re-implement a type-size based limit.](https://github.com/rust-lang/rust/pull/125507/)
28- [Properly account for alignment in `transmute` size checks.](https://github.com/rust-lang/rust/pull/125740/)
29- [Remove the `box_pointers` lint.](https://github.com/rust-lang/rust/pull/126018/)
30- [Ensure the interpreter checks bool/char for validity when they are used in a cast.](https://github.com/rust-lang/rust/pull/126265/)
31- [Improve coverage instrumentation for functions containing nested items.](https://github.com/rust-lang/rust/pull/127199/)
32- Target changes:
33 - [Add Tier 3 `no_std` Xtensa targets:](https://github.com/rust-lang/rust/pull/125141/) `xtensa-esp32-none-elf`, `xtensa-esp32s2-none-elf`, `xtensa-esp32s3-none-elf`
34 - [Add Tier 3 `std` Xtensa targets:](https://github.com/rust-lang/rust/pull/126380/) `xtensa-esp32-espidf`, `xtensa-esp32s2-espidf`, `xtensa-esp32s3-espidf`
35 - [Add Tier 3 i686 Redox OS target:](https://github.com/rust-lang/rust/pull/126192/) `i686-unknown-redox`
36 - [Promote `arm64ec-pc-windows-msvc` to Tier 2.](https://github.com/rust-lang/rust/pull/126039/)
37 - [Promote `wasm32-wasip2` to Tier 2.](https://github.com/rust-lang/rust/pull/126967/)
38 - [Promote `loongarch64-unknown-linux-musl` to Tier 2 with host tools.](https://github.com/rust-lang/rust/pull/126298/)
39 - [Enable full tools and profiler for LoongArch Linux targets.](https://github.com/rust-lang/rust/pull/127078/)
40 - [Unconditionally warn on usage of `wasm32-wasi`.](https://github.com/rust-lang/rust/pull/126662/) (see compatibility note below)
41 - Refer to Rust's [platform support page][platform-support-doc] for more information on Rust's tiered platform support.
42
43<a id="1.81.0-Libraries"></a>
44
45Libraries
46---------
47
48- [Split core's `PanicInfo` and std's `PanicInfo`.](https://github.com/rust-lang/rust/pull/115974/) (see compatibility note below)
49- [Generalize `{Rc,Arc}::make_mut()` to unsized types.](https://github.com/rust-lang/rust/pull/116113/)
50- [Replace sort implementations with stable `driftsort` and unstable `ipnsort`.](https://github.com/rust-lang/rust/pull/124032/) All `slice::sort*` and `slice::select_nth*` methods are expected to see significant performance improvements. See the [research project](https://github.com/Voultapher/sort-research-rs) for more details.
51- [Document behavior of `create_dir_all` with respect to empty paths.](https://github.com/rust-lang/rust/pull/125112/)
52- [Fix interleaved output in the default panic hook when multiple threads panic simultaneously.](https://github.com/rust-lang/rust/pull/127397/)
53
54<a id="1.81.0-Stabilized-APIs"></a>
55
56Stabilized APIs
57---------------
58
59- [`core::error`](https://doc.rust-lang.org/stable/core/error/index.html)
60- [`hint::assert_unchecked`](https://doc.rust-lang.org/stable/core/hint/fn.assert_unchecked.html)
61- [`fs::exists`](https://doc.rust-lang.org/stable/std/fs/fn.exists.html)
62- [`AtomicBool::fetch_not`](https://doc.rust-lang.org/stable/core/sync/atomic/struct.AtomicBool.html#method.fetch_not)
63- [`Duration::abs_diff`](https://doc.rust-lang.org/stable/core/time/struct.Duration.html#method.abs_diff)
64- [`IoSlice::advance`](https://doc.rust-lang.org/stable/std/io/struct.IoSlice.html#method.advance)
65- [`IoSlice::advance_slices`](https://doc.rust-lang.org/stable/std/io/struct.IoSlice.html#method.advance_slices)
66- [`IoSliceMut::advance`](https://doc.rust-lang.org/stable/std/io/struct.IoSliceMut.html#method.advance)
67- [`IoSliceMut::advance_slices`](https://doc.rust-lang.org/stable/std/io/struct.IoSliceMut.html#method.advance_slices)
68- [`PanicHookInfo`](https://doc.rust-lang.org/stable/std/panic/struct.PanicHookInfo.html)
69- [`PanicInfo::message`](https://doc.rust-lang.org/stable/core/panic/struct.PanicInfo.html#method.message)
70- [`PanicMessage`](https://doc.rust-lang.org/stable/core/panic/struct.PanicMessage.html)
71
72These APIs are now stable in const contexts:
73
74- [`char::from_u32_unchecked`](https://doc.rust-lang.org/stable/core/char/fn.from_u32_unchecked.html) (function)
75- [`char::from_u32_unchecked`](https://doc.rust-lang.org/stable/core/primitive.char.html#method.from_u32_unchecked) (method)
76- [`CStr::count_bytes`](https://doc.rust-lang.org/stable/core/ffi/c_str/struct.CStr.html#method.count_bytes)
77- [`CStr::from_ptr`](https://doc.rust-lang.org/stable/core/ffi/c_str/struct.CStr.html#method.from_ptr)
78
79<a id="1.81.0-Cargo"></a>
80
81Cargo
82-----
83
84- [Generated `.cargo_vcs_info.json` is always included, even when `--allow-dirty` is passed.](https://github.com/rust-lang/cargo/pull/13960/)
85- [Disallow `package.license-file` and `package.readme` pointing to non-existent files during packaging.](https://github.com/rust-lang/cargo/pull/13921/)
86- [Disallow passing `--release`/`--debug` flag along with the `--profile` flag.](https://github.com/rust-lang/cargo/pull/13971/)
87- [Remove `lib.plugin` key support in `Cargo.toml`. Rust plugin support has been deprecated for four years and was removed in 1.75.0.](https://github.com/rust-lang/cargo/pull/13902/)
88
89<a id="1.81.0-Compatibility-Notes"></a>
90
91Compatibility Notes
92-------------------
93
94* Usage of the `wasm32-wasi` target will now issue a compiler warning and request users switch to the `wasm32-wasip1` target instead. Both targets are the same, `wasm32-wasi` is only being renamed, and this [change to the WASI target](https://blog.rust-lang.org/2024/04/09/updates-to-rusts-wasi-targets.html) is being done to enable removing `wasm32-wasi` in January 2025.
95
96* We have renamed `std::panic::PanicInfo` to `std::panic::PanicHookInfo`. The old name will continue to work as an alias, but will result in a deprecation warning starting in Rust 1.82.0.
97
98 `core::panic::PanicInfo` will remain unchanged, however, as this is now a *different type*.
99
100 The reason is that these types have different roles: `std::panic::PanicHookInfo` is the argument to the [panic hook](https://doc.rust-lang.org/stable/std/panic/fn.set_hook.html) in std context (where panics can have an arbitrary payload), while `core::panic::PanicInfo` is the argument to the [`#[panic_handler]`](https://doc.rust-lang.org/nomicon/panic-handler.html) in no_std context (where panics always carry a formatted *message*). Separating these types allows us to add more useful methods to these types, such as `std::panic::PanicHookInfo::payload_as_str()` and `core::panic::PanicInfo::message()`.
101
102* The new sort implementations may panic if a type's implementation of [`Ord`](https://doc.rust-lang.org/std/cmp/trait.Ord.html) (or the given comparison function) does not implement a [total order](https://en.wikipedia.org/wiki/Total_order) as the trait requires. `Ord`'s supertraits (`PartialOrd`, `Eq`, and `PartialEq`) must also be consistent. The previous implementations would not "notice" any problem, but the new implementations have a good chance of detecting inconsistencies, throwing a panic rather than returning knowingly unsorted data.
103
104<a id="1.81.0-Internal-Changes"></a>
105
106Internal Changes
107----------------
108
109These changes do not affect any public interfaces of Rust, but they represent
110significant improvements to the performance or internals of rustc and related
111tools.
112
113- [Add a Rust-for Linux `auto` CI job to check kernel builds.](https://github.com/rust-lang/rust/pull/125209/)
114
1115Version 1.80.0 (2024-07-25)
2116==========================
3117
compiler/rustc_codegen_ssa/Cargo.toml+1-1
......@@ -41,7 +41,7 @@ tempfile = "3.2"
4141thin-vec = "0.2.12"
4242thorin-dwp = "0.7"
4343tracing = "0.1"
44wasm-encoder = "0.215.0"
44wasm-encoder = "0.216.0"
4545# tidy-alphabetical-end
4646
4747[target.'cfg(unix)'.dependencies]
compiler/rustc_const_eval/messages.ftl+2-2
......@@ -415,8 +415,8 @@ const_eval_unstable_const_fn = `{$def_path}` is not yet stable as a const fn
415415
416416const_eval_unstable_in_stable =
417417 const-stable function cannot use `#[feature({$gate})]`
418 .unstable_sugg = if it is not part of the public API, make this function unstably const
419 .bypass_sugg = otherwise `#[rustc_allow_const_fn_unstable]` can be used to bypass stability checks (but requires team approval)
418 .unstable_sugg = if the function is not (yet) meant to be stable, make this function unstably const
419 .bypass_sugg = otherwise, as a last resort `#[rustc_allow_const_fn_unstable]` can be used to bypass stability checks (but requires team approval)
420420
421421const_eval_unterminated_c_string =
422422 reading a null-terminated string starting at {$pointer} with no null found before end of allocation
compiler/rustc_const_eval/src/interpret/machine.rs+1-11
......@@ -362,17 +362,7 @@ pub trait Machine<'tcx>: Sized {
362362 ecx: &InterpCx<'tcx, Self>,
363363 id: AllocId,
364364 alloc: &'b Allocation,
365 ) -> InterpResult<'tcx, Cow<'b, Allocation<Self::Provenance, Self::AllocExtra, Self::Bytes>>>
366 {
367 // The default implementation does a copy; CTFE machines have a more efficient implementation
368 // based on their particular choice for `Provenance`, `AllocExtra`, and `Bytes`.
369 let kind = Self::GLOBAL_KIND
370 .expect("if GLOBAL_KIND is None, adjust_global_allocation must be overwritten");
371 let alloc = alloc.adjust_from_tcx(&ecx.tcx, |ptr| ecx.global_root_pointer(ptr))?;
372 let extra =
373 Self::init_alloc_extra(ecx, id, MemoryKind::Machine(kind), alloc.size(), alloc.align)?;
374 Ok(Cow::Owned(alloc.with_extra(extra)))
375 }
365 ) -> InterpResult<'tcx, Cow<'b, Allocation<Self::Provenance, Self::AllocExtra, Self::Bytes>>>;
376366
377367 /// Initialize the extra state of an allocation.
378368 ///
compiler/rustc_middle/src/mir/interpret/allocation.rs+2-1
......@@ -358,10 +358,11 @@ impl Allocation {
358358 pub fn adjust_from_tcx<Prov: Provenance, Bytes: AllocBytes, Err>(
359359 &self,
360360 cx: &impl HasDataLayout,
361 mut alloc_bytes: impl FnMut(&[u8], Align) -> Result<Bytes, Err>,
361362 mut adjust_ptr: impl FnMut(Pointer<CtfeProvenance>) -> Result<Pointer<Prov>, Err>,
362363 ) -> Result<Allocation<Prov, (), Bytes>, Err> {
363364 // Copy the data.
364 let mut bytes = Bytes::from_bytes(Cow::Borrowed(&*self.bytes), self.align);
365 let mut bytes = alloc_bytes(&*self.bytes, self.align)?;
365366 // Adjust provenance of pointers stored in this allocation.
366367 let mut new_provenance = Vec::with_capacity(self.provenance.ptrs().len());
367368 let ptr_size = cx.data_layout().pointer_size.bytes_usize();
compiler/rustc_passes/src/stability.rs+1-2
......@@ -544,9 +544,8 @@ impl<'tcx> MissingStabilityAnnotations<'tcx> {
544544 let is_stable =
545545 self.tcx.lookup_stability(def_id).is_some_and(|stability| stability.level.is_stable());
546546 let missing_const_stability_attribute = self.tcx.lookup_const_stability(def_id).is_none();
547 let is_reachable = self.effective_visibilities.is_reachable(def_id);
548547
549 if is_const && is_stable && missing_const_stability_attribute && is_reachable {
548 if is_const && is_stable && missing_const_stability_attribute {
550549 let descr = self.tcx.def_descr(def_id.to_def_id());
551550 self.tcx.dcx().emit_err(errors::MissingConstStabAttr { span, descr });
552551 }
library/core/src/mem/mod.rs+1-1
......@@ -612,7 +612,7 @@ pub const fn needs_drop<T: ?Sized>() -> bool {
612612///
613613/// There is no guarantee that an all-zero byte-pattern represents a valid value
614614/// of some type `T`. For example, the all-zero byte-pattern is not a valid value
615/// for reference types (`&T`, `&mut T`) and functions pointers. Using `zeroed`
615/// for reference types (`&T`, `&mut T`) and function pointers. Using `zeroed`
616616/// on such types causes immediate [undefined behavior][ub] because [the Rust
617617/// compiler assumes][inv] that there always is a valid value in a variable it
618618/// considers initialized.
library/profiler_builtins/build.rs+32-28
......@@ -1,14 +1,15 @@
11//! Compiles the profiler part of the `compiler-rt` library.
22//!
3//! See the build.rs for libcompiler_builtins crate for details.
3//! Loosely based on:
4//! - LLVM's `compiler-rt/lib/profile/CMakeLists.txt`
5//! - <https://github.com/rust-lang/compiler-builtins/blob/master/build.rs>.
46
57use std::env;
68use std::path::PathBuf;
79
810fn main() {
9 println!("cargo:rerun-if-env-changed=LLVM_PROFILER_RT_LIB");
10 if let Ok(rt) = env::var("LLVM_PROFILER_RT_LIB") {
11 println!("cargo:rustc-link-lib=static:+verbatim={rt}");
11 if let Ok(rt) = tracked_env_var("LLVM_PROFILER_RT_LIB") {
12 println!("cargo::rustc-link-lib=static:+verbatim={rt}");
1213 return;
1314 }
1415
......@@ -16,13 +17,13 @@ fn main() {
1617 let target_env = env::var("CARGO_CFG_TARGET_ENV").expect("CARGO_CFG_TARGET_ENV was not set");
1718 let cfg = &mut cc::Build::new();
1819
19 // FIXME: `rerun-if-changed` directives are not currently emitted and the build script
20 // will not rerun on changes in these source files or headers included into them.
21 let mut profile_sources = vec![
20 let profile_sources = vec![
21 // tidy-alphabetical-start
2222 "GCDAProfiling.c",
2323 "InstrProfiling.c",
2424 "InstrProfilingBuffer.c",
2525 "InstrProfilingFile.c",
26 "InstrProfilingInternal.c",
2627 "InstrProfilingMerge.c",
2728 "InstrProfilingMergeFile.c",
2829 "InstrProfilingNameVar.c",
......@@ -37,15 +38,13 @@ fn main() {
3738 "InstrProfilingValue.c",
3839 "InstrProfilingVersionVar.c",
3940 "InstrProfilingWriter.c",
40 // These files were added in LLVM 11.
41 "InstrProfilingInternal.c",
42 "InstrProfilingBiasVar.c",
41 "WindowsMMap.c",
42 // tidy-alphabetical-end
4343 ];
4444
4545 if target_env == "msvc" {
4646 // Don't pull in extra libraries on MSVC
4747 cfg.flag("/Zl");
48 profile_sources.push("WindowsMMap.c");
4948 cfg.define("strdup", Some("_strdup"));
5049 cfg.define("open", Some("_open"));
5150 cfg.define("fdopen", Some("_fdopen"));
......@@ -60,8 +59,6 @@ fn main() {
6059 if target_os != "windows" {
6160 cfg.flag("-fvisibility=hidden");
6261 cfg.define("COMPILER_RT_HAS_UNAME", Some("1"));
63 } else {
64 profile_sources.push("WindowsMMap.c");
6562 }
6663 }
6764
......@@ -80,26 +77,33 @@ fn main() {
8077 }
8178
8279 // Get the LLVM `compiler-rt` directory from bootstrap.
83 println!("cargo:rerun-if-env-changed=RUST_COMPILER_RT_FOR_PROFILER");
84 let root = PathBuf::from(env::var("RUST_COMPILER_RT_FOR_PROFILER").unwrap_or_else(|_| {
85 let path = "../../src/llvm-project/compiler-rt";
86 println!("RUST_COMPILER_RT_FOR_PROFILER was not set; falling back to {path:?}");
87 path.to_owned()
88 }));
80 let root = PathBuf::from(tracked_env_var_or_fallback(
81 "RUST_COMPILER_RT_FOR_PROFILER",
82 "../../src/llvm-project/compiler-rt",
83 ));
8984
9085 let src_root = root.join("lib").join("profile");
9186 assert!(src_root.exists(), "profiler runtime source directory not found: {src_root:?}");
92 let mut n_sources_found = 0u32;
93 for src in profile_sources {
94 let path = src_root.join(src);
95 if path.exists() {
96 cfg.file(path);
97 n_sources_found += 1;
98 }
87 println!("cargo::rerun-if-changed={}", src_root.display());
88 for file in profile_sources {
89 cfg.file(src_root.join(file));
9990 }
100 assert!(n_sources_found > 0, "couldn't find any profiler runtime source files in {src_root:?}");
10191
102 cfg.include(root.join("include"));
92 let include = root.join("include");
93 println!("cargo::rerun-if-changed={}", include.display());
94 cfg.include(include);
95
10396 cfg.warnings(false);
10497 cfg.compile("profiler-rt");
10598}
99
100fn tracked_env_var(key: &str) -> Result<String, env::VarError> {
101 println!("cargo::rerun-if-env-changed={key}");
102 env::var(key)
103}
104fn tracked_env_var_or_fallback(key: &str, fallback: &str) -> String {
105 tracked_env_var(key).unwrap_or_else(|_| {
106 println!("cargo::warning={key} was not set; falling back to {fallback:?}");
107 fallback.to_owned()
108 })
109}
src/bootstrap/src/core/sanity.rs+2-7
......@@ -8,9 +8,7 @@
88//! In theory if we get past this phase it's a bug if a build fails, but in
99//! practice that's likely not true!
1010
11use std::collections::HashMap;
12#[cfg(not(feature = "bootstrap-self-test"))]
13use std::collections::HashSet;
11use std::collections::{HashMap, HashSet};
1412use std::ffi::{OsStr, OsString};
1513use std::path::PathBuf;
1614use std::{env, fs};
......@@ -34,7 +32,6 @@ pub struct Finder {
3432// it might not yet be included in stage0. In such cases, we handle the targets missing from stage0 in this list.
3533//
3634// Targets can be removed from this list once they are present in the stage0 compiler (usually by updating the beta compiler of the bootstrap).
37#[cfg(not(feature = "bootstrap-self-test"))]
3835const STAGE0_MISSING_TARGETS: &[&str] = &[
3936 // just a dummy comment so the list doesn't get onelined
4037];
......@@ -205,7 +202,6 @@ than building it.
205202 .map(|p| cmd_finder.must_have(p))
206203 .or_else(|| cmd_finder.maybe_have("reuse"));
207204
208 #[cfg(not(feature = "bootstrap-self-test"))]
209205 let stage0_supported_target_list: HashSet<String> = crate::utils::helpers::output(
210206 command(&build.config.initial_rustc).args(["--print", "target-list"]).as_command_mut(),
211207 )
......@@ -234,8 +230,7 @@ than building it.
234230 }
235231
236232 // Ignore fake targets that are only used for unit tests in bootstrap.
237 #[cfg(not(feature = "bootstrap-self-test"))]
238 {
233 if cfg!(not(feature = "bootstrap-self-test")) && !skip_target_sanity {
239234 let mut has_target = false;
240235 let target_str = target.to_string();
241236
src/librustdoc/html/static/js/main.js+8-2
......@@ -1878,9 +1878,15 @@ href="https://doc.rust-lang.org/${channel}/rustdoc/read-documentation/search.htm
18781878 if (elem === null) {
18791879 return;
18801880 }
1881 const buttons = elem.querySelector(".button-holder");
1881 let buttons = elem.querySelector(".button-holder");
18821882 if (buttons === null) {
1883 return;
1883 // On mobile, you can't hover an element so buttons need to be created on click
1884 // if they're not already there.
1885 addCopyButton(event);
1886 buttons = elem.querySelector(".button-holder");
1887 if (buttons === null) {
1888 return;
1889 }
18841890 }
18851891 buttons.classList.toggle("keep-visible");
18861892 }
src/tools/miri/src/alloc_addresses/mod.rs+67-1
......@@ -42,6 +42,11 @@ pub struct GlobalStateInner {
4242 /// they do not have an `AllocExtra`.
4343 /// This is the inverse of `int_to_ptr_map`.
4444 base_addr: FxHashMap<AllocId, u64>,
45 /// Temporarily store prepared memory space for global allocations the first time their memory
46 /// address is required. This is used to ensure that the memory is allocated before Miri assigns
47 /// it an internal address, which is important for matching the internal address to the machine
48 /// address so FFI can read from pointers.
49 prepared_alloc_bytes: FxHashMap<AllocId, MiriAllocBytes>,
4550 /// A pool of addresses we can reuse for future allocations.
4651 reuse: ReusePool,
4752 /// Whether an allocation has been exposed or not. This cannot be put
......@@ -59,6 +64,7 @@ impl VisitProvenance for GlobalStateInner {
5964 let GlobalStateInner {
6065 int_to_ptr_map: _,
6166 base_addr: _,
67 prepared_alloc_bytes: _,
6268 reuse: _,
6369 exposed: _,
6470 next_base_addr: _,
......@@ -78,6 +84,7 @@ impl GlobalStateInner {
7884 GlobalStateInner {
7985 int_to_ptr_map: Vec::default(),
8086 base_addr: FxHashMap::default(),
87 prepared_alloc_bytes: FxHashMap::default(),
8188 reuse: ReusePool::new(config),
8289 exposed: FxHashSet::default(),
8390 next_base_addr: stack_addr,
......@@ -166,7 +173,39 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> {
166173 assert!(!matches!(kind, AllocKind::Dead));
167174
168175 // This allocation does not have a base address yet, pick or reuse one.
169 let base_addr = if let Some((reuse_addr, clock)) = global_state.reuse.take_addr(
176 let base_addr = if ecx.machine.native_lib.is_some() {
177 // In native lib mode, we use the "real" address of the bytes for this allocation.
178 // This ensures the interpreted program and native code have the same view of memory.
179 match kind {
180 AllocKind::LiveData => {
181 let ptr = if ecx.tcx.try_get_global_alloc(alloc_id).is_some() {
182 // For new global allocations, we always pre-allocate the memory to be able use the machine address directly.
183 let prepared_bytes = MiriAllocBytes::zeroed(size, align)
184 .unwrap_or_else(|| {
185 panic!("Miri ran out of memory: cannot create allocation of {size:?} bytes")
186 });
187 let ptr = prepared_bytes.as_ptr();
188 // Store prepared allocation space to be picked up for use later.
189 global_state.prepared_alloc_bytes.try_insert(alloc_id, prepared_bytes).unwrap();
190 ptr
191 } else {
192 ecx.get_alloc_bytes_unchecked_raw(alloc_id)?
193 };
194 // Ensure this pointer's provenance is exposed, so that it can be used by FFI code.
195 ptr.expose_provenance().try_into().unwrap()
196 }
197 AllocKind::Function | AllocKind::VTable => {
198 // Allocate some dummy memory to get a unique address for this function/vtable.
199 let alloc_bytes = MiriAllocBytes::from_bytes(&[0u8; 1], Align::from_bytes(1).unwrap());
200 // We don't need to expose these bytes as nobody is allowed to access them.
201 let addr = alloc_bytes.as_ptr().addr().try_into().unwrap();
202 // Leak the underlying memory to ensure it remains unique.
203 std::mem::forget(alloc_bytes);
204 addr
205 }
206 AllocKind::Dead => unreachable!()
207 }
208 } else if let Some((reuse_addr, clock)) = global_state.reuse.take_addr(
170209 &mut *rng,
171210 size,
172211 align,
......@@ -318,6 +357,33 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
318357 Ok(base_ptr.wrapping_offset(offset, ecx))
319358 }
320359
360 // This returns some prepared `MiriAllocBytes`, either because `addr_from_alloc_id` reserved
361 // memory space in the past, or by doing the pre-allocation right upon being called.
362 fn get_global_alloc_bytes(&self, id: AllocId, kind: MemoryKind, bytes: &[u8], align: Align) -> InterpResult<'tcx, MiriAllocBytes> {
363 let ecx = self.eval_context_ref();
364 Ok(if ecx.machine.native_lib.is_some() {
365 // In native lib mode, MiriAllocBytes for global allocations are handled via `prepared_alloc_bytes`.
366 // This additional call ensures that some `MiriAllocBytes` are always prepared.
367 ecx.addr_from_alloc_id(id, kind)?;
368 let mut global_state = ecx.machine.alloc_addresses.borrow_mut();
369 // The memory we need here will have already been allocated during an earlier call to
370 // `addr_from_alloc_id` for this allocation. So don't create a new `MiriAllocBytes` here, instead
371 // fetch the previously prepared bytes from `prepared_alloc_bytes`.
372 let mut prepared_alloc_bytes = global_state
373 .prepared_alloc_bytes
374 .remove(&id)
375 .unwrap_or_else(|| panic!("alloc bytes for {id:?} have not been prepared"));
376 // Sanity-check that the prepared allocation has the right size and alignment.
377 assert!(prepared_alloc_bytes.as_ptr().is_aligned_to(align.bytes_usize()));
378 assert_eq!(prepared_alloc_bytes.len(), bytes.len());
379 // Copy allocation contents into prepared memory.
380 prepared_alloc_bytes.copy_from_slice(bytes);
381 prepared_alloc_bytes
382 } else {
383 MiriAllocBytes::from_bytes(std::borrow::Cow::Borrowed(&*bytes), align)
384 })
385 }
386
321387 /// When a pointer is used for a memory access, this computes where in which allocation the
322388 /// access is going.
323389 fn ptr_get_alloc(
src/tools/miri/src/concurrency/thread.rs+1-1
......@@ -889,7 +889,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
889889 let alloc = this.ctfe_query(|tcx| tcx.eval_static_initializer(def_id))?;
890890 // We make a full copy of this allocation.
891891 let mut alloc =
892 alloc.inner().adjust_from_tcx(&this.tcx, |ptr| this.global_root_pointer(ptr))?;
892 alloc.inner().adjust_from_tcx(&this.tcx, |bytes, align| Ok(MiriAllocBytes::from_bytes(std::borrow::Cow::Borrowed(bytes), align)), |ptr| this.global_root_pointer(ptr))?;
893893 // This allocation will be deallocated when the thread dies, so it is not in read-only memory.
894894 alloc.mutability = Mutability::Mut;
895895 // Create a fresh allocation with this content.
src/tools/miri/src/lib.rs+3
......@@ -12,6 +12,9 @@
1212#![feature(let_chains)]
1313#![feature(trait_upcasting)]
1414#![feature(strict_overflow_ops)]
15#![feature(strict_provenance)]
16#![feature(exposed_provenance)]
17#![feature(pointer_is_aligned_to)]
1518// Configure clippy and other lints
1619#![allow(
1720 clippy::collapsible_else_if,
src/tools/miri/src/machine.rs+25
......@@ -1,6 +1,7 @@
11//! Global machine state as well as implementation of the interpreter engine
22//! `Machine` trait.
33
4use std::borrow::Cow;
45use std::cell::RefCell;
56use std::collections::hash_map::Entry;
67use std::fmt;
......@@ -1261,6 +1262,30 @@ impl<'tcx> Machine<'tcx> for MiriMachine<'tcx> {
12611262 })
12621263 }
12631264
1265 /// Called to adjust global allocations to the Provenance and AllocExtra of this machine.
1266 ///
1267 /// If `alloc` contains pointers, then they are all pointing to globals.
1268 ///
1269 /// This should avoid copying if no work has to be done! If this returns an owned
1270 /// allocation (because a copy had to be done to adjust things), machine memory will
1271 /// cache the result. (This relies on `AllocMap::get_or` being able to add the
1272 /// owned allocation to the map even when the map is shared.)
1273 fn adjust_global_allocation<'b>(
1274 ecx: &InterpCx<'tcx, Self>,
1275 id: AllocId,
1276 alloc: &'b Allocation,
1277 ) -> InterpResult<'tcx, Cow<'b, Allocation<Self::Provenance, Self::AllocExtra, Self::Bytes>>>
1278 {
1279 let kind = Self::GLOBAL_KIND.unwrap().into();
1280 let alloc = alloc.adjust_from_tcx(&ecx.tcx,
1281 |bytes, align| ecx.get_global_alloc_bytes(id, kind, bytes, align),
1282 |ptr| ecx.global_root_pointer(ptr),
1283 )?;
1284 let extra =
1285 Self::init_alloc_extra(ecx, id, kind, alloc.size(), alloc.align)?;
1286 Ok(Cow::Owned(alloc.with_extra(extra)))
1287 }
1288
12641289 #[inline(always)]
12651290 fn before_memory_read(
12661291 _tcx: TyCtxtAt<'tcx>,
src/tools/miri/src/shims/native_lib.rs+13
......@@ -194,6 +194,8 @@ enum CArg {
194194 UInt64(u64),
195195 /// usize.
196196 USize(usize),
197 /// Raw pointer, stored as C's `void*`.
198 RawPtr(*mut std::ffi::c_void),
197199}
198200
199201impl<'a> CArg {
......@@ -210,6 +212,7 @@ impl<'a> CArg {
210212 CArg::UInt32(i) => ffi::arg(i),
211213 CArg::UInt64(i) => ffi::arg(i),
212214 CArg::USize(i) => ffi::arg(i),
215 CArg::RawPtr(i) => ffi::arg(i),
213216 }
214217 }
215218}
......@@ -234,6 +237,16 @@ fn imm_to_carg<'tcx>(v: ImmTy<'tcx>, cx: &impl HasDataLayout) -> InterpResult<'t
234237 ty::Uint(UintTy::U64) => CArg::UInt64(v.to_scalar().to_u64()?),
235238 ty::Uint(UintTy::Usize) =>
236239 CArg::USize(v.to_scalar().to_target_usize(cx)?.try_into().unwrap()),
240 ty::RawPtr(_, mutability) => {
241 // Arbitrary mutable pointer accesses are not currently supported in Miri.
242 if mutability.is_mut() {
243 throw_unsup_format!("unsupported mutable pointer type for native call: {}", v.layout.ty);
244 } else {
245 let s = v.to_scalar().to_pointer(cx)?.addr();
246 // This relies on the `expose_provenance` in `addr_from_alloc_id`.
247 CArg::RawPtr(std::ptr::with_exposed_provenance_mut(s.bytes_usize()))
248 }
249 },
237250 _ => throw_unsup_format!("unsupported argument type for native call: {}", v.layout.ty),
238251 })
239252}
src/tools/miri/tests/native-lib/libtest.map deleted-12
......@@ -1,12 +0,0 @@
1CODEABI_1.0 {
2 # Define which symbols to export.
3 global:
4 add_one_int;
5 printer;
6 test_stack_spill;
7 get_unsigned_int;
8 add_int16;
9 add_short_to_long;
10 # The rest remains private.
11 local: *;
12};
src/tools/miri/tests/native-lib/native-lib.map created+20
......@@ -0,0 +1,20 @@
1CODEABI_1.0 {
2 # Define which symbols to export.
3 global:
4 # scalar_arguments.c
5 add_one_int;
6 printer;
7 test_stack_spill;
8 get_unsigned_int;
9 add_int16;
10 add_short_to_long;
11
12 # ptr_read_access.c
13 print_pointer;
14 access_simple;
15 access_nested;
16 access_static;
17
18 # The rest remains private.
19 local: *;
20};
src/tools/miri/tests/native-lib/pass/call_extern_c_fn.rs deleted-46
......@@ -1,46 +0,0 @@
1//@only-target-linux
2//@only-on-host
3
4extern "C" {
5 fn add_one_int(x: i32) -> i32;
6 fn add_int16(x: i16) -> i16;
7 fn test_stack_spill(
8 a: i32,
9 b: i32,
10 c: i32,
11 d: i32,
12 e: i32,
13 f: i32,
14 g: i32,
15 h: i32,
16 i: i32,
17 j: i32,
18 k: i32,
19 l: i32,
20 ) -> i32;
21 fn add_short_to_long(x: i16, y: i64) -> i64;
22 fn get_unsigned_int() -> u32;
23 fn printer();
24}
25
26fn main() {
27 unsafe {
28 // test function that adds 2 to a provided int
29 assert_eq!(add_one_int(1), 3);
30
31 // test function that takes the sum of its 12 arguments
32 assert_eq!(test_stack_spill(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12), 78);
33
34 // test function that adds 3 to a 16 bit int
35 assert_eq!(add_int16(-1i16), 2i16);
36
37 // test function that adds an i16 to an i64
38 assert_eq!(add_short_to_long(-1i16, 123456789123i64), 123456789122i64);
39
40 // test function that returns -10 as an unsigned int
41 assert_eq!(get_unsigned_int(), (-10i32) as u32);
42
43 // test void function that prints from C
44 printer();
45 }
46}
src/tools/miri/tests/native-lib/pass/call_extern_c_fn.stdout deleted-1
......@@ -1 +0,0 @@
1printing from C
src/tools/miri/tests/native-lib/pass/ptr_read_access.rs created+82
......@@ -0,0 +1,82 @@
1//@only-target-linux
2//@only-on-host
3
4fn main() {
5 test_pointer();
6
7 test_simple();
8
9 test_nested();
10
11 test_static();
12}
13
14// Test void function that dereferences a pointer and prints its contents from C.
15fn test_pointer() {
16 extern "C" {
17 fn print_pointer(ptr: *const i32);
18 }
19
20 let x = 42;
21
22 unsafe { print_pointer(&x) };
23}
24
25// Test function that dereferences a simple struct pointer and accesses a field.
26fn test_simple() {
27 #[repr(C)]
28 struct Simple {
29 field: i32
30 }
31
32 extern "C" {
33 fn access_simple(s_ptr: *const Simple) -> i32;
34 }
35
36 let simple = Simple { field: -42 };
37
38 assert_eq!(unsafe { access_simple(&simple) }, -42);
39}
40
41// Test function that dereferences nested struct pointers and accesses fields.
42fn test_nested() {
43 use std::ptr::NonNull;
44
45 #[derive(Debug, PartialEq, Eq)]
46 #[repr(C)]
47 struct Nested {
48 value: i32,
49 next: Option<NonNull<Nested>>,
50 }
51
52 extern "C" {
53 fn access_nested(n_ptr: *const Nested) -> i32;
54 }
55
56 let mut nested_0 = Nested { value: 97, next: None };
57 let mut nested_1 = Nested { value: 98, next: NonNull::new(&mut nested_0) };
58 let nested_2 = Nested { value: 99, next: NonNull::new(&mut nested_1) };
59
60 assert_eq!(unsafe { access_nested(&nested_2) }, 97);
61}
62
63// Test function that dereferences static struct pointers and accesses fields.
64fn test_static() {
65
66 #[repr(C)]
67 struct Static {
68 value: i32,
69 recurse: &'static Static,
70 }
71
72 extern "C" {
73 fn access_static(n_ptr: *const Static) -> i32;
74 }
75
76 static STATIC: Static = Static {
77 value: 9001,
78 recurse: &STATIC,
79 };
80
81 assert_eq!(unsafe { access_static(&STATIC) }, 9001);
82}
src/tools/miri/tests/native-lib/pass/ptr_read_access.stdout created+1
......@@ -0,0 +1 @@
1printing pointer dereference from C: 42
src/tools/miri/tests/native-lib/pass/scalar_arguments.rs created+46
......@@ -0,0 +1,46 @@
1//@only-target-linux
2//@only-on-host
3
4extern "C" {
5 fn add_one_int(x: i32) -> i32;
6 fn add_int16(x: i16) -> i16;
7 fn test_stack_spill(
8 a: i32,
9 b: i32,
10 c: i32,
11 d: i32,
12 e: i32,
13 f: i32,
14 g: i32,
15 h: i32,
16 i: i32,
17 j: i32,
18 k: i32,
19 l: i32,
20 ) -> i32;
21 fn add_short_to_long(x: i16, y: i64) -> i64;
22 fn get_unsigned_int() -> u32;
23 fn printer();
24}
25
26fn main() {
27 unsafe {
28 // test function that adds 2 to a provided int
29 assert_eq!(add_one_int(1), 3);
30
31 // test function that takes the sum of its 12 arguments
32 assert_eq!(test_stack_spill(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12), 78);
33
34 // test function that adds 3 to a 16 bit int
35 assert_eq!(add_int16(-1i16), 2i16);
36
37 // test function that adds an i16 to an i64
38 assert_eq!(add_short_to_long(-1i16, 123456789123i64), 123456789122i64);
39
40 // test function that returns -10 as an unsigned int
41 assert_eq!(get_unsigned_int(), (-10i32) as u32);
42
43 // test void function that prints from C
44 printer();
45 }
46}
src/tools/miri/tests/native-lib/pass/scalar_arguments.stdout created+1
......@@ -0,0 +1 @@
1printing from C
src/tools/miri/tests/native-lib/ptr_read_access.c created+47
......@@ -0,0 +1,47 @@
1#include <stdio.h>
2
3/* Test: test_pointer */
4
5void print_pointer(const int *ptr) {
6 printf("printing pointer dereference from C: %d\n", *ptr);
7}
8
9/* Test: test_simple */
10
11typedef struct Simple {
12 int field;
13} Simple;
14
15int access_simple(const Simple *s_ptr) {
16 return s_ptr->field;
17}
18
19/* Test: test_nested */
20
21typedef struct Nested {
22 int value;
23 struct Nested *next;
24} Nested;
25
26// Returns the innermost/last value of a Nested pointer chain.
27int access_nested(const Nested *n_ptr) {
28 // Edge case: `n_ptr == NULL` (i.e. first Nested is None).
29 if (!n_ptr) { return 0; }
30
31 while (n_ptr->next) {
32 n_ptr = n_ptr->next;
33 }
34
35 return n_ptr->value;
36}
37
38/* Test: test_static */
39
40typedef struct Static {
41 int value;
42 struct Static *recurse;
43} Static;
44
45int access_static(const Static *s_ptr) {
46 return s_ptr->recurse->recurse->value;
47}
src/tools/miri/tests/native-lib/scalar_arguments.c created+27
......@@ -0,0 +1,27 @@
1#include <stdio.h>
2
3int add_one_int(int x) {
4 return 2 + x;
5}
6
7void printer() {
8 printf("printing from C\n");
9}
10
11// function with many arguments, to test functionality when some args are stored
12// on the stack
13int test_stack_spill(int a, int b, int c, int d, int e, int f, int g, int h, int i, int j, int k, int l) {
14 return a+b+c+d+e+f+g+h+i+j+k+l;
15}
16
17unsigned int get_unsigned_int() {
18 return -10;
19}
20
21short add_int16(short x) {
22 return x + 3;
23}
24
25long add_short_to_long(short x, long y) {
26 return x + y;
27}
src/tools/miri/tests/native-lib/test.c deleted-27
......@@ -1,27 +0,0 @@
1#include <stdio.h>
2
3int add_one_int(int x) {
4 return 2 + x;
5}
6
7void printer() {
8 printf("printing from C\n");
9}
10
11// function with many arguments, to test functionality when some args are stored
12// on the stack
13int test_stack_spill(int a, int b, int c, int d, int e, int f, int g, int h, int i, int j, int k, int l) {
14 return a+b+c+d+e+f+g+h+i+j+k+l;
15}
16
17unsigned int get_unsigned_int() {
18 return -10;
19}
20
21short add_int16(short x) {
22 return x + 3;
23}
24
25long add_short_to_long(short x, long y) {
26 return x + y;
27}
src/tools/miri/tests/ui.rs+10-3
......@@ -36,18 +36,25 @@ fn build_native_lib() -> PathBuf {
3636 // Create the directory if it does not already exist.
3737 std::fs::create_dir_all(&so_target_dir)
3838 .expect("Failed to create directory for shared object file");
39 let so_file_path = so_target_dir.join("libtestlib.so");
39 let so_file_path = so_target_dir.join("native-lib.so");
4040 let cc_output = Command::new(cc)
4141 .args([
4242 "-shared",
4343 "-o",
4444 so_file_path.to_str().unwrap(),
45 "tests/native-lib/test.c",
45 // FIXME: Automate gathering of all relevant C source files in the directory.
46 "tests/native-lib/scalar_arguments.c",
47 "tests/native-lib/ptr_read_access.c",
4648 // Only add the functions specified in libcode.version to the shared object file.
4749 // This is to avoid automatically adding `malloc`, etc.
4850 // Source: https://anadoxin.org/blog/control-over-symbol-exports-in-gcc.html/
4951 "-fPIC",
50 "-Wl,--version-script=tests/native-lib/libtest.map",
52 "-Wl,--version-script=tests/native-lib/native-lib.map",
53 // Ensure we notice serious problems in the C code.
54 "-Wall",
55 "-Wextra",
56 "-Wpedantic",
57 "-Werror",
5158 ])
5259 .output()
5360 .expect("failed to generate shared object file for testing native function calls");
src/tools/opt-dist/src/tests.rs+7-1
......@@ -102,7 +102,13 @@ llvm-config = "{llvm_config}"
102102 for test_path in env.skipped_tests() {
103103 args.extend(["--skip", test_path]);
104104 }
105 cmd(&args).env("COMPILETEST_FORCE_STAGE0", "1").run().context("Cannot execute tests")
105 cmd(&args)
106 .env("COMPILETEST_FORCE_STAGE0", "1")
107 // Above we override the stage 0 compiler with previously compiled compiler,
108 // which can cause confusion in bootstrap's target sanity checks.
109 .env("BOOTSTRAP_SKIP_TARGET_SANITY", "1")
110 .run()
111 .context("Cannot execute tests")
106112}
107113
108114/// Tries to find the version of the dist artifacts (either nightly, beta, or 1.XY.Z).
src/tools/run-make-support/Cargo.toml+1-1
......@@ -7,7 +7,7 @@ edition = "2021"
77bstr = "1.6.0"
88object = "0.36.2"
99similar = "2.5.0"
10wasmparser = { version = "0.215", default-features = false, features = ["std"] }
10wasmparser = { version = "0.216", default-features = false, features = ["std"] }
1111regex = "1.8" # 1.8 to avoid memchr 2.6.0, as 2.5.0 is pinned in the workspace
1212gimli = "0.31.0"
1313build_helper = { path = "../build_helper" }
src/tools/tidy/src/features.rs+2-1
......@@ -455,9 +455,10 @@ fn get_and_check_lib_features(
455455 if f.tracking_issue != s.tracking_issue && f.level != Status::Accepted {
456456 tidy_error!(
457457 bad,
458 "{}:{}: `issue` \"{}\" mismatches the {} `issue` of \"{}\"",
458 "{}:{}: feature gate {} has inconsistent `issue`: \"{}\" mismatches the {} `issue` of \"{}\"",
459459 file.display(),
460460 line,
461 name,
461462 f.tracking_issue_display(),
462463 display,
463464 s.tracking_issue_display(),
src/tools/tidy/src/target_specific_tests.rs+8-2
......@@ -36,8 +36,8 @@ struct RevisionInfo<'a> {
3636 llvm_components: Option<Vec<&'a str>>,
3737}
3838
39pub fn check(path: &Path, bad: &mut bool) {
40 crate::walk::walk(path, |path, _is_dir| filter_not_rust(path), &mut |entry, content| {
39pub fn check(tests_path: &Path, bad: &mut bool) {
40 crate::walk::walk(tests_path, |path, _is_dir| filter_not_rust(path), &mut |entry, content| {
4141 let file = entry.path().display();
4242 let mut header_map = BTreeMap::new();
4343 iter_header(content, &mut |HeaderLine { revision, directive, .. }| {
......@@ -65,6 +65,12 @@ pub fn check(path: &Path, bad: &mut bool) {
6565 }
6666 }
6767 });
68
69 // Skip run-make tests as revisions are not supported.
70 if entry.path().strip_prefix(tests_path).is_ok_and(|rest| rest.starts_with("run-make")) {
71 return;
72 }
73
6874 for (rev, RevisionInfo { target_arch, llvm_components }) in &header_map {
6975 let rev = rev.unwrap_or("[unspecified]");
7076 match (target_arch, llvm_components) {
tests/crashes/129425.rs created+6
......@@ -0,0 +1,6 @@
1//@ known-bug: rust-lang/rust#129425
2
3//@compile-flags: --crate-type=lib
4
5#![feature(generic_const_exprs)]
6fn foo<'a, T: 'a>(_: [(); std::mem::offset_of!((T,), 0)]) {}
tests/crashes/129444.rs created+15
......@@ -0,0 +1,15 @@
1//@ known-bug: rust-lang/rust#129444
2
3//@ compile-flags: -Znext-solver=coherence
4
5trait Trait {
6 type Assoc;
7}
8
9struct W<T: Trait>(*mut T);
10impl<T: ?Trait> Trait for W<W<W<T>>> {}
11
12trait NoOverlap {}
13impl<T: Trait<W<T>>> NoOverlap for T {}
14
15impl<T: Trait<Assoc = u32>> NoOverlap for W<T> {}
tests/crashes/129503.rs created+7
......@@ -0,0 +1,7 @@
1//@ known-bug: rust-lang/rust#129503
2
3use std::arch::asm;
4
5unsafe fn f6() {
6 asm!(concat!(r#"lJ𐏿Æ�.𐏿�"#, "r} {}"));
7}
tests/crashes/129556.rs created+26
......@@ -0,0 +1,26 @@
1//@ known-bug: rust-lang/rust#129556
2
3#![feature(adt_const_params)]
4#![feature(generic_const_exprs)]
5
6use core::marker::ConstParamTy;
7
8// #[derive(ConstParamTy, PartialEq, Eq)]
9// struct StructOrEnum;
10
11#[derive(ConstParamTy, PartialEq, Eq)]
12enum StructOrEnum {
13 A,
14}
15
16trait TraitParent<const SMTH: StructOrEnum = { StructOrEnum::A }> {}
17
18trait TraitChild<const SMTH: StructOrEnum = { StructOrEnum::A }>: TraitParent<SMTH> {}
19
20impl TraitParent for StructOrEnum {}
21
22// ICE occurs
23impl TraitChild for StructOrEnum {}
24
25// ICE does not occur
26// impl TraitChild<{ StructOrEnum::A }> for StructOrEnum {}
tests/run-make/print-cfg/rmake.rs+5
......@@ -5,6 +5,11 @@
55//!
66//! It also checks that some targets have the correct set cfgs.
77
8// ignore-tidy-linelength
9//@ needs-llvm-components: arm x86
10// Note: without the needs-llvm-components it will fail on LLVM built without the required
11// components listed above.
12
813use std::collections::HashSet;
914use std::iter::FromIterator;
1015use std::path::PathBuf;
tests/run-make/print-target-list/rmake.rs+9-4
......@@ -1,10 +1,15 @@
1// Checks that all the targets returned by `rustc --print target-list` are valid
2// target specifications
1// Checks that all the targets returned by `rustc --print target-list` are valid target
2// specifications.
3
4// ignore-tidy-linelength
5//@ needs-llvm-components: aarch64 arm avr bpf csky hexagon loongarch m68k mips msp430 nvptx powerpc riscv sparc systemz webassembly x86
6// FIXME(jieyouxu): there has to be a better way to do this, without the needs-llvm-components it
7// will fail on LLVM built without all of the components listed above.
38
49use run_make_support::bare_rustc;
510
6// FIXME(127877): certain experimental targets fail with creating a 'LLVM TargetMachine'
7// in CI, so we skip them
11// FIXME(#127877): certain experimental targets fail with creating a 'LLVM TargetMachine' in CI, so
12// we skip them.
813const EXPERIMENTAL_TARGETS: &[&str] = &["avr", "m68k", "csky", "xtensa"];
914
1015fn main() {
tests/run-make/print-to-output/rmake.rs+8-2
......@@ -1,5 +1,11 @@
1//! This checks the output of some `--print` options when
2//! output to a file (instead of stdout)
1//! This checks the output of some `--print` options when output to a file (instead of stdout)
2
3// ignore-tidy-linelength
4//@ needs-llvm-components: aarch64 arm avr bpf csky hexagon loongarch m68k mips msp430 nvptx powerpc riscv sparc systemz webassembly x86
5// FIXME(jieyouxu): there has to be a better way to do this, without the needs-llvm-components it
6// will fail on LLVM built without all of the components listed above. If adding a new target that
7// relies on a llvm component not listed above, it will need to be added to the required llvm
8// components above.
39
410use std::path::PathBuf;
511
tests/run-make/target-without-atomic-cas/rmake.rs+10-5
......@@ -1,8 +1,13 @@
1// ARM Cortex-M are a class of processors supported by the rust compiler. However,
2// they cannot support any atomic features, such as Arc. This test simply prints
3// the configuration details of one Cortex target, and checks that the compiler
4// does not falsely list atomic support.
5// See https://github.com/rust-lang/rust/pull/36874
1// ARM Cortex-M are a class of processors supported by the rust compiler. However, they cannot
2// support any atomic features, such as Arc. This test simply prints the configuration details of
3// one Cortex target, and checks that the compiler does not falsely list atomic support.
4// See <https://github.com/rust-lang/rust/pull/36874>.
5
6// ignore-tidy-linelength
7//@ needs-llvm-components: arm
8// Note: without the needs-llvm-components it will fail on LLVM built without all of the components
9// listed above. If any new targets are added, please double-check their respective llvm components
10// are specified above.
611
712use run_make_support::rustc;
813
tests/ui/consts/min_const_fn/min_const_fn_libstd_stability.stderr+2-2
......@@ -20,12 +20,12 @@ error: const-stable function cannot use `#[feature(const_refs_to_cell)]`
2020LL | x.get();
2121 | ^
2222 |
23help: if it is not part of the public API, make this function unstably const
23help: if the function is not (yet) meant to be stable, make this function unstably const
2424 |
2525LL + #[rustc_const_unstable(feature = "...", issue = "...")]
2626LL | const fn bar3() -> u32 {
2727 |
28help: otherwise `#[rustc_allow_const_fn_unstable]` can be used to bypass stability checks (but requires team approval)
28help: otherwise, as a last resort `#[rustc_allow_const_fn_unstable]` can be used to bypass stability checks (but requires team approval)
2929 |
3030LL + #[rustc_allow_const_fn_unstable(const_refs_to_cell)]
3131LL | const fn bar3() -> u32 {