Skip to content

Commit 925766f

Browse files
committed
fix: missing --via-ir flag in combined json request to solc
1 parent b4ce0f9 commit 925766f

File tree

6 files changed

+28
-7
lines changed

6 files changed

+28
-7
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@
1010

1111
- The warning about the default codegen is made more verbose and informative
1212

13+
### Fixed
14+
15+
- Missing `--via-ir` flag in the combined JSON request to `solc`
16+
1317
## [1.5.11] - 2025-01-27
1418

1519
### Fixed

era-compiler-solidity/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -844,7 +844,7 @@ pub fn combined_json_eravm(
844844
}
845845
let output_assembly = selectors.contains(&era_solc::CombinedJsonSelector::Assembly);
846846

847-
let mut combined_json = solc_compiler.combined_json(paths, selectors)?;
847+
let mut combined_json = solc_compiler.combined_json(paths, selectors, codegen)?;
848848

849849
let build = standard_output_eravm(
850850
paths,
@@ -937,7 +937,7 @@ pub fn combined_json_evm(
937937
));
938938
}
939939

940-
let mut combined_json = solc_compiler.combined_json(paths, selectors)?;
940+
let mut combined_json = solc_compiler.combined_json(paths, selectors, codegen)?;
941941

942942
let build = standard_output_evm(
943943
paths,

era-compiler-solidity/tests/common/mod.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,8 +221,11 @@ pub fn build_solidity_combined_json(
221221
)?;
222222
build.check_errors()?;
223223

224-
let mut combined_json =
225-
solc_compiler.combined_json(paths.as_slice(), selectors.into_iter().collect())?;
224+
let mut combined_json = solc_compiler.combined_json(
225+
paths.as_slice(),
226+
selectors.into_iter().collect(),
227+
Some(solc_codegen),
228+
)?;
226229
build.write_to_combined_json(&mut combined_json)?;
227230
Ok(combined_json)
228231
}

era-solc/src/combined_json/selector.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,10 @@ impl Selector {
6464
/// Whether the selector is available in `solc`.
6565
///
6666
pub fn is_source_solc(&self) -> bool {
67-
!matches!(self, Self::Assembly)
67+
!matches!(
68+
self,
69+
Self::Assembly | Self::Bytecode | Self::BytecodeRuntime
70+
)
6871
}
6972
}
7073

@@ -82,6 +85,7 @@ impl FromStr for Selector {
8285
"transient-storage-layout" => Ok(Self::TransientStorageLayout),
8386
"ast" => Ok(Self::AST),
8487
"asm" => Ok(Self::ASM),
88+
8589
"bin" => Ok(Self::Bytecode),
8690
"bin-runtime" => Ok(Self::BytecodeRuntime),
8791

@@ -104,6 +108,7 @@ impl std::fmt::Display for Selector {
104108
Self::TransientStorageLayout => write!(f, "transient-storage-layout"),
105109
Self::AST => write!(f, "ast"),
106110
Self::ASM => write!(f, "asm"),
111+
107112
Self::Bytecode => write!(f, "bin"),
108113
Self::BytecodeRuntime => write!(f, "bin-runtime"),
109114

era-solc/src/solc.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ use std::sync::RwLock;
1111

1212
use crate::combined_json::selector::Selector as CombinedJsonSelector;
1313
use crate::combined_json::CombinedJson;
14+
use crate::standard_json::input::settings::codegen::Codegen as StandardJsonInputSettingsCodegen;
1415
use crate::standard_json::input::settings::libraries::Libraries as StandardJsonInputSettingsLibraries;
1516
use crate::standard_json::input::settings::optimizer::Optimizer as StandardJsonInputSettingsOptimizer;
1617
use crate::standard_json::input::settings::selection::Selection as StandardJsonInputSettingsSelection;
@@ -243,6 +244,7 @@ For reference, see the following links:
243244
&self,
244245
paths: &[PathBuf],
245246
mut selectors: HashSet<CombinedJsonSelector>,
247+
codegen: Option<StandardJsonInputSettingsCodegen>,
246248
) -> anyhow::Result<CombinedJson> {
247249
selectors.retain(|selector| selector.is_source_solc());
248250
if selectors.is_empty() {
@@ -263,10 +265,17 @@ For reference, see the following links:
263265
.collect::<Vec<String>>()
264266
.join(","),
265267
);
268+
if let Some(StandardJsonInputSettingsCodegen::Yul) = codegen {
269+
if self.version.default >= Self::FIRST_VIA_IR_VERSION {
270+
command.arg("--via-ir");
271+
} else if self.version.default >= Self::FIRST_YUL_VERSION {
272+
command.arg("--experimental-via-ir");
273+
}
274+
}
266275

267276
let process = command
268277
.spawn()
269-
.map_err(|error| anyhow::anyhow!("{} subprocess spawning: {:?}", executable, error))?;
278+
.map_err(|error| anyhow::anyhow!("{executable} subprocess spawning: {error:?}"))?;
270279

271280
let result = process.wait_with_output().map_err(|error| {
272281
anyhow::anyhow!("{} subprocess output reading: {error:?}", self.executable)

era-solc/src/standard_json/output/error/mapped_location.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ impl<'a> MappedLocation<'a> {
9797
}
9898
}
9999

100-
impl<'a> std::fmt::Display for MappedLocation<'a> {
100+
impl std::fmt::Display for MappedLocation<'_> {
101101
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
102102
let mut path = self.path.clone();
103103
if let Some(line) = self.line {

0 commit comments

Comments
 (0)