hardhat icon indicating copy to clipboard operation
hardhat copied to clipboard

Use wasm for all production build profile builds

Open kanej opened this issue 1 year ago • 1 comments

There are some builds of solc that produce subtly different bytecode depending on the platform they are running on. When running under the production build profile, we should force compilation through the wasm version of solc to isolate us from the underlying platform.

kanej avatar Nov 27 '24 10:11 kanej

In the light of https://github.com/NomicFoundation/hardhat/issues/6336, this might not always be possible.

In particular, the solcjs-wrapper stores the compiler output from solcjs as a string, and so does our solcjs-runner. For very large codebases, the string containing the compiler output might exceed the maximum string length.

https://github.com/NomicFoundation/hardhat/blob/942d9afd569f8c9b207fd514c0c64c17a6c61b8c/v-next/hardhat/src/internal/builtin-plugins/solidity/build-system/compiler/solcjs-runner.ts#L31

This is not a problem for the native compilers because we now handle their outputs as streams instead - https://github.com/NomicFoundation/hardhat/pull/6411

galargh avatar Feb 26 '25 13:02 galargh

Add config(?) for selecting wasm as the compiler

Let's add a preferWasm to SingleVersionSolcUserConfig, MultiVersionSolcUserConfig and SolidityBuildProfileConfig.

Re @galargh's comment: the production build doesn't merge compilation jobs, so we won't hit that error.

alcuadrado avatar Jul 30 '25 14:07 alcuadrado