Skip to content

Commit c784758

Browse files
committed
Merge branch 'main' of github.com:foundry-rs/compilers into elfedy-compiler-output
2 parents ec5ba21 + 05dc674 commit c784758

File tree

13 files changed

+217
-55
lines changed

13 files changed

+217
-55
lines changed

CHANGELOG.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,32 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [0.12.1](https://github.com/foundry-rs/compilers/releases/tag/v0.12.1) - 2024-11-18
9+
10+
### Bug Fixes
11+
12+
- `collect_contract_names` ([#221](https://github.com/foundry-rs/compilers/issues/221))
13+
14+
## [0.12.0](https://github.com/foundry-rs/compilers/releases/tag/v0.12.0) - 2024-11-18
15+
16+
### Bug Fixes
17+
18+
- Sanitize `settings.optimizer.details.inliner` ([#216](https://github.com/foundry-rs/compilers/issues/216))
19+
- [tests] Always try installing pinned solc ([#217](https://github.com/foundry-rs/compilers/issues/217))
20+
- Outdated merge build error
21+
22+
### Features
23+
24+
- Allow multiple compiler configs ([#170](https://github.com/foundry-rs/compilers/issues/170))
25+
- Replace solang with solar ([#215](https://github.com/foundry-rs/compilers/issues/215))
26+
27+
### Miscellaneous Tasks
28+
29+
- Release 0.12.0
30+
- Remove outdated `ref` patterns ([#218](https://github.com/foundry-rs/compilers/issues/218))
31+
- Inline constants in Settings::sanitize ([#219](https://github.com/foundry-rs/compilers/issues/219))
32+
- Use Version::new over .parse ([#220](https://github.com/foundry-rs/compilers/issues/220))
33+
834
## [0.11.6](https://github.com/foundry-rs/compilers/releases/tag/v0.11.6) - 2024-10-16
935

1036
### Bug Fixes
@@ -14,6 +40,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1440

1541
### Miscellaneous Tasks
1642

43+
- Release 0.11.6
1744
- Release 0.11.5
1845
- Allow adding vyper sources with `add_raw_source` w/ `.vy` / `.vyi` extension ([#211](https://github.com/foundry-rs/compilers/issues/211))
1946
- [`ci`] Fix deny (add `ZLib` exception) ([#212](https://github.com/foundry-rs/compilers/issues/212))

Cargo.toml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ resolver = "2"
44

55
[workspace.package]
66
authors = ["Foundry Maintainers"]
7-
version = "0.11.6"
7+
version = "0.12.1"
88
rust-version = "1.70"
99
readme = "README.md"
1010
license = "MIT OR Apache-2.0"
@@ -31,11 +31,11 @@ unused-must-use = "deny"
3131
all = "warn"
3232

3333
[workspace.dependencies]
34-
foundry-compilers = { path = "crates/compilers", version = "0.11.6" }
35-
foundry-compilers-artifacts = { path = "crates/artifacts/artifacts", version = "0.11.6" }
36-
foundry-compilers-artifacts-solc = { path = "crates/artifacts/solc", version = "0.11.6" }
37-
foundry-compilers-artifacts-vyper = { path = "crates/artifacts/vyper", version = "0.11.6" }
38-
foundry-compilers-core = { path = "crates/core", version = "0.11.6" }
34+
foundry-compilers = { path = "crates/compilers", version = "0.12.1" }
35+
foundry-compilers-artifacts = { path = "crates/artifacts/artifacts", version = "0.12.1" }
36+
foundry-compilers-artifacts-solc = { path = "crates/artifacts/solc", version = "0.12.1" }
37+
foundry-compilers-artifacts-vyper = { path = "crates/artifacts/vyper", version = "0.12.1" }
38+
foundry-compilers-core = { path = "crates/core", version = "0.12.1" }
3939

4040
alloy-json-abi = { version = "0.8", features = ["serde_json"] }
4141
alloy-primitives = { version = "0.8", features = ["serde", "rand"] }

crates/artifacts/solc/src/bytecode.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ impl BytecodeObject {
303303
///
304304
/// See also: <https://docs.soliditylang.org/en/develop/using-the-compiler.html#library-linking>
305305
pub fn link_fully_qualified(&mut self, name: &str, addr: Address) -> &mut Self {
306-
if let Self::Unlinked(ref mut unlinked) = self {
306+
if let Self::Unlinked(unlinked) = self {
307307
let place_holder = utils::library_hash_placeholder(name);
308308
// the address as hex without prefix
309309
let hex_addr = hex::encode(addr);

crates/artifacts/solc/src/contract.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ pub struct Contract {
4848

4949
impl<'a> From<&'a Contract> for CompactContractBytecodeCow<'a> {
5050
fn from(artifact: &'a Contract) -> Self {
51-
let (bytecode, deployed_bytecode) = if let Some(ref evm) = artifact.evm {
51+
let (bytecode, deployed_bytecode) = if let Some(evm) = &artifact.evm {
5252
(
5353
evm.bytecode.clone().map(Into::into).map(Cow::Owned),
5454
evm.deployed_bytecode.clone().map(Into::into).map(Cow::Owned),
@@ -523,7 +523,7 @@ impl<'a> CompactContractRef<'a> {
523523

524524
impl<'a> From<&'a Contract> for CompactContractRef<'a> {
525525
fn from(c: &'a Contract) -> Self {
526-
let (bin, bin_runtime) = if let Some(ref evm) = c.evm {
526+
let (bin, bin_runtime) = if let Some(evm) = &c.evm {
527527
(
528528
evm.bytecode.as_ref().map(|c| &c.object),
529529
evm.deployed_bytecode

crates/artifacts/solc/src/lib.rs

Lines changed: 39 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -297,8 +297,7 @@ impl Settings {
297297

298298
/// This will remove/adjust values in the settings that are not compatible with this version.
299299
pub fn sanitize(&mut self, version: &Version, language: SolcLanguage) {
300-
const V0_6_0: Version = Version::new(0, 6, 0);
301-
if *version < V0_6_0 {
300+
if *version < Version::new(0, 6, 0) {
302301
if let Some(meta) = &mut self.metadata {
303302
// introduced in <https://docs.soliditylang.org/en/v0.6.0/using-the-compiler.html#compiler-api>
304303
// missing in <https://docs.soliditylang.org/en/v0.5.17/using-the-compiler.html#compiler-api>
@@ -308,22 +307,26 @@ impl Settings {
308307
self.debug = None;
309308
}
310309

311-
const V0_7_5: Version = Version::new(0, 7, 5);
312-
if *version < V0_7_5 {
310+
if *version < Version::new(0, 7, 5) {
313311
// introduced in 0.7.5 <https://github.com/ethereum/solidity/releases/tag/v0.7.5>
314312
self.via_ir = None;
315313
}
316314

317-
const V0_8_7: Version = Version::new(0, 8, 7);
318-
if *version < V0_8_7 {
315+
if *version < Version::new(0, 8, 5) {
316+
// introduced in 0.8.5 <https://github.com/ethereum/solidity/releases/tag/v0.8.5>
317+
if let Some(optimizer_details) = &mut self.optimizer.details {
318+
optimizer_details.inliner = None;
319+
}
320+
}
321+
322+
if *version < Version::new(0, 8, 7) {
319323
// lower the disable version from 0.8.10 to 0.8.7, due to `divModNoSlacks`,
320324
// `showUnproved` and `solvers` are implemented
321325
// introduced in <https://github.com/ethereum/solidity/releases/tag/v0.8.7>
322326
self.model_checker = None;
323327
}
324328

325-
const V0_8_10: Version = Version::new(0, 8, 10);
326-
if *version < V0_8_10 {
329+
if *version < Version::new(0, 8, 10) {
327330
if let Some(debug) = &mut self.debug {
328331
// introduced in <https://docs.soliditylang.org/en/v0.8.10/using-the-compiler.html#compiler-api>
329332
// <https://github.com/ethereum/solidity/releases/tag/v0.8.10>
@@ -336,8 +339,7 @@ impl Settings {
336339
}
337340
}
338341

339-
const V0_8_18: Version = Version::new(0, 8, 18);
340-
if *version < V0_8_18 {
342+
if *version < Version::new(0, 8, 18) {
341343
// introduced in 0.8.18 <https://github.com/ethereum/solidity/releases/tag/v0.8.18>
342344
if let Some(meta) = &mut self.metadata {
343345
meta.cbor_metadata = None;
@@ -351,23 +353,26 @@ impl Settings {
351353
}
352354
}
353355

354-
if *version < SHANGHAI_SOLC {
356+
if *version < Version::new(0, 8, 20) {
355357
// introduced in 0.8.20 <https://github.com/ethereum/solidity/releases/tag/v0.8.20>
356358
if let Some(model_checker) = &mut self.model_checker {
357359
model_checker.show_proved_safe = None;
358360
model_checker.show_unsupported = None;
359361
}
360362
}
361363

362-
if let Some(ref mut evm_version) = self.evm_version {
364+
if let Some(evm_version) = self.evm_version {
363365
self.evm_version = evm_version.normalize_version_solc(version);
364366
}
365367

366-
if language == SolcLanguage::Yul {
367-
if !self.remappings.is_empty() {
368-
warn!("omitting remappings supplied for the yul sources");
368+
match language {
369+
SolcLanguage::Solidity => {}
370+
SolcLanguage::Yul => {
371+
if !self.remappings.is_empty() {
372+
warn!("omitting remappings supplied for the yul sources");
373+
}
374+
self.remappings = Vec::new();
369375
}
370-
self.remappings = Vec::new();
371376
}
372377
}
373378

@@ -2025,25 +2030,20 @@ mod tests {
20252030

20262031
#[test]
20272032
fn can_sanitize_byte_code_hash() {
2028-
let version: Version = "0.6.0".parse().unwrap();
2029-
20302033
let settings = Settings { metadata: Some(BytecodeHash::Ipfs.into()), ..Default::default() };
20312034

20322035
let input =
20332036
SolcInput { language: SolcLanguage::Solidity, sources: Default::default(), settings };
20342037

2035-
let i = input.clone().sanitized(&version);
2038+
let i = input.clone().sanitized(&Version::new(0, 6, 0));
20362039
assert_eq!(i.settings.metadata.unwrap().bytecode_hash, Some(BytecodeHash::Ipfs));
20372040

2038-
let version: Version = "0.5.17".parse().unwrap();
2039-
let i = input.sanitized(&version);
2041+
let i = input.sanitized(&Version::new(0, 5, 17));
20402042
assert!(i.settings.metadata.unwrap().bytecode_hash.is_none());
20412043
}
20422044

20432045
#[test]
20442046
fn can_sanitize_cbor_metadata() {
2045-
let version: Version = "0.8.18".parse().unwrap();
2046-
20472047
let settings = Settings {
20482048
metadata: Some(SettingsMetadata::new(BytecodeHash::Ipfs, true)),
20492049
..Default::default()
@@ -2052,7 +2052,7 @@ mod tests {
20522052
let input =
20532053
SolcInput { language: SolcLanguage::Solidity, sources: Default::default(), settings };
20542054

2055-
let i = input.clone().sanitized(&version);
2055+
let i = input.clone().sanitized(&Version::new(0, 8, 18));
20562056
assert_eq!(i.settings.metadata.unwrap().cbor_metadata, Some(true));
20572057

20582058
let i = input.sanitized(&Version::new(0, 8, 0));
@@ -2221,4 +2221,19 @@ mod tests {
22212221
let content = fs::read_to_string(path).unwrap();
22222222
let _output: CompilerOutput = serde_json::from_str(&content).unwrap();
22232223
}
2224+
2225+
// <https://github.com/foundry-rs/foundry/issues/9322>
2226+
#[test]
2227+
fn can_sanitize_optimizer_inliner() {
2228+
let settings = Settings::default().with_via_ir_minimum_optimization();
2229+
2230+
let input =
2231+
SolcInput { language: SolcLanguage::Solidity, sources: Default::default(), settings };
2232+
2233+
let i = input.clone().sanitized(&Version::new(0, 8, 4));
2234+
assert!(i.settings.optimizer.details.unwrap().inliner.is_none());
2235+
2236+
let i = input.sanitized(&Version::new(0, 8, 5));
2237+
assert_eq!(i.settings.optimizer.details.unwrap().inliner, Some(false));
2238+
}
22242239
}

crates/compilers/src/compile/output/info.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,10 @@ impl ContractInfo {
4444

4545
impl fmt::Display for ContractInfo {
4646
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
47-
if let Some(ref path) = self.path {
48-
write!(f, "{path}:{}", self.name)
49-
} else {
50-
write!(f, "{}", self.name)
47+
if let Some(path) = &self.path {
48+
write!(f, "{path}:")?;
5149
}
50+
f.write_str(&self.name)
5251
}
5352
}
5453

crates/compilers/src/compile/output/mod.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -917,13 +917,12 @@ impl<C: Compiler> fmt::Display for OutputDiagnostics<'_, C> {
917917
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
918918
f.write_str("Compiler run ")?;
919919
if self.has_error() {
920-
Paint::red("failed:")
920+
write!(f, "{}:", "failed".red())
921921
} else if self.has_warning() {
922-
Paint::yellow("successful with warnings:")
922+
write!(f, "{}:", "successful with warnings".yellow())
923923
} else {
924-
Paint::green("successful!")
925-
}
926-
.fmt(f)?;
924+
write!(f, "{}!", "successful".green())
925+
}?;
927926

928927
for err in &self.compiler_output.errors {
929928
if !self.compiler_output.should_ignore(

crates/compilers/src/compilers/solc/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,7 @@ mod tests {
465465
metadata: Default::default(),
466466
};
467467

468-
let v: Version = "0.8.12".parse().unwrap();
468+
let v = Version::new(0, 8, 12);
469469
let input = SolcVersionedInput::build(
470470
Default::default(),
471471
Default::default(),

crates/compilers/src/lib.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,12 @@ use cache::CompilerCache;
4949
use compile::output::contracts::VersionedContracts;
5050
use compilers::multi::MultiCompiler;
5151
use derivative::Derivative;
52-
use foundry_compilers_artifacts::solc::{
52+
use foundry_compilers_artifacts::{
5353
output_selection::OutputSelection,
54-
sources::{Source, SourceCompilationKind, Sources},
55-
Severity, SourceFile, StandardJsonCompilerInput,
54+
solc::{
55+
sources::{Source, SourceCompilationKind, Sources},
56+
Severity, SourceFile, StandardJsonCompilerInput,
57+
},
5658
};
5759
use foundry_compilers_core::error::{Result, SolcError, SolcIoError};
5860
use output::sources::{VersionedSourceFile, VersionedSourceFiles};
@@ -383,7 +385,7 @@ impl<T: ArtifactOutput<CompilerContract = C::CompilerContract>, C: Compiler> Pro
383385
let graph = Graph::<C::ParsedSource>::resolve(&self.paths)?;
384386
let mut contracts: HashMap<String, Vec<PathBuf>> = HashMap::new();
385387
if !graph.is_empty() {
386-
for node in graph.nodes(0) {
388+
for node in &graph.nodes {
387389
for contract_name in node.data.contract_names() {
388390
contracts
389391
.entry(contract_name.clone())

crates/compilers/src/project_util/mod.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,8 @@ impl<
6363
pub fn set_solc(&mut self, solc: &str) -> &mut Self {
6464
use crate::solc::{Solc, SolcCompiler};
6565

66-
self.inner.compiler.solc = Some(SolcCompiler::Specific(
67-
Solc::find_svm_installed_version(&solc.parse().unwrap()).unwrap().unwrap(),
68-
));
66+
self.inner.compiler.solc =
67+
Some(SolcCompiler::Specific(Solc::find_or_install(&solc.parse().unwrap()).unwrap()));
6968

7069
self
7170
}

0 commit comments

Comments
 (0)