Skip to content

Fix compiler download for old versions in ARM64#8062

Merged
ChristopherDedominici merged 8 commits intomainfrom
fix-compiler-download
Mar 19, 2026
Merged

Fix compiler download for old versions in ARM64#8062
ChristopherDedominici merged 8 commits intomainfrom
fix-compiler-download

Conversation

@ChristopherDedominici
Copy link
Copy Markdown
Contributor

@ChristopherDedominici ChristopherDedominici commented Mar 13, 2026

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.

Copilot AI review requested due to automatic review settings March 13, 2026 15:25
@ChristopherDedominici ChristopherDedominici self-assigned this Mar 13, 2026
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Mar 13, 2026

⚠️ No Changeset found

Latest commit: 848e542

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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” describe block covering isCompilerDownloaded, downloadCompiler, and getCompiler for solc 0.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.

Copilot AI review requested due to automatic review settings March 19, 2026 11:43
public async getCompiler(version: string): Promise<Compiler | undefined> {
const build = await this.#getCompilerBuild(version);

assertHardhatInvariant(
Copy link
Copy Markdown
Contributor Author

@ChristopherDedominici ChristopherDedominici Mar 19, 2026

Choose a reason for hiding this comment

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

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

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 hasArm64MirrorBuild and an ARM64 mirror threshold (0.5.0) to distinguish mirror-native vs. official-native vs. no-native versions.
  • Default per-compiler preferWasm to true on 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.

Copilot AI review requested due to automatic review settings March 19, 2026 12:16
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 resolving preferWasm defaults.
  • 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.

ChristopherDedominici and others added 2 commits March 19, 2026 13:44
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings March 19, 2026 13:45
@ChristopherDedominici ChristopherDedominici marked this pull request as ready for review March 19, 2026 13:48
@ChristopherDedominici ChristopherDedominici moved this from In Progress to In Review in Hardhat Mar 19, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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)) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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.

@ChristopherDedominici ChristopherDedominici added this pull request to the merge queue Mar 19, 2026
Merged via the queue into main with commit a45e689 Mar 19, 2026
213 checks passed
@ChristopherDedominici ChristopherDedominici deleted the fix-compiler-download branch March 19, 2026 16:38
@github-project-automation github-project-automation Bot moved this from In Review to Done in Hardhat Mar 19, 2026
@github-actions github-actions Bot mentioned this pull request Mar 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no docs needed This PR doesn't require links to documentation no peer bump needed

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants