Repository navigation
Support Windows on ARM through the x64 package #8776
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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
02d2781
Support Windows on ARM through the x64 package
cknitt 1a4fce7
Link the Windows on ARM CHANGELOG entry
cknitt bcf3c41
Only use the x64 package on Windows 11 on ARM
cknitt 36da563
Add platform.cjs to the artifact list
cknitt 556bd22
Merge branch 'master' into windows-arm64-x64-package
cknitt 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| // @ts-check | ||
|
|
||
| // Maps the current platform to the platform package (@rescript/<target>) that | ||
| // provides its compiler binaries. Kept free of side effects so it can be tested. | ||
|
|
||
| const supportedTargets = [ | ||
| "darwin-arm64", | ||
| "darwin-x64", | ||
| "linux-arm64", | ||
| "linux-x64", | ||
| "win32-x64", | ||
| ]; | ||
|
|
||
| // The first Windows 11 build. Windows 10 on ARM only emulates x86, not x64. | ||
| const firstWindows11Build = 22000; | ||
|
|
||
| /** | ||
| * @param {string} platform `process.platform` | ||
| * @param {string} arch `process.arch` | ||
| * @param {string} osRelease `os.release()`, e.g. "10.0.22631" on Windows 11 | ||
| * @returns {string | undefined} the target, or undefined if unsupported | ||
| */ | ||
| function getTarget(platform, arch, osRelease) { | ||
| // Windows 11 on ARM runs the x64 toolchain through its x64 emulation. | ||
| const binaryArch = | ||
| platform === "win32" && | ||
| arch === "arm64" && | ||
| windowsBuild(osRelease) >= firstWindows11Build | ||
| ? "x64" | ||
| : arch; | ||
| const target = `${platform}-${binaryArch}`; | ||
| return supportedTargets.includes(target) ? target : undefined; | ||
| } | ||
|
|
||
| /** | ||
| * @param {string} osRelease | ||
| */ | ||
| function windowsBuild(osRelease) { | ||
| const build = Number(osRelease.split(".")[2]); | ||
| return Number.isInteger(build) ? build : 0; | ||
| } | ||
|
|
||
| exports.getTarget = getTarget; |
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 |
|---|---|---|
|
|
@@ -45,7 +45,8 @@ | |
| "win32" | ||
| ], | ||
| "cpu": [ | ||
| "x64" | ||
| "x64", | ||
| "arm64" | ||
| ], | ||
| "files": [ | ||
| "bin.js", | ||
|
|
||
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,33 @@ | ||
| import * as assert from "node:assert/strict"; | ||
| import { describe, it } from "mocha"; | ||
| import { getTarget } from "../../cli/common/platform.cjs"; | ||
|
|
||
| describe("getTarget", () => { | ||
| it("maps supported platforms to their own package", () => { | ||
| for (const [platform, arch] of [ | ||
| ["darwin", "arm64"], | ||
| ["darwin", "x64"], | ||
| ["linux", "arm64"], | ||
| ["linux", "x64"], | ||
| ["win32", "x64"], | ||
| ]) { | ||
| assert.equal(getTarget(platform, arch, "10.0.0"), `${platform}-${arch}`); | ||
| } | ||
| }); | ||
|
|
||
| it("uses the x64 package on Windows 11 on ARM", () => { | ||
| assert.equal(getTarget("win32", "arm64", "10.0.22000"), "win32-x64"); | ||
| assert.equal(getTarget("win32", "arm64", "10.0.26100"), "win32-x64"); | ||
| }); | ||
|
|
||
| it("rejects Windows 10 on ARM, which cannot emulate x64", () => { | ||
| assert.equal(getTarget("win32", "arm64", "10.0.19045"), undefined); | ||
| assert.equal(getTarget("win32", "arm64", "unknown"), undefined); | ||
| }); | ||
|
|
||
| it("rejects unsupported platforms", () => { | ||
| assert.equal(getTarget("win32", "ia32", "10.0.26100"), undefined); | ||
| assert.equal(getTarget("linux", "ia32", "6.0.0"), undefined); | ||
| assert.equal(getTarget("freebsd", "x64", "14.0"), undefined); | ||
| }); | ||
| }); |
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.