mirror of
https://github.com/pezkuwichain/revive.git
synced 2026-06-15 09:11:04 +00:00
Separate compilation and linker phases (#376)
Separate between compilation and linker phases to allow deploy time linking and back-porting era compiler changes to fix #91. Unlinked contract binaries (caused by missing libraries or missing factory dependencies in turn) are emitted as raw ELF object. Few drive by fixes: - #98 - A compiler panic on missing libraries definitions. - Fixes some incosistent type forwarding in JSON output (empty string vs. null object). - Remove the unused fallback for size optimization setting. - Remove the broken `--lvm-ir` mode. - CI workflow fixes. --------- Signed-off-by: Cyrill Leutwiler <bigcyrill@hotmail.com> Signed-off-by: xermicus <bigcyrill@hotmail.com> Signed-off-by: xermicus <cyrill@parity.io>
This commit is contained in:
@@ -1,10 +1,9 @@
|
||||
//! The tests for running resolc with explicit optimization.
|
||||
|
||||
#![cfg(test)]
|
||||
|
||||
use revive_common;
|
||||
|
||||
use crate::tests::cli::{utils, yul};
|
||||
use crate::tests::cli::utils::{
|
||||
self, assert_command_failure, assert_command_success, assert_equal_exit_codes, execute_resolc,
|
||||
execute_solc, RESOLC_YUL_FLAG, SOLIDITY_CONTRACT_PATH, YUL_MEMSET_CONTRACT_PATH,
|
||||
};
|
||||
|
||||
const LEVELS: &[char] = &['0', '1', '2', '3', 's', 'z'];
|
||||
|
||||
@@ -12,11 +11,7 @@ const LEVELS: &[char] = &['0', '1', '2', '3', 's', 'z'];
|
||||
fn runs_with_valid_level() {
|
||||
for level in LEVELS {
|
||||
let optimization_argument = format!("-O{level}");
|
||||
let arguments = &[
|
||||
utils::YUL_MEMSET_CONTRACT_PATH,
|
||||
yul::YUL_OPTION,
|
||||
&optimization_argument,
|
||||
];
|
||||
let arguments = &[YUL_MEMSET_CONTRACT_PATH, "--yul", &optimization_argument];
|
||||
let resolc_result = utils::execute_resolc(arguments);
|
||||
assert!(
|
||||
resolc_result.success,
|
||||
@@ -37,17 +32,27 @@ fn runs_with_valid_level() {
|
||||
|
||||
#[test]
|
||||
fn fails_with_invalid_level() {
|
||||
let arguments = &[utils::YUL_MEMSET_CONTRACT_PATH, yul::YUL_OPTION, "-O9"];
|
||||
let resolc_result = utils::execute_resolc(arguments);
|
||||
utils::assert_command_failure(&resolc_result, "Providing an invalid optimization level");
|
||||
let arguments = &[YUL_MEMSET_CONTRACT_PATH, RESOLC_YUL_FLAG, "-O9"];
|
||||
let resolc_result = execute_resolc(arguments);
|
||||
assert_command_failure(&resolc_result, "Providing an invalid optimization level");
|
||||
|
||||
assert!(
|
||||
resolc_result
|
||||
.stderr
|
||||
.contains("Unexpected optimization option"),
|
||||
"Expected the output to contain a specific error message."
|
||||
);
|
||||
assert!(resolc_result
|
||||
.stderr
|
||||
.contains("Unexpected optimization option"));
|
||||
|
||||
let solc_result = utils::execute_solc(arguments);
|
||||
utils::assert_equal_exit_codes(&solc_result, &resolc_result);
|
||||
let solc_result = execute_solc(arguments);
|
||||
assert_equal_exit_codes(&solc_result, &resolc_result);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn disable_solc_optimzer() {
|
||||
let arguments = &[SOLIDITY_CONTRACT_PATH, "--bin", "--disable-solc-optimizer"];
|
||||
let disabled = execute_resolc(arguments);
|
||||
assert_command_success(&disabled, "Disabling the solc optimizer");
|
||||
|
||||
let arguments = &[SOLIDITY_CONTRACT_PATH, "--bin"];
|
||||
let enabled = execute_resolc(arguments);
|
||||
assert_command_success(&disabled, "Enabling the solc optimizer");
|
||||
|
||||
assert_ne!(enabled.stdout, disabled.stdout);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user