diff --git a/.cargo/config.toml b/.cargo/config.toml index cc6aa0da9..028399c71 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -8,3 +8,16 @@ xtask = "run --package xtask --" # archive `cargo xtask dist` links whole (`ld -r -force_load`) registers jemalloc as the first # malloc zone of every host that links it, ahead of the system's. enable_zone_allocator = "no" + +# rustc's parallel front end on every compile, with as many threads as the host has cores +# (`-Zthreads=0`), through Cargo's profile rustflags, which add to `RUSTFLAGS` rather than give way +# to it. `test`, `debugging` and `checked` inherit it from `dev` and `release`. The toolchain is +# nightly for this (rust-toolchain.toml). +[unstable] +profile-rustflags = true + +[profile.dev] +rustflags = ["-Zthreads=0"] + +[profile.release] +rustflags = ["-Zthreads=0"] diff --git a/README.md b/README.md index bb74db233..16d3800d1 100644 --- a/README.md +++ b/README.md @@ -247,8 +247,8 @@ the following. - An Apple silicon Mac. Every Rust binary is arm64 (`aarch64-apple-darwin`): rustc's arm64e target has no pointer authentication, and its binaries crash before `main` (`rust-toolchain.toml`). -- The toolchain `rust-toolchain.toml` pins: stable 1.98.1 with rustfmt and clippy. rustup installs - it on first use. +- The toolchain `rust-toolchain.toml` pins: nightly-2026-11-03 with rustfmt and clippy, for rustc's + parallel front end (`-Zthreads`, in `.cargo/config.toml`). rustup installs it on first use. - `cargo-nextest`, which runs the tests in `cargo xtask check` (`cargo install --locked cargo-nextest`). - cbindgen 0.29.4, for `cargo xtask header` (`cargo install --locked cbindgen --version 0.29.4`). diff --git a/crates/reims-vgpu-core/src/iosurface/regs.rs b/crates/reims-vgpu-core/src/iosurface/regs.rs index 6f8b4b55a..8d639eab9 100644 --- a/crates/reims-vgpu-core/src/iosurface/regs.rs +++ b/crates/reims-vgpu-core/src/iosurface/regs.rs @@ -358,7 +358,7 @@ mod tests { assert!(second_form_holds_every_id(0x4000)); assert!(!second_form_holds_every_id(0x1000)); assert_eq!( - (0x1000 / TABLE_ENTRY_SIZE) * (0x1000 / Form::First.size().get()), + (0x1000 / TABLE_ENTRY_SIZE) * (0x1000 / Form::First.size()), MAPPING_ID_COUNT ); } diff --git a/crates/reims-vgpu-core/src/memory/dirty.rs b/crates/reims-vgpu-core/src/memory/dirty.rs index f62169d4c..04fc0480b 100644 --- a/crates/reims-vgpu-core/src/memory/dirty.rs +++ b/crates/reims-vgpu-core/src/memory/dirty.rs @@ -413,8 +413,7 @@ impl DirtyLog { /// Ends one [`DirtyLog::close`]. pub fn reopen(&self) { let _s = self.state.lock(); - let _ = - (self.closed).fetch_update(Ordering::SeqCst, Ordering::SeqCst, |c| c.checked_sub(1)); + let _ = (self.closed).try_update(Ordering::SeqCst, Ordering::SeqCst, |c| c.checked_sub(1)); } /// Closes the log for good and drops the host's hook: once this returns, the hook is never diff --git a/crates/reims-vgpu-core/src/testkit/death.rs b/crates/reims-vgpu-core/src/testkit/death.rs index d77de386b..338612fe2 100644 --- a/crates/reims-vgpu-core/src/testkit/death.rs +++ b/crates/reims-vgpu-core/src/testkit/death.rs @@ -1629,11 +1629,7 @@ mod tests { |r| { let h = r.assert_hung_at("sleeping an hour"); assert_eq!(h.thread.name(), Some("hang-body")); - assert!( - r.records() - .iter() - .any(|x| x.kind == RecordKind::Advanced) - ); + assert!(r.records().iter().any(|x| x.kind == RecordKind::Advanced)); } ); @@ -1844,7 +1840,10 @@ mod tests { another_threads_op_after_the_death_is_not_the_deaths, options = DYING_THREAD, |t| { - let (go, done) = (Arc::new(AtomicBool::new(false)), Arc::new(AtomicBool::new(false))); + let (go, done) = ( + Arc::new(AtomicBool::new(false)), + Arc::new(AtomicBool::new(false)), + ); let (go2, done2) = (go.clone(), done.clone()); named("other", move || { while !go2.load(Ordering::Acquire) { @@ -1924,7 +1923,10 @@ mod tests { /// the op that preceded it, not at the worker's stale op a_death_on_a_reused_worker_is_at_the_op_before_it, |t| { - let q = crate::rt::queue::SerialQueue::new(&crate::testkit::threads::FakeThreads::default(), "A"); + let q = crate::rt::queue::SerialQueue::new( + &crate::testkit::threads::FakeThreads::default(), + "A", + ); let done = Arc::new(AtomicBool::new(false)); let d2 = done.clone(); q.exec_async(move || { @@ -1934,7 +1936,9 @@ mod tests { // The worker ran the first block and waits for the next. wait_until(|| done.load(Ordering::Acquire)); t.op("body: submit C"); - q.exec_async(|| crate::testkit::capture::die(crate::raise::death::DeathKind::Abort, "site_t")); + q.exec_async(|| { + crate::testkit::capture::die(crate::raise::death::DeathKind::Abort, "site_t") + }); park_forever() }, |r| { @@ -1942,7 +1946,10 @@ mod tests { assert!(!d.thread.body, "{d:?}"); // The reused worker's own last op is A's finished block. let tid = d.thread.tid; - assert_eq!(r.last_op_before_end(|t| t.tid == tid), Some("A: block done")); + assert_eq!( + r.last_op_before_end(|t| t.tid == tid), + Some("A: block done") + ); assert_eq!(r.ops(), ["A: block done", "body: submit C"]); } ); @@ -1975,7 +1982,9 @@ mod tests { go.store(true, Ordering::Release); wait_until(|| finished.load(Ordering::Acquire) == 2); t.op("body: submit C"); - qa.exec_async(|| crate::testkit::capture::die(crate::raise::death::DeathKind::Abort, "site_t")); + qa.exec_async(|| { + crate::testkit::capture::die(crate::raise::death::DeathKind::Abort, "site_t") + }); park_forever() }, |r| { @@ -2081,7 +2090,11 @@ mod tests { assert!(d.thread.body, "{d:?}"); assert_eq!(d.op.as_deref(), Some("recursing")); assert_eq!(d.id, None); - assert!(r.stderr().contains("overflowed its stack"), "{}", r.stderr()); + assert!( + r.stderr().contains("overflowed its stack"), + "{}", + r.stderr() + ); // std's line is one death's, and one death alone did not race. assert!(!d.raced, "{d:?}"); assert_eq!(d.abort_lines.len(), 1, "{d:?}"); @@ -2151,7 +2164,10 @@ mod tests { #[should_panic(expected = "expected a death")] a_death_deferred_past_the_call_fails, |t| { - let q = crate::rt::queue::SerialQueue::new(&crate::testkit::threads::FakeThreads::default(), "Q"); + let q = crate::rt::queue::SerialQueue::new( + &crate::testkit::threads::FakeThreads::default(), + "Q", + ); t.op("body: calling"); trace("api: called"); q.exec_async(|| { @@ -2260,7 +2276,9 @@ mod tests { two_death_lines_are_not_paired, |_| { printed_not_marked("a", "site_a", 0); - named("b", || crate::testkit::capture::die(crate::raise::death::DeathKind::Abort, "site_b")); + named("b", || { + crate::testkit::capture::die(crate::raise::death::DeathKind::Abort, "site_b") + }); park_forever() }, |r| { @@ -2314,7 +2332,9 @@ mod tests { park_forever() }); wait_until(|| marked.load(Ordering::Acquire)); - named("b", || crate::testkit::capture::die(crate::raise::death::DeathKind::Abort, "site_b")); + named("b", || { + crate::testkit::capture::die(crate::raise::death::DeathKind::Abort, "site_b") + }); park_forever() }, |r| { @@ -2421,7 +2441,11 @@ mod tests { crate::testkit::capture::die(crate::raise::death::DeathKind::Abort, "site_t") }); t.op("body: checking"); - assert_eq!(std::hint::black_box(1 + 1), 3, "the body's own check failed"); + assert_eq!( + std::hint::black_box(1 + 1), + 3, + "the body's own check failed" + ); }, |r| { let _ = r.assert_died_at(SITE, "body: checking"); @@ -2505,7 +2529,7 @@ mod tests { a_death_line_beside_a_std_abort_is_not_paired, |_| { printed_not_marked("a", "site_a", 0); - named("b", || a_panic_in_a_trampoline()); + named("b", a_panic_in_a_trampoline); park_forever() }, |r| check_a_beside_another_abort(r, "panic. aborting.") @@ -2561,7 +2585,10 @@ mod tests { assert!(!d.raced, "{d:?}"); assert_eq!((d.id.as_ref(), d.ids.len()), (None, 0), "{d:?}"); assert_eq!(d.abort_lines.len(), 1, "{d:?}"); - assert!(d.abort_lines[0].contains("reims-vgpu: panicked at "), "{d:?}"); + assert!( + d.abort_lines[0].contains("reims-vgpu: panicked at "), + "{d:?}" + ); assert_eq!(d.thread.name(), Some("b")); assert_eq!(d.op.as_deref(), Some("body: calling")); } diff --git a/crates/reims-vgpu-metal/src/gpu/desc.rs b/crates/reims-vgpu-metal/src/gpu/desc.rs index 669205ad5..3a66635b8 100644 --- a/crates/reims-vgpu-metal/src/gpu/desc.rs +++ b/crates/reims-vgpu-metal/src/gpu/desc.rs @@ -949,7 +949,9 @@ macro_rules! apply_attachment { apply_attachment!( /// A colour attachment's set; its own: the clear colour. - apply_color_attachment(ColorAttachmentSet, MetalRenderPassColorAttachment) |set, o| { + apply_color_attachment(ColorAttachmentSet, MetalRenderPassColorAttachment) + | set, + o | { if let Some(v) = set.clear_color { let v = v.mtl(); msg::get("setClearColor:", || o.setClearColor(v)); @@ -959,30 +961,30 @@ apply_attachment!( apply_attachment!( /// The depth attachment's set; its own: the clear depth, then the resolve filter. - apply_depth_attachment(DepthAttachmentSet, MetalRenderPassDepthAttachment) |set, o| { + apply_depth_attachment(DepthAttachmentSet, MetalRenderPassDepthAttachment) + | set, + o | { if let Some(v) = set.clear_depth { msg::get("setClearDepth:", || o.setClearDepth(v)); } if let Some(v) = set.depth_resolve_filter { let v = MTLMultisampleDepthResolveFilter(v.to_usize()); - msg::get("setDepthResolveFilter:", || { - o.setDepthResolveFilter(v) - }); + msg::get("setDepthResolveFilter:", || o.setDepthResolveFilter(v)); } } ); apply_attachment!( /// The stencil attachment's set; its own: the clear stencil, then the resolve filter. - apply_stencil_attachment(StencilAttachmentSet, MetalRenderPassStencilAttachment) |set, o| { + apply_stencil_attachment(StencilAttachmentSet, MetalRenderPassStencilAttachment) + | set, + o | { if let Some(v) = set.clear_stencil { msg::get("setClearStencil:", || o.setClearStencil(v)); } if let Some(v) = set.stencil_resolve_filter { let v = MTLMultisampleStencilResolveFilter(v.to_usize()); - msg::get("setStencilResolveFilter:", || { - o.setStencilResolveFilter(v) - }); + msg::get("setStencilResolveFilter:", || o.setStencilResolveFilter(v)); } } ); diff --git a/crates/reims-vgpu-metal/src/platform.rs b/crates/reims-vgpu-metal/src/platform.rs index 63a03b384..06abc7148 100644 --- a/crates/reims-vgpu-metal/src/platform.rs +++ b/crates/reims-vgpu-metal/src/platform.rs @@ -361,7 +361,7 @@ impl Platform for MetalPlatform { /// The device of `MTLCopyAllDevices()` whose `registryID` is `registry_id` (+1), or `None`. /// In one process it is the instance the host's own device is. fn open_device(&self, registry_id: u64) -> Option { - let all = msg::fatal_send("MTLCopyAllDevices()", || objc2_metal::MTLCopyAllDevices()); + let all = msg::fatal_send("MTLCopyAllDevices()", objc2_metal::MTLCopyAllDevices); let count = msg::value("count", || all.count()); (0..count) .map(|i| msg::value("objectAtIndex:", || all.objectAtIndex(i))) diff --git a/crates/reims-vgpu-video-codec/src/hevc/tests.rs b/crates/reims-vgpu-video-codec/src/hevc/tests.rs index 57a52e41d..63e11c84e 100644 --- a/crates/reims-vgpu-video-codec/src/hevc/tests.rs +++ b/crates/reims-vgpu-video-codec/src/hevc/tests.rs @@ -489,9 +489,9 @@ fn slice(sps: &SpsSpec, pps: &PpsSpec, spec: &SliceSpec) -> Vec { .unwrap_or((pps.l0_default_minus1, pps.l1_default_minus1)); if pps.lists_modification && total_curr > 1 { let bits = 32 - (total_curr - 1).leading_zeros(); - for list in 0..if b { 2 } else { 1 } { - w.bit(spec.list_entries[list].is_some()); - for &entry in spec.list_entries[list].iter().flatten() { + for entries in &spec.list_entries[..if b { 2 } else { 1 }] { + w.bit(entries.is_some()); + for &entry in entries.iter().flatten() { w.u(bits, entry); } } diff --git a/crates/reims-vgpu-video-core/src/host/decoder.rs b/crates/reims-vgpu-video-core/src/host/decoder.rs index 31ba3f5e4..f3eeb3223 100644 --- a/crates/reims-vgpu-video-core/src/host/decoder.rs +++ b/crates/reims-vgpu-video-core/src/host/decoder.rs @@ -646,7 +646,7 @@ impl Worker { fn take_up_frame(&self) { let _ = self .frames_queued - .fetch_update(Ordering::AcqRel, Ordering::Acquire, |queued| { + .try_update(Ordering::AcqRel, Ordering::Acquire, |queued| { queued.checked_sub(1) }); } diff --git a/crates/reims-vgpu-video-core/src/host/guest_bounds.rs b/crates/reims-vgpu-video-core/src/host/guest_bounds.rs index dc2cfe2bb..8d82c56a3 100644 --- a/crates/reims-vgpu-video-core/src/host/guest_bounds.rs +++ b/crates/reims-vgpu-video-core/src/host/guest_bounds.rs @@ -104,7 +104,7 @@ impl HeldMessages { fn take(&self, bytes: usize) -> bool { let charge = |counter: &AtomicUsize, amount: usize, limit: usize| { counter - .fetch_update(Ordering::AcqRel, Ordering::Acquire, |held| { + .try_update(Ordering::AcqRel, Ordering::Acquire, |held| { held.checked_add(amount).filter(|&total| total <= limit) }) .is_ok() diff --git a/crates/reims-vgpu-video-core/tests/fuzz/support.rs b/crates/reims-vgpu-video-core/tests/fuzz/support.rs index c73c7c58c..de607c521 100644 --- a/crates/reims-vgpu-video-core/tests/fuzz/support.rs +++ b/crates/reims-vgpu-video-core/tests/fuzz/support.rs @@ -376,7 +376,7 @@ fn install_abort_report() {} #[cfg(unix)] extern "C" fn report_abort(_: i32) { unsafe extern "C" { - fn write(fd: i32, bytes: *const u8, count: usize) -> isize; + fn write(fd: std::ffi::c_int, bytes: *const std::ffi::c_void, count: usize) -> isize; } let name = CASE_NAME.load(Ordering::SeqCst); // SAFETY: null, or a name `run` leaked, which lives for ever. @@ -395,7 +395,7 @@ extern "C" fn report_abort(_: i32) { let end = usize::try_from(cursor.position()).unwrap_or(0); // SAFETY: `end` bytes of `line` are initialised. unsafe { - write(2, line.as_ptr(), end); + write(2, line.as_ptr().cast(), end); } } diff --git a/crates/reims-vgpu-vulkan/src/answer/native.rs b/crates/reims-vgpu-vulkan/src/answer/native.rs index 0b1028200..c837b89bf 100644 --- a/crates/reims-vgpu-vulkan/src/answer/native.rs +++ b/crates/reims-vgpu-vulkan/src/answer/native.rs @@ -475,7 +475,7 @@ fn placement_in(state: u8) -> Placement { pub fn device_made(properties: &rt::DeviceProperties) { super::census::on(); let class = class_of(properties.description.driver_id); - let _ = STATE.fetch_update(Ordering::AcqRel, Ordering::Acquire, |s| { + let _ = STATE.try_update(Ordering::AcqRel, Ordering::Acquire, |s| { Some(after(s, class)) }); } diff --git a/crates/reims-vgpu-vulkan/src/gpu/predication.rs b/crates/reims-vgpu-vulkan/src/gpu/predication.rs index 207d5dfd4..6be464df7 100644 --- a/crates/reims-vgpu-vulkan/src/gpu/predication.rs +++ b/crates/reims-vgpu-vulkan/src/gpu/predication.rs @@ -3306,7 +3306,15 @@ mod tests { let c = shared(64); let cb = command_buffer(); let e = compute(&cb); - encode_all(&e, [set(&inc), bind(&[Some(&c)], &[0]), start_while(&c, 0, 1, 1000), one()]); + encode_all( + &e, + [ + set(&inc), + bind(&[Some(&c)], &[0]), + start_while(&c, 0, 1, 1000), + one(), + ], + ); e.encode_end_while().unwrap(); e.encode(OnFault::Return, ComputeCmd::EndEncoding).unwrap(); cb.commit(OnFault::Return).unwrap(); diff --git a/crates/reims-vgpu-vulkan/tests/client_direction.rs b/crates/reims-vgpu-vulkan/tests/client_direction.rs index b981653cd..581ed10d7 100644 --- a/crates/reims-vgpu-vulkan/tests/client_direction.rs +++ b/crates/reims-vgpu-vulkan/tests/client_direction.rs @@ -20,7 +20,11 @@ //! surface's own, and Metal's write ends the process with a bus error, where this crate's platform //! dies at the call. -#![cfg(target_os = "macos")] // Compares with Metal, which is macOS's. +#![cfg(target_os = "macos")] +// Compares with Metal, which is macOS's. +// The proof that a command buffer's result is well-formed walks the runtime's types for `Send` and +// `Sync`, deeper than rustc's default limit of 128, as in the library (`src/lib.rs`). +#![recursion_limit = "256"] #![allow( clippy::unwrap_used, clippy::indexing_slicing, diff --git a/crates/reims-vgpu-vulkan/tests/no_copy_remap.rs b/crates/reims-vgpu-vulkan/tests/no_copy_remap.rs index f2ae98447..e7b2480ce 100644 --- a/crates/reims-vgpu-vulkan/tests/no_copy_remap.rs +++ b/crates/reims-vgpu-vulkan/tests/no_copy_remap.rs @@ -14,7 +14,11 @@ //! too. A no-copy buffer's deallocator may call the platform's Mach VM, which tells the runtime, //! whichever thread releases the buffer. -#![cfg(target_os = "macos")] // Compares with Metal, which is macOS's. +#![cfg(target_os = "macos")] +// Compares with Metal, which is macOS's. +// The proof that a command buffer's result is well-formed walks the runtime's types for `Send` and +// `Sync`, deeper than rustc's default limit of 128, as in the library (`src/lib.rs`). +#![recursion_limit = "256"] #![allow( clippy::unwrap_used, clippy::indexing_slicing, diff --git a/crates/reims-vgpu-vulkan/tests/no_copy_remap_linux.rs b/crates/reims-vgpu-vulkan/tests/no_copy_remap_linux.rs index 0a2c367ef..5d1568e9d 100644 --- a/crates/reims-vgpu-vulkan/tests/no_copy_remap_linux.rs +++ b/crates/reims-vgpu-vulkan/tests/no_copy_remap_linux.rs @@ -37,6 +37,9 @@ //! told of are made through the OS's VM alone (`os::OsVm`), which reports nothing. #![cfg(target_os = "linux")] +// The proof that a command buffer's result is well-formed walks the runtime's types for `Send` and +// `Sync`, deeper than rustc's default limit of 128, as in the library (`src/lib.rs`). +#![recursion_limit = "256"] #![allow( clippy::unwrap_used, clippy::indexing_slicing, diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 4a2d72525..5aaa16d47 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,13 +1,17 @@ -# Pinned stable (architecture 2.1), measured with objc2 0.6.4. D32: the Metal platform is -# aarch64-apple-darwin alone; the Vulkan platform builds for aarch64 and x86-64, on macOS and -# Linux, and x86_64-unknown-linux-gnu is what ships on Linux (built there, type-checked from the -# Mac by `cargo xtask check`). x86_64-apple-darwin runs core's tests under Rosetta, with the x86-64 -# guest's pages and instructions, on a Mac that has Rosetta (check skips them on one without). +# A dated nightly, for rustc's parallel front end (`-Zthreads`, set in `.cargo/config.toml` through +# Cargo's profile rustflags), the toolchain metal2vulkan's builds use too. The date is fixed so +# every host runs one rustc, clippy and rustfmt; moving it is a deliberate step, with a full check. +# The crates' `rust-version` (Cargo.toml) stays the stable floor clippy's `incompatible_msrv` checks +# the standard library's items against. D32: the Metal platform is aarch64-apple-darwin alone; the +# Vulkan platform builds for aarch64 and x86-64, on macOS and Linux, and x86_64-unknown-linux-gnu is +# what ships on Linux (built there, type-checked from the Mac by `cargo xtask check`). +# x86_64-apple-darwin runs core's tests under Rosetta, with the x86-64 guest's pages and +# instructions, on a Mac that has Rosetta (check skips them on one without). # No Rust binary is arm64e: rustc's arm64e-apple-darwin target has no pointer authentication, and # its binaries, a hello world among them, crash in dyld's `_tlv_get_addr` before `main` (measured # 2026-09-25 with nightly-2026-09-24 on macOS 26.7). An arm64 binary still links and calls arm64e # code, as it calls the system's frameworks, and arm64e code calls its callbacks. [toolchain] -channel = "1.98.1" +channel = "nightly-2026-11-03" components = ["rustfmt", "clippy"] targets = ["aarch64-apple-darwin", "x86_64-unknown-linux-gnu", "x86_64-apple-darwin"]