Repository navigation
fix(native): select the preferred universal slice for metadata readers #9793
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
chordpli
wants to merge
5
commits into
morluto:main
Choose a base branch
from
chordpli:fix/macho-slice-preference
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.
+318
−75
Open
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
c8e9cc0
fix(native): select the preferred universal slice for metadata readers
chordpli 42baa43
docs(native): describe preferred slice selection for universal Mach-O…
chordpli 5723134
fix(native): report unread same-family slices as a limitation
chordpli 77b203d
docs(native): name the canonical x86 subtype preference
chordpli ad4d339
docs(native): refuse only a duplicated preferred slice subtype
chordpli 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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| import { describe, expect, it } from "vitest"; | ||
|
|
||
| import { selectPreferredMachoSlice } from "./MachoArchitectureSelection.js"; | ||
|
|
||
| const CPU_ARM = 12; | ||
| const CPU_X86_64 = 0x01000007; | ||
| const CPU_ARM64 = 0x0100000c; | ||
| const slice = (index: number, cpuType: number, cpuSubtype: number) => ({ | ||
| index, | ||
| cpuType, | ||
| cpuSubtype, | ||
| }); | ||
|
|
||
| describe("selectPreferredMachoSlice", () => { | ||
| it("prefers listed subtypes over FAT table order", () => { | ||
| const x86 = [slice(0, CPU_X86_64, 8), slice(1, CPU_X86_64, 3)]; | ||
| expect(selectPreferredMachoSlice(x86, "x86_64")).toEqual({ | ||
| status: "selected", | ||
| slice: x86[1], | ||
| }); | ||
| const arm64 = [slice(0, CPU_ARM64, 0x80000002), slice(1, CPU_ARM64, 0)]; | ||
| expect(selectPreferredMachoSlice(arm64, "arm64")).toEqual({ | ||
| status: "selected", | ||
| slice: arm64[1], | ||
| }); | ||
| }); | ||
|
|
||
| it("keeps FAT table order among subtypes with no listed preference", () => { | ||
| // armv7s (11) before armv7 (9): the arm policy lists no subtype order. | ||
| const arm = [slice(0, CPU_ARM, 11), slice(1, CPU_ARM, 9)]; | ||
| expect(selectPreferredMachoSlice(arm, "arm")).toEqual({ | ||
| status: "selected", | ||
| slice: arm[0], | ||
| }); | ||
| }); | ||
|
|
||
| it("refuses slices that share a base subtype and reports absent families", () => { | ||
| const duplicate = [slice(0, CPU_ARM64, 0), slice(1, CPU_ARM64, 0)]; | ||
| expect(selectPreferredMachoSlice(duplicate, "arm64")).toEqual({ | ||
| status: "ambiguous", | ||
| }); | ||
| expect(selectPreferredMachoSlice(duplicate, "x86_64")).toEqual({ | ||
| status: "absent", | ||
| }); | ||
| expect(selectPreferredMachoSlice(duplicate, "sparc")).toEqual({ | ||
| status: "absent", | ||
| }); | ||
| }); | ||
| }); |
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
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.
Uh oh!
There was an error while loading. Please reload this page.