Fix compiler download for old versions in ARM64#8062
Fix compiler download for old versions in ARM64#8062ChristopherDedominici merged 8 commits intomainfrom
Conversation
|
There was a problem hiding this comment.
Pull request overview
Adds a regression test suite intended to reproduce and guard against failures when requesting an older solc version on linux-arm64 where no native ARM64 binary exists.
Changes:
- Introduces a new
linux-arm64“bug repro”describeblock coveringisCompilerDownloaded,downloadCompiler, andgetCompilerfor solc0.4.24. - Asserts the downloader APIs return
false/undefined(and do not throw) when the ARM64 build is unavailable.
You can also share your feedback on Copilot code review. Take the survey.
| public async getCompiler(version: string): Promise<Compiler | undefined> { | ||
| const build = await this.#getCompilerBuild(version); | ||
|
|
||
| assertHardhatInvariant( |
There was a problem hiding this comment.
The assertHardhatInvariant was redundant because #getCompilerBuild() (in this file) already guarantees build is never undefined, if the version isn't found, it throws a HardhatError
There was a problem hiding this comment.
Pull request overview
Updates Hardhat’s Solidity compiler resolution and download flow on Linux ARM64 to correctly handle very old solc versions that have no native ARM64 binaries, ensuring a WASM fallback instead of failing native downloads.
Changes:
- Add
hasArm64MirrorBuildand an ARM64 mirror threshold (0.5.0) to distinguish mirror-native vs. official-native vs. no-native versions. - Default per-compiler
preferWasmtotrueon ARM64 for versions with no native build anywhere (<0.5.0), and keep production-default WASM behavior for versions lacking official ARM64 builds. - Update compiler download/get logic to skip native operations for versions without an ARM64 native build, and add tests for the new behavior.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| v-next/hardhat/src/internal/builtin-plugins/solidity/build-system/solc-info.ts | Introduces mirror-range detection (hasArm64MirrorBuild) and threshold constant. |
| v-next/hardhat/src/internal/builtin-plugins/solidity/config.ts | Adjusts ARM64 per-compiler preferWasm defaults to force WASM when no native ARM64 build exists. |
| v-next/hardhat/src/internal/builtin-plugins/solidity/build-system/compiler/index.ts | Filters native downloads on ARM64 to versions with native builds; adds native-availability guard before native getCompiler. |
| v-next/hardhat/src/internal/builtin-plugins/solidity/build-system/compiler/downloader.ts | Removes a now-redundant invariant after centralizing missing-version handling in #getCompilerBuild. |
| v-next/hardhat/test/internal/builtin-plugins/solidity/build-system/solc-info.ts | Adds unit tests for hasArm64MirrorBuild range behavior. |
| v-next/hardhat/test/internal/builtin-plugins/solidity/config.ts | Adds/updates ARM64 config-resolution tests for the new WASM defaulting rules. |
| v-next/hardhat/test/internal/builtin-plugins/solidity/build-system/compiler/index.ts | Adds an ARM64-only integration test for WASM fallback for 0.4.x. |
| v-next/hardhat/test/internal/builtin-plugins/solidity/build-system/compiler/downloader.ts | Adds tests asserting native ARM64 downloader throws for versions missing from the native list. |
You can also share your feedback on Copilot code review. Take the survey.
There was a problem hiding this comment.
Pull request overview
Fixes Solidity compiler resolution on Linux ARM64 for very old solc versions (<0.5.0) by avoiding native compiler downloads (which don’t exist) and ensuring WASM is used instead, while preserving existing ARM64 behavior for mirror/official ranges.
Changes:
- Add ARM64 mirror threshold logic (
FIRST_ARM64_MIRROR_SOLC_VERSION,hasArm64MirrorBuild) and use it when resolvingpreferWasmdefaults. - Skip native compiler list/download and native compiler selection on Linux ARM64 when no native build exists for the requested version(s), falling back to WASM.
- Extend test coverage for mirror/official build detection and for ARM64 old-version WASM fallback behavior.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| v-next/hardhat/src/internal/builtin-plugins/solidity/build-system/solc-info.ts | Introduces ARM64 mirror threshold constant and hasArm64MirrorBuild() helper. |
| v-next/hardhat/src/internal/builtin-plugins/solidity/config.ts | Updates per-compiler preferWasm defaulting on ARM64 to force WASM for <0.5.0 across profiles. |
| v-next/hardhat/src/internal/builtin-plugins/solidity/build-system/compiler/index.ts | Adds hasNativeBuildForPlatform() and filters native downloads / native compiler selection accordingly. |
| v-next/hardhat/src/internal/builtin-plugins/solidity/build-system/compiler/downloader.ts | Adjusts behavior for versions missing from the native build list (now consistently throws INVALID_SOLC_VERSION). |
| v-next/hardhat/test/internal/builtin-plugins/solidity/build-system/solc-info.ts | Adds tests for hasArm64MirrorBuild() boundaries. |
| v-next/hardhat/test/internal/builtin-plugins/solidity/config.ts | Adds ARM64-only test for forcing WASM below mirror threshold and updates assertions/comments for mirror-range versions. |
| v-next/hardhat/test/internal/builtin-plugins/solidity/build-system/compiler/index.ts | Adds unit tests for hasNativeBuildForPlatform() and an ARM64-only integration-style fallback test using high-level APIs. |
You can also share your feedback on Copilot code review. Take the survey.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR fixes Hardhat’s Solidity compiler resolution/download behavior on Linux ARM64 for old Solidity versions (<0.5.0) by recognizing that no native ARM64 binaries exist for those versions and automatically falling back to the WASM compiler.
Changes:
- Introduce ARM64 mirror range detection (
0.5.0–0.8.30) alongside existing “official ARM64 starts at 0.8.31” logic. - Skip native compiler list updates/downloads (and native
getCompiler) on Linux ARM64 when a native build cannot exist, ensuring WASM fallback for<0.5.0. - Add/adjust tests to cover mirror detection, config defaulting, downloader behavior for missing versions, and the end-to-end ARM64 WASM fallback.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| v-next/hardhat/src/internal/builtin-plugins/solidity/build-system/solc-info.ts | Adds mirror threshold constant and hasArm64MirrorBuild() helper. |
| v-next/hardhat/src/internal/builtin-plugins/solidity/config.ts | Updates ARM64 per-compiler preferWasm defaults to force WASM for <0.5.0 and keep production behavior for non-official builds. |
| v-next/hardhat/src/internal/builtin-plugins/solidity/build-system/compiler/index.ts | Adds hasNativeBuildForPlatform() and uses it to avoid native download/get attempts for ARM64 <0.5.0, enabling WASM fallback. |
| v-next/hardhat/src/internal/builtin-plugins/solidity/build-system/compiler/downloader.ts | Removes redundant invariant in getCompiler now that missing builds throw INVALID_SOLC_VERSION. |
| v-next/hardhat/test/internal/builtin-plugins/solidity/build-system/solc-info.ts | Adds unit tests for hasArm64MirrorBuild(). |
| v-next/hardhat/test/internal/builtin-plugins/solidity/config.ts | Adds ARM64 config-resolution test ensuring <0.5.0 defaults to preferWasm: true across profiles; clarifies default-profile expectations. |
| v-next/hardhat/test/internal/builtin-plugins/solidity/build-system/compiler/index.ts | Adds tests for hasNativeBuildForPlatform() and an ARM64-only integration test verifying WASM fallback; uses mocked global cache dir with cleanup. |
| v-next/hardhat/test/internal/builtin-plugins/solidity/build-system/compiler/downloader.ts | Adds tests asserting native ARM64 downloader throws INVALID_SOLC_VERSION for versions absent from the native build list. |
You can also share your feedback on Copilot code review. Take the survey.
| ); | ||
|
|
||
| const compiler = await compilerDownloader.getCompiler(version); | ||
| if (hasNativeBuildForPlatform(version, platform)) { |
There was a problem hiding this comment.
I like this double-protection here, in case preferWasm: false is wrong used. It also aligns well with "prefer", it's not a strict mandate.
Problem
On ARM64 Linux, Hardhat fails when trying to compile with old Solidity versions (< 0.5.0) because no native ARM64 binary exists for those versions, not in the official releases nor in the community mirror.
Solution
Based on the available versions listed in the solc-linux-arm64-mirror (which is frozen), the fix hardcodes that native ARM64 binaries only exist from version 0.5.0 onward. For older versions on ARM64 Linux, it skips the native download entirely and uses the WASM compiler instead. This applies to all build profiles, since those old versions simply have no native ARM64 binary anywhere.