@@ -4,10 +4,8 @@ use std::collections::BTreeMap;
44use std:: collections:: BTreeSet ;
55use std:: collections:: HashMap ;
66use std:: fmt:: Display ;
7- use std:: path:: PathBuf ;
87use std:: sync:: Mutex ;
98
10- use once_cell:: sync:: Lazy ;
119use revive_common:: MetadataHash ;
1210use revive_llvm_context:: initialize_llvm;
1311use revive_llvm_context:: DebugConfig ;
@@ -24,16 +22,19 @@ use revive_solc_json_interface::SolcStandardJsonInputSettingsSelection;
2422use revive_solc_json_interface:: SolcStandardJsonInputSource ;
2523use revive_solc_json_interface:: SolcStandardJsonOutput ;
2624use revive_solc_json_interface:: SolcStandardJsonOutputErrorHandler ;
25+ use std:: sync:: LazyLock ;
2726
2827use crate :: project:: Project ;
2928use crate :: solc:: solc_compiler:: SolcCompiler ;
3029use crate :: solc:: Compiler ;
3130
32- static PVM_BLOB_CACHE : Lazy < Mutex < HashMap < CachedBlob , Vec < u8 > > > > = Lazy :: new ( Default :: default) ;
33- static EVM_BLOB_CACHE : Lazy < Mutex < HashMap < CachedBlob , Vec < u8 > > > > = Lazy :: new ( Default :: default) ;
34- static EVM_RUNTIME_BLOB_CACHE : Lazy < Mutex < HashMap < CachedBlob , Vec < u8 > > > > =
35- Lazy :: new ( Default :: default) ;
36- static YUL_IR_CACHE : Lazy < Mutex < HashMap < CachedBlob , String > > > = Lazy :: new ( Default :: default) ;
31+ static PVM_BLOB_CACHE : LazyLock < Mutex < HashMap < CachedBlob , Vec < u8 > > > > =
32+ LazyLock :: new ( Default :: default) ;
33+ static EVM_BLOB_CACHE : LazyLock < Mutex < HashMap < CachedBlob , Vec < u8 > > > > =
34+ LazyLock :: new ( Default :: default) ;
35+ static EVM_RUNTIME_BLOB_CACHE : LazyLock < Mutex < HashMap < CachedBlob , Vec < u8 > > > > =
36+ LazyLock :: new ( Default :: default) ;
37+ static YUL_IR_CACHE : LazyLock < Mutex < HashMap < CachedBlob , String > > > = LazyLock :: new ( Default :: default) ;
3738
3839const DEBUG_CONFIG : revive_llvm_context:: DebugConfig = DebugConfig :: new ( None , true ) ;
3940
@@ -78,9 +79,6 @@ pub fn build_solidity_with_options(
7879 inkwell:: support:: enable_llvm_pretty_stack_trace ( ) ;
7980 initialize_llvm ( PolkaVMTarget :: PVM , crate :: DEFAULT_EXECUTABLE_NAME , & [ ] ) ;
8081
81- let _ = crate :: process:: native_process:: EXECUTABLE
82- . set ( PathBuf :: from ( crate :: r#const:: DEFAULT_EXECUTABLE_NAME ) ) ;
83-
8482 let solc = SolcCompiler :: new ( SolcCompiler :: DEFAULT_EXECUTABLE_NAME . to_owned ( ) ) ?;
8583 let solc_version = solc. version ( ) ?;
8684
@@ -146,9 +144,6 @@ pub fn build_solidity_with_options_evm(
146144 check_dependencies ( ) ;
147145 inkwell:: support:: enable_llvm_pretty_stack_trace ( ) ;
148146 initialize_llvm ( PolkaVMTarget :: PVM , crate :: DEFAULT_EXECUTABLE_NAME , & [ ] ) ;
149- let _ = crate :: process:: native_process:: EXECUTABLE
150- . set ( PathBuf :: from ( crate :: r#const:: DEFAULT_EXECUTABLE_NAME ) ) ;
151-
152147 let solc = SolcCompiler :: new ( SolcCompiler :: DEFAULT_EXECUTABLE_NAME . to_owned ( ) ) ?;
153148 let mut input = SolcStandardJsonInput :: try_from_solidity_sources (
154149 None ,
@@ -204,9 +199,6 @@ pub fn build_solidity_and_detect_missing_libraries<T: ToString>(
204199
205200 inkwell:: support:: enable_llvm_pretty_stack_trace ( ) ;
206201 initialize_llvm ( PolkaVMTarget :: PVM , crate :: DEFAULT_EXECUTABLE_NAME , & [ ] ) ;
207- let _ = crate :: process:: native_process:: EXECUTABLE
208- . set ( PathBuf :: from ( crate :: r#const:: DEFAULT_EXECUTABLE_NAME ) ) ;
209-
210202 let solc = SolcCompiler :: new ( SolcCompiler :: DEFAULT_EXECUTABLE_NAME . to_owned ( ) ) ?;
211203 let solc_version = solc. version ( ) ?;
212204 let mut input = SolcStandardJsonInput :: try_from_solidity_sources (
@@ -249,9 +241,6 @@ pub fn build_yul<T: ToString + Display>(
249241 inkwell:: support:: enable_llvm_pretty_stack_trace ( ) ;
250242 initialize_llvm ( PolkaVMTarget :: PVM , crate :: DEFAULT_EXECUTABLE_NAME , & [ ] ) ;
251243
252- let _ = crate :: process:: native_process:: EXECUTABLE
253- . set ( PathBuf :: from ( crate :: r#const:: DEFAULT_EXECUTABLE_NAME ) ) ;
254-
255244 let mut build = Project :: try_from_yul_sources (
256245 sources
257246 . iter ( )
@@ -298,9 +287,6 @@ pub fn build_yul_standard_json(
298287 inkwell:: support:: enable_llvm_pretty_stack_trace ( ) ;
299288 initialize_llvm ( PolkaVMTarget :: PVM , crate :: DEFAULT_EXECUTABLE_NAME , & [ ] ) ;
300289
301- let _ = crate :: process:: native_process:: EXECUTABLE
302- . set ( PathBuf :: from ( crate :: r#const:: DEFAULT_EXECUTABLE_NAME ) ) ;
303-
304290 let solc = SolcCompiler :: new ( SolcCompiler :: DEFAULT_EXECUTABLE_NAME . to_owned ( ) ) ?;
305291 let mut output = solc. validate_yul_standard_json ( & mut solc_input, & mut vec ! [ ] ) ?;
306292 if output. has_errors ( ) {
@@ -427,6 +413,8 @@ pub fn sources<T: ToString>(sources: &[(T, T)]) -> BTreeMap<String, SolcStandard
427413}
428414
429415/// Checks if the required executables are present in `${PATH}`.
416+ /// Also initializes the resolc executable path for subprocess spawning,
417+ /// since `std::env::current_exe()` returns the test runner binary in tests.
430418fn check_dependencies ( ) {
431419 for executable in [
432420 crate :: r#const:: DEFAULT_EXECUTABLE_NAME ,
@@ -439,6 +427,10 @@ fn check_dependencies() {
439427 "The `{executable}` executable not found in ${{PATH}}"
440428 ) ;
441429 }
430+
431+ let _ = crate :: process:: native_process:: EXECUTABLE . set (
432+ which:: which ( crate :: r#const:: DEFAULT_EXECUTABLE_NAME ) . expect ( "resolc should be in ${PATH}" ) ,
433+ ) ;
442434}
443435
444436/// The internal EVM bytecode compile helper.
0 commit comments