Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

Setting a custom path for the native solc binary #4490

Open
cameel opened this issue Dec 3, 2021 · 4 comments
Open

Setting a custom path for the native solc binary #4490

cameel opened this issue Dec 3, 2021 · 4 comments

Comments

@cameel
Copy link

cameel commented Dec 3, 2021

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
@fainashalts
Copy link
Contributor

Hi @cameel we like this idea, but it will require scoping as far as how to specify this properly in the user config and properly handle the info inside Truffle. We'll put it on our backlog to investigate further, but PRs are always welcome if you have an implementation in mind!

@cameel
Copy link
Author

cameel commented Dec 9, 2021

Great! I might try submitting a PR for this eventually, because it's blocking switching the Colony-based tests to the native compiler in the Solidity repo. Unfortunately not at the moment though because it's just a small part of a bigger task (benchmarking compilation/optimization using the new IR-based code generator) and it's not that critical, just nice to have to be able to get rid of brittle workarounds.

As for specifying this - would you prefer the solution with putting the compiler path in the setting or using an env variable? In case of a setting would you rely on autodetection or add another property to indicate what type of executable this is?

@hellwolf
Copy link

Is it possible now?

@hellwolf
Copy link

#6007

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants