-
Notifications
You must be signed in to change notification settings - Fork 703
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
installing emsdk on Apple M1 hardware fails #671
Comments
emsdk only officially supports x86_64 today. If you would like to try to add similar support for aarch64 macOS that be most welcome. The first level of support where we support building from source should be relatively straight forward and will probably just involve adding versions of node and python for aarch64 macOS. The second level of support where we supply pre-built binaries is likely to be a lot harder as it will involves CI builders to build and upload the packages. There is similar issue for adding support for aarch64 linux: #547. Regardless, we should certainly be giving a better error message here. There are two levels of support that we could add |
I could, but I would not know where to begin at add it. Perhaps someone could point me in the right direction, or even a similar git sha. |
BTW, in the mean time you should be able to build from source: https://emscripten.org/docs/building_from_source/index.html Building from source will also allow you to find and fix any issues with llvm, binaryen and emscripten before dealing with emsdk integration issues. |
I thought using ./emsdk install sdk-upstream-master-64bit built from source? This builds llvm, but seems to want to download node package. |
Hey @lpotter, if all you want to do is run emscripten on an M1 mac then I just forced it to install the x86_64 version by changing line 112 of emsdk.py to 'machine = "x86_64'. This makes it grab the Intel build for mac which runs fine under Rosetta 2. |
Ok, that's one way to work around it, but it is not ideal in the long term. |
If you would like to work on a more long term solution (perhaps we could do it incrementally starting with pulling arm versions of python and node for example) I think we would need the help of one of you to write and test out a patch. I don't know of any other emscripten developers or users who have this hardware yet. |
The Intel solution is working great for my needs and I don't see much need for a native ARM version. Maybe for now, M1 macs could be redirected to the Intel version with a small message. If that would be helpful, I might be able to write a patch for that so at least it works for now. |
That would be great. We could even link to this bug in case anyone wants to help work on it. |
I can certainly help, since i have hardware. Not sure I know emscripten or it's tools well enough to do the work myself, besides having my hands full with Qt WebAssembly. |
In addition to @bobbydigitales's solution, I found that Emscripten can also be automatically installed with Homebrew running under Rosetta: |
Speaking of homebrew, I can't get openjdk working on arm, but I've tricked it into compiling emscripten for arm by symlinking to the intel/rosetta openjdk:
I can't say it's the right way to do it, but it does seem to work so far. |
java is no longer a hard requirement to run emscripten since the npm package of closure can also use the native and js versions. |
You can just patch the emsdk.py file to remove the checks for node and python tools, then install the arm64 versions them manually via brew. You can confirm the binary architecture using lipo:
|
@jerrans thanks, I will test it out. However, a question:
Which node-12.9.1-64bit does it mean? Is it looking for exact node version on the host machine and that's all? because
there's definitely aarch64 node installed. |
@berkus No that's just the version listed in the emsdk_manifest.json, I'm using 15.5.1 as well. My patch is probably out of date now, if you just search the emsdk.py script for any instances of
And make sure that you just add a line to the effect of:
That will eliminate the check for node (you may need to do the same with Python) and allow the installation to proceed. Also make sure the node path is set to empty:
When emsdk uses node it just runs I have had no problems using v15.5.1 on my M1 system. |
Yep, I applied your patch semi-automatically and it seemed to configure. I ran into some other issues with it later though, that's missing "tools/optimize" directory and couldn't build it in the end. |
Ok so I've just tried pulling
I did run into an issue at the end:
But actually even an |
M1 support landed in #753. That should work without needing to patch, and/or needing to rely on homebrew for anything. However, there is one gotcha to be aware: detecting M1 is done using python, and if you have installed an Intel-only python that runs under Rosetta 2 emulation, then emsdk will also behave as if it is Intel only. If you are using the version of python that is shipped with the M1 Mac, or if you have installed an ARM64 aware python, then it should detect properly. You can check if your python interpreter is compiled to ARM64 by running
Use
The Currently |
@juj I'm still running into an error even after #753, I verified my python3 is native: $ file $(which python3)
/usr/bin/python3: Mach-O universal binary with 2 architectures: [x86_64:Mach-O 64-bit executable x86_64] [arm64e:Mach-O 64-bit executable arm64e]
/usr/bin/python3 (for architecture x86_64): Mach-O 64-bit executable x86_64
/usr/bin/python3 (for architecture arm64e): Mach-O 64-bit executable arm64e
$ ./emsdk install latest
Error: No tool or SDK found by name 'sdk-releases-upstream-89202930a98fe7f9ed59b574469a9471b0bda7dd-64bit'. |
Ah looks like it works with |
Ah yea, good point - upstream google servers do not package up precompiled versions, but one must compile from source. That might change in the future. |
Hm it seems even the locally built llvm and binaryen are still x86_64:
Only the downloaded python is arm64. |
That's odd. Any chance did you have previous build directories ( |
Given how many reports we are seeing perhaps we should make the x86_64 binaries installable on M1 arm hardware so that "emsdk install latest" at least functions (even if its in emulation mode). |
I've submitted a quick PR as #771 which simply treats arm64 macOS as x86_64 macOS, and works fine with the prebuilt binaries on my M1 MacBook Air. This is not ideal as it fetches the x86_64 node and python. Ideally all macOS dependencies would be built as universal binaries containing both architectures, or if that's inconvenient for the Unix-y build processes, as separate builds for both architectures made from the build bots. Note that x86_64 macOS can build for Aarch64/arm64 macOS just fine -- and if you build as universal binaries it will run the resulting binaries for tests (by running the native side, presumably x86_64 on a VM). |
Here's what I did for emscripten to work on an unknown platform: Then My point is that emscripten devs did an excellent job to allow building emscripten from scratch without prior knowledge to any platform, easy on porting jobs... |
Update: I've added arm64 mac builds to the emscripten-releases build system, which is what produces the precompiled binaries for emsdk. I believe with #816 emsdk should now "just work" on arm64 macs. For now it works with |
Awesome news! Assuming you have done some basic testing on a real M1 mac with |
Yes, I tested |
Awesome news, thanks all! |
Hey, I have a question, what are the steps to install emsdk/emcc on macbook m1? Still having trouble going along with instructions from docs. Commands I follow:
EDIT: I have found error, commands should be:
|
Glad you figured it out. When we make the next tagged release (2.0.21, which I expect to be in the next couple of days), then it should also work with |
It alse cannot work in ubuntu(use paralles to install ubuntu vmware on macbook m1) |
I don't think there are Linux/arm64 binaries yet, just macOS/arm64. You'll have to build from source; use: ./emsdk install sdk-upstream-main-64bit && ./emsdk activate sdk-upstream-main-64bit |
thanks |
…ence-packages build 20240213.1 (emscripten-core#671) [main] Update dependencies from dotnet/source-build-reference-packages
There is no precompiled emsdk package for Apple's new MacOSX hardware M1
lpotter@Lorns-Mac-mini emsdk % ./emsdk install latest
Error: No tool or SDK found by name 'sdk-releases-upstream-4764c5c323a474f7ba28ae991b0c9024fccca43c-64bit'.
and building emsdk fails:
./emsdk install sdk-upstream-master-64bit
...
Done installing tool 'llvm-git-master-64bit'.
Manifest error: No tool by name 'node-12.18.1-64bit' found! This may indicate an internal SDK error!
Traceback (most recent call last):
File "/Users/lpotter/emsdk/./emsdk.py", line 3082, in
sys.exit(main())
File "/Users/lpotter/emsdk/./emsdk.py", line 3062, in main
success = tool.install()
File "/Users/lpotter/emsdk/./emsdk.py", line 1840, in install
return self.install_sdk()
File "/Users/lpotter/emsdk/./emsdk.py", line 1851, in install_sdk
success = tool.install()
AttributeError: 'NoneType' object has no attribute 'install'
The text was updated successfully, but these errors were encountered: