Skip to content
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

Add native builds for ARM-based Macs #820

Merged
merged 3 commits into from
Feb 18, 2021
Merged

Conversation

rtsao
Copy link
Contributor

@rtsao rtsao commented Feb 16, 2021

Resolves #550

@@ -81,4 +81,4 @@ fs.read = function () {
};

const argv = ['node', wasm_exec, esbuild_wasm].concat(process.argv.slice(2));
wrapper(require, require.main, Object.assign(Object.create(process), { argv }), { instantiate });
wrapper(require, require.main, Object.assign(Object.create(process), { argv }), Object.assign(Object.create(WebAssembly), { instantiate }));
Copy link
Contributor Author

@rtsao rtsao Feb 16, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As of Golang 1.16.0, the wasm_exec.js run function now has this check:

if (!(instance instanceof WebAssembly.Instance)) {
  throw new Error("Go.run: WebAssembly.Instance expected");
}

This seemed like the simplest solution as opposed to patching the generated code like in

wasm_exec_js = wasm_exec_js.replace(toReplace, `

lib/install.ts Outdated Show resolved Hide resolved
@evanw
Copy link
Owner

evanw commented Feb 17, 2021

Thanks so much for putting this together.

However, it's missing the most important part: has anyone with a M1 processor tried this build command on Go 1.16.0 and checked that esbuild works? I don't want to ship a broken build if no one has tested it, but I don't have a M1 myself. A good check could be to build one of the benchmarks (e.g. make bench-three-esbuild).

I'm also curious to hear what the build times are like for native vs. Rosetta emulated. For example, what the build times are like for make bench-three-esbuild with GOARCH=arm64 vs. GOARCH=amd64.

@sod
Copy link
Contributor

sod commented Feb 17, 2021

I'm also curious to hear what the build times are

m1 macbook pro 8gb | <- left arm64/native ... right amd64/rosetta2 ->
image

if I run the bench 10 times, the arm64 avg. at ~290ms and the amd64 at ~405ms

@evanw
Copy link
Owner

evanw commented Feb 18, 2021

if I run the bench 10 times, the arm64 avg. at ~290ms and the amd64 at ~405ms

That's awesome. Thanks for checking.

@evanw evanw merged commit 6a4af08 into evanw:master Feb 18, 2021
evanw added a commit that referenced this pull request Feb 18, 2021
@muuvmuuv
Copy link

Adding my tests here with Mac mini M1 16 GB Ram but with Go native arm64 build:

amd64 arm64
Bildschirmfoto 2021-02-18 um 18 48 57 Bildschirmfoto 2021-02-18 um 18 49 46

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add darwin arm64 LE build
5 participants