-
Notifications
You must be signed in to change notification settings - Fork 1.6k
A round of Mac M1 fixes #3274
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
A round of Mac M1 fixes #3274
Conversation
crates/cranelift/src/compiler.rs
Outdated
| pub(crate) const CODE_SECTION_ALIGNMENT: u64 = 0x4000; | ||
|
|
||
| #[cfg(not(all(target_os = "macos", target_arch = "aarch64")))] | ||
| pub(crate) const CODE_SECTION_ALIGNMENT: u64 = 0x1000; |
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.
At least on macOS you have to query the page size at runtime. This is for example necessary for Rosetta 2 to work as it uses AArch64 sized pages. There may be other cases where it isn't possible to know this at compile time. You can use region::page::size() to query it.
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.
TIL! @alexcrichton in this case, would it be just simpler to call region::page::size() (maybe cache it, if we expect this to be expensive) instead of having the raw constants scattered in the code?
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.
I think a better fix for this would be to inspect self.isa.target() to accomodate cross-compiling use cases. If the section is over-aligned for some embeddings that's not an issue.
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.
Good point, fixed!
|
Seems that CI is running |
alexcrichton
left a comment
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.
Wasmtime bits look good to me, but someon else may wish to confirm the cranelift changes. Seems like updating rustc for that check is fine to me as well, yeah.
Firefox has updated its toolchain to something much more recent.
| - run: cargo check --target wasm32-unknown-emscripten -p wasi-common | ||
| - run: cargo check --target armv7-unknown-linux-gnueabihf -p wasi-common | ||
|
|
||
| # Check that codegen and wasm crates typecheck on 1.43.0; this is required |
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.
Maybe just bump it to a newer version instead of removing it completely?
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.
I was under the impression that Firefox is now following latest stable, so that cargo check step ought to be unnecessary. Plus, unclear whether Cranelift is still being updated from this particular repository or Mozilla's fork. I'll check in with the Mozilla folks, it'd be easy to add back later, if necessary.
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.
Yury from Mozilla confirmed on Matrix mozilla-central is using stable, so we should be good here!
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.
Aren't they updating like one week after a new rust version releases?
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.
It might be, but Cranelift in Firefox seems to receive updates at a lesser frequency (which makes sense for their stability guarantees, and considering the Cranelift bug has been resolved as inactive). Last update was 3 months ago.
cfallin
left a comment
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.
LGTM on Cranelift/ABI bits as well -- thanks!
|
@alexcrichton @bnjbvr I have just seen this:
Is there any specific reason to push the registers in that order? The Procedure Call Standard actually specifies the reverse:
|
No, no particular reasons. One could easily get confused with the push order in |
|
Perhaps that is partially the cause of the issue with libunwind? I.e. maybe the unwinder has been changed to have stricter frame record layout expectations (in the presence of incorrect CFI information)? |
No: the change in this PR was sufficient to make the test pass, and it wouldn't have been the case if the unwinder had very precise frame record layout expectations. That being said, I'm all in favor of using the most conforming push order :-) |
|
Nah there is no reason to push the registers in that order, only that I'd never written arm64 assembly before when I wrote this. I think it would be best to follow arm64 conventions and standards though! |
Three commits that make the Mac M1 pass all the tests run in CI:
stp lr, fp, [sp, -16]!, so FP was at CFA - 0x8, not CFA - 0x60. Unclear why it did work in the first place, and why it stopped working at some point; likely that something in Apple's libunwind has changed in the meanwhile.gen_prologue_frame_setup, so there's a new functiongen_debug_frame_infothat's defaulting to doing nothing, and implemented on aarch64 and disabling pointer auth. This function is called independently from the fact that the function requires a prologue/epilogue, so we can put the unwind instruction that will generate the CFI directive in there. cc @cfallin @akirilov-arm for this changeFixes #3256.