-
Notifications
You must be signed in to change notification settings - Fork 12.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
driftsort implementation uses an out-of-range literal on 16-bit targets #129910
Comments
It's worse than one might think, because many AVR microarchitectures, including the atmega328 we nominally support, have only 2KiB of SRAM, which means that this line is literally impossible: // For small inputs 4KiB of stack storage suffices, which allows us to avoid
// calling the (de-)allocator. Benchmarks showed this was quite beneficial.
let mut stack_buf = AlignedStorage::<T, 4096>::new(); |
these targets should probably use some of the code in #129587 with perhaps a few more tweaks. |
Good to know, 16-bit wasn't something we had in mind during development, in terms of less standard targets, we did test big endian with miri. I agree with @workingjubilee the code in #129587 would be a better fit for such targets. What kind of tweaks did you have in mind? |
There are other places in driftsort and ipnsort that use stack arrays, e.g:
They are all size bound to <= 4KiB through various means, but still a poor fit for tiny chips. |
I think that's necessary, I don't believe driftsort could ever meaningfully run on machines this small. |
You already figured it out: dropping all the stack arrays to the absolute minimum. Note that you are not obligated to fix these targets, as usual. |
I think it should be a single additional |
Yeah, we'd get CI failures way too often if we errored on warnings for tier 3 targets. |
Related: #130818 |
Who is using Tier 3 targets in CI? |
Miri is, by running a test with We should probably change that. |
Rollup merge of rust-lang#130832 - RalfJung:sort-cfg-mess, r=workingjubilee fix some cfg logic around optimize_for_size and 16-bit targets Fixes rust-lang#130818. Fixes rust-lang#129910. There are still some warnings when building on a 16bit target: ``` warning: struct `AlignedStorage` is never constructed --> /home/r/src/rust/rustc.2/library/core/src/slice/sort/stable/mod.rs:135:8 | 135 | struct AlignedStorage<T, const N: usize> { | ^^^^^^^^^^^^^^ | = note: `#[warn(dead_code)]` on by default warning: associated items `new` and `as_uninit_slice_mut` are never used --> /home/r/src/rust/rustc.2/library/core/src/slice/sort/stable/mod.rs:141:8 | 140 | impl<T, const N: usize> AlignedStorage<T, N> { | -------------------------------------------- associated items in this implementation 141 | fn new() -> Self { | ^^^ ... 145 | fn as_uninit_slice_mut(&mut self) -> &mut [MaybeUninit<T>] { | ^^^^^^^^^^^^^^^^^^^ warning: function `quicksort` is never used --> /home/r/src/rust/rustc.2/library/core/src/slice/sort/unstable/quicksort.rs:19:15 | 19 | pub(crate) fn quicksort<'a, T, F>( | ^^^^^^^^^ warning: `core` (lib) generated 3 warnings ``` However, the cfg stuff here is sufficiently messy that I didn't want to touch more of it. I think all `feature = "optimize_for_size"` should become `any(feature = "optimize_for_size", target_pointer_width = "16")` but I am not entirely certain. Warnings are fine, Miri will just ignore them. Cc `@Voultapher`
Thinking a bit more about it, is there any scenario where you'd compile Rust for 16-bit targets and don't want to use |
Run
Or
And you'll get this diagnostic (cargo miri setup makes it a warning, lol):
I don't know what effect this has at runtime but it can't be good.
The text was updated successfully, but these errors were encountered: