Build fails on macOS M1 Apple Silicon in Eclipse, while it works on CLI (IEP-545)
See original GitHub issueBuild of hello_world fails of macOS M1 with following error:
ImportError: dlopen(/Users/georgik/.espressif/python_env/idf4.4_py3.8_env/lib/python3.8/site-packages/cryptography/hazmat/bindings/_openssl.abi3.so, 2): no suitable image found. Did find:
/Users/georgik/.espressif/python_env/idf4.4_py3.8_env/lib/python3.8/site-packages/cryptography/hazmat/bindings/_openssl.abi3.so: mach-o, but wrong architecture
/Users/georgik/.espressif/python_env/idf4.4_py3.8_env/lib/python3.8/site-packages/cryptography/hazmat/bindings/_openssl.abi3.so: mach-o, but wrong architecture
ninja: build stopped: subcommand failed.
The build works without problem when build from terminal.
To Reproduce Steps to reproduce the behavior:
- Create hello_world project and build it.
- The build fail in later stage when it’s invoking Python which requires cryptography
Expected behavior The build pass
Environment Information: Eclipse 2021-06 x86_64
ESP-IDF Tools Information: ESP-IDF 4.4
Problem analysis The problem is caused by invoking Python in x86_64 mode instead of arm64. Python wheels for M1 is available in arm64 format, the Python executed in x86_64 mode will try to seek for .so which is for x86_64.
Workaround The workaround is to launch Python which has only M1 version, e.g. one from Homebrew, not one from Apple. This Python works:
/opt/homebrew/bin//python3: Mach-O 64-bit executable arm64
This Python won’t work:
% file /usr/bin/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
Workaround steps:
- remove
~/.espressif/python_env/idf*
- explicitly set priotity to PATH to Homebrew Python:
export PATH=/opt/homebrew/bin/:$PATH
- double check the Python:
file `which python3`
- only one arch should be displayed - run install.sh
- update Eclipse configuration to point to newly created virtualenv
Possible solution: Force launching Python in arm64 for mode. There should be CLI option for macOS M1 to do it
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:6
Top GitHub Comments
Hi @georgik
Do we need this PR to work with the Apple M1 or was it working fine with arm64 based eclipse and java 17?
There are two things we did in the PR
arch -arm64
argument to pythonBuilds Java 17 for macOS arm64 https://download.oracle.com/java/17/latest/jdk-17_macos-aarch64_bin.dmg
Eclipse CPP arm64 build for macOS - this is a prerelease version eclipse-cpp-2021-12-M1-macosx.cocoa.aarch64
Thanks for the suggestion, but it doesn’t work here on M1.