crytic / crytic/crytic-compile
Support for multiple different solc compiler versions (--solc-solcs-select/--solc-solcs-bin usage)
- Dominant language
- Python
- Stars
- 197
- Forks
- 97
- PR merge metrics
- No merged PRs in 30d
Description
### Describe the desired feature
Hello, I am trying to run slither against multiple contracts with different required solc versions, however I am seeing this error:
```bash
$ slither ./ --checklist
Compilation warnings/errors on ./Arithmetic1.sol:
Error: Source file requires different compiler version (current compiler is 0.8.17+commit.8df45f5f.Darwin.appleclang) - note that nightly builds are considered to be strictly less than the released version
--> Arithmetic1.sol:2:1:
|
2 | pragma solidity ^0.7.0;
| ^^^^^^^^^^^^^^^^^^^^^^^
```
Note that I have both 0.8.17 and 0.7.6 installed through solc-select:
```bash
$ solc-select versions
0.8.17 (current, set by /Users/eric/.solc-select/global-version)
0.7.6
```
Based on the docs for `--solc-solcs-select/--solc-solcs-bin`:
```
--solc-solcs-select SOLC_SOLCS_SELECT
Specify different solc version to try (env config). Depends on solc-select
--solc-solcs-bin SOLC_SOLCS_BIN
Specify different solc version to try (path config). Example: --solc-solcs-bin
solc-0.4.24,solc-0.5.3
```
I would assume this means that I should be able to specify multiple versions or bins of solc, and slither would pick one that works for a particular contract. But this is not the case:
```
$ slither ./ --solc-solcs-select 0.8.17,0.7.6 --checklist
Compilation warnings/errors on ./Arithmetic1.sol:
Error: Source file requires different compiler version (current compiler is 0.8.17+commit.8df45f5f.Darwin.appleclang) - note that nightly builds are considered to be strictly less than the released version
--> Arithmetic1.sol:2:1:
|
2 | pragma solidity ^0.7.0;
| ^^^^^^^^^^^^^^^^^^^^^^^
```
Trying again with bin paths directly:
```
$ slither ./ --solc-solcs-bin ~/.solc-select/artifacts/solc-0.8.17/solc-0.8.17,~/.solc-select/artifacts/solc-0.7.6/solc-0.7.6 --checklist
Compilation warnings/errors on ./Arithmetic1.sol:
Error: Source file requires different compiler version (current compiler is 0.8.17+commit.8df45f5f.Darwin.appleclang) - note that nightly builds are considered to be strictly less than the released version
--> Arithmetic1.sol:2:1:
|
2 | pragma solidity ^0.7.0;
| ^^^^^^^^^^^^^^^^^^^^^^^
```
If I reverse the ordering of 0.8.17 and 0.7.6 on the command line, then the contract with ^0.7.0 succeeds but the ones with ^0.8.0 fail instead. I am confused as to why the doc allows multiple bins, but in reality only the first bin will be used to compile all contracts, instead of being selective.
Assuming this is not a bug (intended to support only one solc version at a time), would it be useful to request (maybe yet another option) to allow exhausting all available solc versions for each individual contract, instead of a blanket compile using just one solc version?
Contributor guide
Assessment
This issue has not been assessed yet.