-
Notifications
You must be signed in to change notification settings - Fork 1
Let the guest's memcpy use unaligned word loads #980
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
Open
jotabulacios
wants to merge
4
commits into
main
Choose a base branch
from
perf/guest-unaligned-memcpy
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
1a64d6e
Let the guest's memcpy use unaligned word loads
jotabulacios 7157b47
Merge branch 'main' into perf/guest-unaligned-memcpy
jotabulacios 6b479e8
Hash the guest cargo config in the ELF cache keys
jotabulacios d97faba
Note the cfg's reach and its nightly pin
jotabulacios File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| # Guest-only build flags: the key is scoped to the guest target, so host builds | ||
| # read this file and take nothing from it. Cargo joins `rustflags` across | ||
| # ancestor configs, so each guest crate keeps its own flags and gains this one. | ||
| [target.riscv64im-lambda-vm-elf] | ||
| # `compiler_builtins` turns `mem-unaligned` on for x86, aarch64 and bpf only, so | ||
| # on RISC-V `memcpy`/`memmove` reassemble every misaligned word by hand; this VM | ||
| # does unaligned scalar accesses natively (#864). The cfg reaches every crate in | ||
| # the guest graph, but only `compiler-builtins` reads that name, and it declares | ||
| # the value in its own check-cfg. It lives in that crate's `build.rs` with no | ||
| # stability guarantee: bumping the `nightly-2026-02-01` pin in the Makefile can | ||
| # turn this into a silent no-op. | ||
| rustflags = ["--cfg", "feature=\"mem-unaligned\""] | ||
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
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Low — worth one more sentence in the comment: this sets the cfg for every crate in the guest graph, and it can silently become a no-op.
Two things the comment doesn't say:
--cfg feature="mem-unaligned"is not scoped tocompiler_builtins— it's set on every crate compiled for this target (core/alloc/std,libc, and all of the ethrex guest's third-party deps). Today onlycompiler-builtinsreads that name, so it's harmless, but if some dep ever declares a feature by that name it gets enabled without Cargo activating its dependencies. Also, since the cfg is unexpected for every crate that doesn't declare it, expectunexpected_cfgswarnings across the guest graph; pairing it with"--check-cfg", "cfg(feature, values(\"mem-unaligned\"))"in the same array unions the value into the expected set and keeps the build output clean.Nothing fails loudly if the flag stops taking effect, and the failure mode is the 8% cycle regression coming back with a green build. Three ways that happens: the pinned
nightly-2026-02-01sysroot'scompiler-builtinsrenames/drops the knob (it's build.rs-internal, no stability guarantee — worth naming the nightly pin inMakefileas the coupling);RUSTFLAGS/CARGO_ENCODED_RUSTFLAGSis set in the environment, which replacestarget.<triple>.rustflagsrather than joining with it (unlike the ancestor-config joining the comment describes); or a guest is ever built from a cwd outside this repo tree.