Repository navigation
rust: bindgen: make sched_statistics opaque - #992
Merged
Merged
Conversation
With CONFIG_SCHEDSTATS=n, struct sched_statistics is an empty
____cacheline_aligned struct. bindgen 0.73.2 drops the alignment of a
zero-sized non-opaque struct and emits `pub struct sched_statistics {}`
with alignment 1. Rust then puts task_struct::stats at offset 792 where C
has 832, and later fields, including mm, move with it.
Commit 7b563df ("rust: require checked binding layouts for every
kernel build") made the layout assertions mandatory, so a build with
stock bindgen stops with E0080. Trees that pass --no-layout-tests still
build, with the wrong offsets.
Declare the type opaque. bindgen takes an opaque type's layout from Clang,
so stock bindgen emits #[repr(align(64))] and the assertions pass without
preparing tools/aurora-bindgen. The C layout does not change and no Rust
code reads these fields.
Update the documentation and the rust_is_available.sh warning, which said
default Asahi builds fail on this type.
Signed-off-by: Diljit Singh <[email protected]>
Signed-off-by: Diljit Singh <[email protected]>
DjDeveloperr
added a commit
that referenced
this pull request
Nov 6, 2026
Picks up the bindgen fix (#992), without which the asahi profile does not build. Signed-off-by: Diljit Singh <[email protected]>
RyanTheTide
added a commit
that referenced
this pull request
Nov 6, 2026
Keep linux#922 current with integration/aurora (#992 rust bindgen layout) for the speakerguardd v2 cutover (option A). Signed-off-by: Ryan Murray <[email protected]> Assisted-by: LLM
This was referenced Nov 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Builds with stock bindgen 0.73.2 stop in
rust/bindings.oandrust/uapi.owith two E0080 layout errors:align_of::<sched_statistics>()offset_of!(task_struct, stats)Cause
No recent struct change caused this. With
CONFIG_SCHEDSTATS=n,struct sched_statisticsis empty and____cacheline_aligned. bindgen drops the alignment of a zero-sized non-opaque struct and emitspub struct sched_statistics {}.The omacom tree (30a6518) passes
--no-layout-testsby default, so a mismatch like this has nothing to catch it there. 7b563df made the assertions mandatory here, which turned the hidden mismatch into a build error.tools/aurora-bindgenalso repairs this, but someone has to prepare it by hand. Without it, Kbuild falls back tobindgenon PATH.Fix
Add
--opaque-type sched_statisticstorust/bindgen_parameters. bindgen takes an opaque type's layout from Clang, so stock 0.73.2 emits#[repr(align(64))]. The C layout doesn't change, every assertion stays on, and no Rust code reads these fields.task_structhas a single assertion block and const evaluation stops at its first failure, sostatspassing also lets the checks on all later fields run. None of them fail.I also corrected the doc and the
rust_is_available.shwarning, which said default Asahi builds fail on this type. The warning itself stays, since other aligned empty structs can still hit the bindgen bug.Validation
Both runs used integration/aurora 11eccbe, the asahi profile and the build VM's stock bindgen 0.73.2 with
make -k rust/bindings.o rust/uapi.o. Kbuild'spreparealso buildsrust/kernel.o.Without the fix,
./linux-build/buildexits 1. Both objects fail with the same two errors, and both generated files havepub struct sched_statistics {}:With the fix, in the same output directory, it exits 0.
rust/bindings.o,rust/uapi.oandrust/kernel.oall build, with no E0080 across 26169 assertion lines inbindings_generated.rsand 13361 inuapi_generated.rs. The generated struct is now#[repr(C)] #[repr(align(64))] pub struct sched_statistics. The VM's post-build check passed, and a separatebuild verifyreportedchecked 113373 files in 504 packages; 0 bad.This branch now merges 11eccbe. Its tree, 6ae17468d9e, is the tree I tested with the fix.
scripts/rust_is_available_test.pypasses all 35 tests.I didn't rebuild
Image moduleson this base. Three from-scratch asahiImage modulesbuilds on the earlier base (2661d71) ranmaketo completion with no E0080, includingasahi_core.oandaurora.ko, but all three failed the VM's post-build check on corrupted guest memory (24, 31 and 408 bad package files). Treat those three as evidence that the code compiled and don't use them as artifacts.Nothing has been boot-tested. The change only affects the build.
🤖 Generated with Claude Code