-
-
Notifications
You must be signed in to change notification settings - Fork 153
fix(codegen): pin apple-m1 on Apple aarch64 instead of -mcpu=native #7352
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
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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,32 @@ | ||
| ### Windows: COFF section and PE lookup land; the walker is what is still missing | ||
|
|
||
| Two of the three pieces Windows needs are in, and the third is named rather | ||
| than glossed. | ||
|
|
||
| **The section.** COFF joins Mach-O and ELF as a first-class object format in | ||
| the map emitter. Its name is `.pgcmap`, not `.perry_gcmap`, and that is | ||
| load-bearing: a **PE image section header has an 8-byte name field**, and long | ||
| names survive only in object files as a string-table offset the linker does not | ||
| carry into the image. A 12-byte name would be truncated on the way in and the | ||
| runtime could never match it. | ||
|
|
||
| **The lookup.** The runtime can find that section in a running PE image — | ||
| `GetModuleHandleW(NULL)` gives the image base, which is also the | ||
| `IMAGE_DOS_HEADER`; the section table follows the optional header, whose size | ||
| the file header records rather than being fixed. | ||
|
|
||
| **The walker is missing, so Windows stays refused.** `_Unwind_*` does not exist | ||
| there, and the walker module is gated to Apple and Linux — on Windows it falls | ||
| to the stub, no frame is ever visited, and the collector would free live | ||
| objects. Emitting a map anyway would produce exactly the silent-lost-roots | ||
| failure this backend exists to make impossible, so the compiler refuses the | ||
| target with a message that says which piece is absent. | ||
|
|
||
| A walker there means either `RtlVirtualUnwind`, or an fp-chain walk (Perry | ||
| forces frame pointers, so RBP does chain) — and it wants a Windows host to | ||
| develop against, which is why this lands staged rather than half-enabled. | ||
|
|
||
| Verified: the PE lookup compiles for `x86_64-pc-windows-msvc` in isolation. The | ||
| full crate cannot be cross-checked from macOS because `psm`/`stacker` build | ||
| scripts need a C cross-compiler — the same blocker that stops local watchOS and | ||
| visionOS checks, unrelated to this code. CI's `windows-build` job covers it. |
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,28 @@ | ||
| ### Pin `apple-m1` instead of `-mcpu=native` on Apple aarch64 | ||
|
|
||
| `gc-native-roots` has never gone green — **0 successes in 40 runs** — and the | ||
| current cause is not a GC bug at all: | ||
|
|
||
| ``` | ||
| fatal error: error in backend: Cannot select: intrinsic %llvm.aarch64.fjcvtzs | ||
| ``` | ||
|
|
||
| `inprocess.rs` already documents the invariant this breaks. Codegen decides | ||
| whether to emit `llvm.aarch64.fjcvtzs` (FEAT_JSCVT, the single-instruction | ||
| ECMAScript `ToInt32`) **from the triple alone**, because clang's default CPU for | ||
| `arm64-apple-*` is `apple-m1`. Anything that then compiles that IR for a CPU | ||
| without the feature aborts. The doc calls out the generic-TargetMachine half of | ||
| that pair; `-mcpu=native` is the other half, and it fails the same way wherever | ||
| CPU detection disagrees with the triple assumption — which is exactly what a | ||
| virtualised macOS CI runner does. The identical command works on a physical Mac, | ||
| which is why this only ever failed in CI. | ||
|
|
||
| Apple aarch64 hosts now pass an explicit `-mcpu=apple-m1` rather than `native`, | ||
| making what Perry emits and what it targets the same decision instead of two | ||
| that happen to agree on developer hardware. Every other host keeps native | ||
| tuning. | ||
|
|
||
| Verified on hardware: `native_tuning_arg = -mcpu=apple-m1` in the recorded | ||
| compile plan, and all ten gc-ratchet probes still byte-match the pinned Node | ||
| oracle under `PERRY_RS4GC=1 PERRY_GC_FORCE_EVACUATE=1 | ||
| PERRY_GC_VERIFY_EVACUATION=1`. |
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
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.
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.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Test the production Windows refusal.
compact_and_assemble_refusalduplicates the predicate at Line 922. Production code never calls this helper. If the production COFF refusal is removed, this test still passes.Extract the target-refusal decision into a shared helper, or call
compact_and_assemblefrom this test and assert its error.Proposed test structure
📝 Committable suggestion
🤖 Prompt for AI Agents