mirror of
https://github.com/pezkuwichain/revive-differential-tests.git
synced 2026-06-13 23:21:04 +00:00
Elide viaIR input if compiler does not support it
This commit is contained in:
@@ -23,6 +23,9 @@ use foundry_compilers_artifacts::{
|
|||||||
use semver::Version;
|
use semver::Version;
|
||||||
use tokio::{io::AsyncWriteExt, process::Command as AsyncCommand};
|
use tokio::{io::AsyncWriteExt, process::Command as AsyncCommand};
|
||||||
|
|
||||||
|
/// This is the first version of solc that supports the `--via-ir` flag / "viaIR" input JSON.
|
||||||
|
const VERSION_SUPPORTING_VIA_IR: Version = Version::new(0, 8, 13);
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct Solc {
|
pub struct Solc {
|
||||||
solc_path: PathBuf,
|
solc_path: PathBuf,
|
||||||
@@ -45,6 +48,17 @@ impl SolidityCompiler for Solc {
|
|||||||
}: CompilerInput,
|
}: CompilerInput,
|
||||||
_: Self::Options,
|
_: Self::Options,
|
||||||
) -> anyhow::Result<CompilerOutput> {
|
) -> anyhow::Result<CompilerOutput> {
|
||||||
|
let compiler_supports_via_ir = self.version()? >= VERSION_SUPPORTING_VIA_IR;
|
||||||
|
|
||||||
|
// Be careful to entirely omit the viaIR field if the compiler does not support it,
|
||||||
|
// as it will error if you provide fields it does not know about. Because
|
||||||
|
// `supports_mode` is called prior to instantiating a compiler, we should never
|
||||||
|
// ask for something which is invalid.
|
||||||
|
let via_ir = match (pipeline, compiler_supports_via_ir) {
|
||||||
|
(pipeline, true) => pipeline.map(|p| p.via_yul_ir()),
|
||||||
|
(_pipeline, false) => None,
|
||||||
|
};
|
||||||
|
|
||||||
let input = SolcInput {
|
let input = SolcInput {
|
||||||
language: SolcLanguage::Solidity,
|
language: SolcLanguage::Solidity,
|
||||||
sources: Sources(
|
sources: Sources(
|
||||||
@@ -70,7 +84,7 @@ impl SolidityCompiler for Solc {
|
|||||||
.map(|item| item.to_string()),
|
.map(|item| item.to_string()),
|
||||||
),
|
),
|
||||||
evm_version: evm_version.map(|version| version.to_string().parse().unwrap()),
|
evm_version: evm_version.map(|version| version.to_string().parse().unwrap()),
|
||||||
via_ir: pipeline.map(|p| p.via_yul_ir()),
|
via_ir,
|
||||||
libraries: Libraries {
|
libraries: Libraries {
|
||||||
libs: libraries
|
libs: libraries
|
||||||
.into_iter()
|
.into_iter()
|
||||||
@@ -221,7 +235,7 @@ impl SolidityCompiler for Solc {
|
|||||||
// solc 0.8.13 and above supports --via-ir, and less than that does not. Thus, we support mode E
|
// solc 0.8.13 and above supports --via-ir, and less than that does not. Thus, we support mode E
|
||||||
// (ie no Yul IR) in either case, but only support Y (via Yul IR) if the compiler is new enough.
|
// (ie no Yul IR) in either case, but only support Y (via Yul IR) if the compiler is new enough.
|
||||||
pipeline == ModePipeline::E
|
pipeline == ModePipeline::E
|
||||||
|| (pipeline == ModePipeline::Y && compiler_version >= &Version::new(0, 8, 13))
|
|| (pipeline == ModePipeline::Y && compiler_version >= &VERSION_SUPPORTING_VIA_IR)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -679,7 +679,7 @@ async fn compile_contracts<P: Platform>(
|
|||||||
%compiler_version,
|
%compiler_version,
|
||||||
metadata_file_path = %metadata_file_path.display(),
|
metadata_file_path = %metadata_file_path.display(),
|
||||||
mode = ?mode,
|
mode = ?mode,
|
||||||
"Skipping compilation: compiler does not support this mode"
|
"Skipping compilation: compiler does not support this mode or version"
|
||||||
);
|
);
|
||||||
return Ok(None);
|
return Ok(None);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user