|
| 1 | +# Add Linux ARM64/aarch64 Architecture Support |
| 2 | + |
| 3 | +## Summary |
| 4 | + |
| 5 | +solc-select currently lacks support for Linux ARM64/aarch64 architecture, causing installation and usage failures on ARM-based Linux systems (including Docker containers running on Apple Silicon Macs, AWS Graviton instances, Raspberry Pi, and other ARM64 Linux environments). |
| 6 | + |
| 7 | +## Current Behavior |
| 8 | + |
| 9 | +When running solc-select on a Linux ARM64 system: |
| 10 | +1. The `soliditylang_platform()` function incorrectly identifies the system as `linux-amd64` regardless of actual architecture |
| 11 | +2. solc-select attempts to download x86_64 binaries from `https://binaries.soliditylang.org/linux-amd64/` |
| 12 | +3. The downloaded x86_64 binaries fail to execute on ARM64 systems with "Exec format error" |
| 13 | + |
| 14 | +## Root Cause Analysis |
| 15 | + |
| 16 | +### Architecture Detection Issue |
| 17 | +The `soliditylang_platform()` function in `solc_select/solc_select.py:275-284` only checks the operating system, not the architecture: |
| 18 | + |
| 19 | +```python |
| 20 | +def soliditylang_platform() -> str: |
| 21 | + if sys.platform.startswith("linux"): |
| 22 | + platform = LINUX_AMD64 # Always returns AMD64 for any Linux |
| 23 | + elif sys.platform == "darwin": |
| 24 | + platform = MACOSX_AMD64 |
| 25 | + elif sys.platform in ["win32", "cygwin"]: |
| 26 | + platform = WINDOWS_AMD64 |
| 27 | + else: |
| 28 | + raise argparse.ArgumentTypeError("Unsupported platform") |
| 29 | + return platform |
| 30 | +``` |
| 31 | + |
| 32 | +### Binary Availability Challenge |
| 33 | +The Solidity team does not provide official ARM64 Linux binaries: |
| 34 | +- Available platforms at binaries.soliditylang.org: |
| 35 | + - ✅ linux-amd64 |
| 36 | + - ✅ macosx-amd64 (Universal binaries since v0.8.24) |
| 37 | + - ✅ windows-amd64 |
| 38 | + - ✅ emscripten-wasm32 |
| 39 | + - ✅ emscripten-asmjs |
| 40 | + - ❌ linux-arm64 (does not exist) |
| 41 | + - ❌ linux-aarch64 (does not exist) |
| 42 | + |
| 43 | +## Comparison with macOS Approach |
| 44 | + |
| 45 | +solc-select already handles architecture differences on macOS: |
| 46 | +- Detects Apple Silicon vs Intel Macs |
| 47 | +- Checks for Rosetta 2 availability for running Intel binaries on ARM |
| 48 | +- Identifies Universal binaries (v0.8.24+) that run natively on both architectures |
| 49 | +- See `solc_select/utils.py:10-30` for implementation |
| 50 | + |
| 51 | +## Proposed Solution |
| 52 | + |
| 53 | +### Phase 1: Immediate Improvements (Error Handling) |
| 54 | +1. **Detect actual architecture** on Linux systems using `platform.machine()` |
| 55 | +2. **Provide clear error messages** when running on unsupported architectures |
| 56 | +3. **Document workarounds** for ARM64 Linux users |
| 57 | + |
| 58 | +### Phase 2: ARM64 Support Implementation |
| 59 | + |
| 60 | +#### Option A: Use solc-js/WASM binaries (Recommended) |
| 61 | +- Leverage the existing emscripten-wasm32 binaries which work on any architecture |
| 62 | +- Add a new platform type `LINUX_ARM64_WASM` that uses WASM binaries |
| 63 | +- Implement a wrapper to make WASM binaries behave like native ones |
| 64 | +- Benefits: Works immediately, maintained by Solidity team, cross-architecture |
| 65 | +- Drawbacks: Slightly slower performance, requires Node.js |
| 66 | + |
| 67 | +#### Option B: Build native ARM64 binaries |
| 68 | +- Set up CI/CD to compile Solidity for linux-arm64 |
| 69 | +- Host binaries in Crytic's supplemental repository |
| 70 | +- Similar to how older Linux versions (0.4.0-0.4.10) are handled |
| 71 | +- Benefits: Native performance |
| 72 | +- Drawbacks: Maintenance burden, build infrastructure needed |
| 73 | + |
| 74 | +#### Option C: Use QEMU user-mode emulation |
| 75 | +- Document how to set up QEMU with binfmt_misc for transparent x86_64 emulation |
| 76 | +- Similar to Rosetta 2 on macOS but for Linux |
| 77 | +- Benefits: Works with existing binaries |
| 78 | +- Drawbacks: Performance overhead, setup complexity |
| 79 | + |
| 80 | +## Recommended Implementation Plan |
| 81 | + |
| 82 | +1. **Update architecture detection**: |
| 83 | +```python |
| 84 | +def soliditylang_platform() -> str: |
| 85 | + if sys.platform.startswith("linux"): |
| 86 | + machine = platform.machine() |
| 87 | + if machine in ["x86_64", "AMD64"]: |
| 88 | + platform = LINUX_AMD64 |
| 89 | + elif machine in ["aarch64", "arm64"]: |
| 90 | + platform = LINUX_ARM64 # New constant |
| 91 | + else: |
| 92 | + raise argparse.ArgumentTypeError(f"Unsupported Linux architecture: {machine}") |
| 93 | + # ... rest of function |
| 94 | +``` |
| 95 | + |
| 96 | +2. **Add WASM-based fallback for ARM64**: |
| 97 | + - Download emscripten-wasm32 binaries for ARM64 Linux |
| 98 | + - Create a Node.js wrapper script that executes the WASM binary |
| 99 | + - Install wrapper as the `solc` executable |
| 100 | + |
| 101 | +3. **Add compatibility checks**: |
| 102 | + - Check for Node.js availability when on ARM64 |
| 103 | + - Provide helpful error messages with installation instructions |
| 104 | + |
| 105 | +## Impact |
| 106 | + |
| 107 | +This issue affects: |
| 108 | +- Docker containers on Apple Silicon Macs (very common in development) |
| 109 | +- AWS Graviton instances (increasingly popular for cost savings) |
| 110 | +- Raspberry Pi and other ARM SBCs |
| 111 | +- Any CI/CD running on ARM64 infrastructure |
| 112 | +- Projects using Manticore, Slither, or other tools depending on solc-select |
| 113 | + |
| 114 | +## Testing |
| 115 | + |
| 116 | +The solution should be tested on: |
| 117 | +- [ ] x86_64 Linux (regression testing) |
| 118 | +- [ ] ARM64 Linux (Docker on Apple Silicon) |
| 119 | +- [ ] ARM64 Linux (native, e.g., Raspberry Pi OS) |
| 120 | +- [ ] Various Solidity versions (especially older ones like 0.4.x) |
| 121 | + |
| 122 | +## Related Issues |
| 123 | + |
| 124 | +- Similar architecture detection is needed for Windows ARM64 (emerging platform) |
| 125 | +- The approach could be extended to support other architectures (RISC-V, etc.) |
| 126 | + |
| 127 | +## References |
| 128 | + |
| 129 | +- [Solidity Official Binaries Repository](https://binaries.soliditylang.org/) |
| 130 | +- [macOS Universal Binary Support (v0.8.24+)](https://github.com/ethereum/solidity/issues/12291#issuecomment-2223328961) |
| 131 | +- [solc-js npm package](https://www.npmjs.com/package/solc) - JavaScript/WASM version |
0 commit comments