Setting a custom path for the native solc binary #4490
Description
Currently Truffle is hard-coded to use the globally installed solc binary called solc
when configured with compilers.solc.version = 'native'
. This makes switching between versions of the compiler cumbersome. It would be more convenient if it allowed setting a custom path. Currently this is only possible with the emscripten binaries via solc-js.
In my case the primary motivation is to easily run tests of external projects with custom builds of the compiler but I could also imagine users wanting to use the much faster native binaries with multiple projects using different compiler versions.
If simply accepting the path to a native binary in the compilers.solc.version
setting is problematic (would need some kind of detection to recognize it as a native binary?), my suggestion would be to read the compiler path from an environment variable if the variable exists. Using a custom compiler would then be as simple as:
TRUFFLE_NATIVE_SOLC_PATH="/tmp/solc-linux-amd64-v0.8.10+commit.fc410830" truffle compile