std json: do not request EVM bytecode (#410)

These compiler outputs are irrelevant for the `resolc` compilation
pipeline. It can also break the compilation pipeline. For example, solc
may reject the code without via-ir or fail during the EVM codegen phase
with stack too deep errors - which is not relevant to us.

---------

Signed-off-by: xermicus <cyrill@parity.io>
This commit is contained in:
xermicus
2025-11-13 10:32:32 +01:00
committed by GitHub
parent 8ee1860f12
commit 79aaca1a85
9 changed files with 96 additions and 2 deletions
@@ -210,4 +210,9 @@ impl Input {
let _ = source.try_resolve();
});
}
/// Removes unneded output selections.
pub fn retain_output_selection(&mut self) {
self.settings.retain_output_selection();
}
}
@@ -112,4 +112,9 @@ impl Settings {
pub fn selection_to_prune(&self) -> Selection {
self.output_selection.selection_to_prune()
}
/// Removes unneeded selections.
pub fn retain_output_selection(&mut self) {
self.output_selection.retain();
}
}
@@ -47,3 +47,16 @@ pub enum Flag {
#[serde(rename = "ir")]
Ir,
}
impl Flag {
/// Whether this selection flag is required for the revive codegen.
///
/// Specifically, EVM bytecode and related flags should never be requested.
/// It will be replaced by PVM code anyways.
pub fn is_required_for_codegen(&self) -> bool {
!matches!(
self,
Flag::EVMBC | Flag::EVMDBC | Flag::EVMLA | Flag::EVM | Flag::Assembly
)
}
}
@@ -56,6 +56,14 @@ impl PerFileSelection {
pub fn is_empty(&self) -> bool {
self.files.is_empty()
}
/// Removes unneeded selections.
pub fn retain(&mut self) {
for file in self.files.values_mut() {
file.per_contract.retain(Flag::is_required_for_codegen);
file.per_file.retain(Flag::is_required_for_codegen);
}
}
}
/// The `solc --standard-json` output selection.
@@ -125,4 +133,11 @@ impl Selection {
.contains(path, flag)
.unwrap_or(self.all.contains(flag))
}
/// Removes unneeded selections.
pub fn retain(&mut self) {
self.all.per_file.retain(Flag::is_required_for_codegen);
self.all.per_contract.retain(Flag::is_required_for_codegen);
self.files.retain();
}
}