Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adjust profile.release's optimization parameters #115

Merged
merged 3 commits into from
Sep 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions contracts/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,5 @@ resolver = "2"

[profile.release]
overflow-checks = true
opt-level = 's'
lto = true
strip = true
codegen-units = 1
20 changes: 11 additions & 9 deletions contracts/ckb-std-tests/src/entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -805,15 +805,6 @@ pub fn main() -> Result<(), Error> {
test_query();
test_calc_data_hash();

#[cfg(target_arch = "riscv64")]
unsafe {
let mut context = ContextType::new();
#[allow(deprecated)]
let mut old_context = ContextTypeOld::new();

test_dynamic_loading(&mut old_context);
test_dynamic_loading_c_impl(&mut context);
}
test_vm_version();
test_current_cycles();
test_since();
Expand All @@ -823,5 +814,16 @@ pub fn main() -> Result<(), Error> {
test_atomic2();
test_log();
}

#[cfg(target_arch = "riscv64")]
unsafe {
let mut context = ContextType::new();
#[allow(deprecated)]
let mut old_context = ContextTypeOld::new();

test_dynamic_loading(&mut old_context);
test_dynamic_loading_c_impl(&mut context);
}

Ok(())
}
10 changes: 5 additions & 5 deletions test/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ test: build build-examples

build:
make -C shared-lib all-via-docker
cd ../contracts && RUSTFLAGS="-C target-feature=-a" cargo build --target riscv64imac-unknown-none-elf
cd ../contracts && RUSTFLAGS="-C target-feature=-a" cargo build --release --target riscv64imac-unknown-none-elf

build-examples:
cd ../examples && RUSTFLAGS="-C target-feature=-a" cargo build --features build-with-clang --example always_failure --target riscv64imac-unknown-none-elf
cd ../examples && RUSTFLAGS="-C target-feature=-a" cargo build --features build-with-clang --example always_success --target riscv64imac-unknown-none-elf
cd ../examples && RUSTFLAGS="-C target-feature=-a" cargo build --features build-with-clang --example atomic --target riscv64imac-unknown-none-elf
cd ../examples && RUSTFLAGS="-C target-feature=-a" cargo build --features build-with-clang --example type_id --target riscv64imac-unknown-none-elf --features "type-id"
cd ../examples && RUSTFLAGS="-C target-feature=-a" cargo build --release --target riscv64imac-unknown-none-elf --features build-with-clang --example always_failure
cd ../examples && RUSTFLAGS="-C target-feature=-a" cargo build --release --target riscv64imac-unknown-none-elf --features build-with-clang --example always_success
cd ../examples && RUSTFLAGS="-C target-feature=-a" cargo build --release --target riscv64imac-unknown-none-elf --features build-with-clang --example atomic
cd ../examples && RUSTFLAGS="-C target-feature=-a" cargo build --release --target riscv64imac-unknown-none-elf --features build-with-clang,type-id --example type_id

clean:
rm -rf ../build
Expand Down
2 changes: 1 addition & 1 deletion test/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ fn it_works() {
let mut context = Context::default();
let contract_bin = {
let mut buf = Vec::new();
File::open("../contracts/target/riscv64imac-unknown-none-elf/debug/ckb-std-tests")
File::open("../contracts/target/riscv64imac-unknown-none-elf/release/ckb-std-tests")
.unwrap()
.read_to_end(&mut buf)
.expect("read code");
Expand Down
8 changes: 4 additions & 4 deletions test/src/exec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ fn test_exec_by_index() {
let mut context = Context::default();
let caller_bin = {
let mut buf = Vec::new();
File::open("../contracts/target/riscv64imac-unknown-none-elf/debug/exec-caller")
File::open("../contracts/target/riscv64imac-unknown-none-elf/release/exec-caller")
.unwrap()
.read_to_end(&mut buf)
.expect("read code");
Expand All @@ -30,7 +30,7 @@ fn test_exec_by_index() {
let caller_out_point = context.deploy_cell(caller_bin);
let callee_bin = {
let mut buf = Vec::new();
File::open("../contracts/target/riscv64imac-unknown-none-elf/debug/exec-callee")
File::open("../contracts/target/riscv64imac-unknown-none-elf/release/exec-callee")
.unwrap()
.read_to_end(&mut buf)
.expect("read code");
Expand Down Expand Up @@ -85,7 +85,7 @@ fn test_exec_by_code_hash() {
let caller_bin = {
let mut buf = Vec::new();
File::open(
"../contracts/target/riscv64imac-unknown-none-elf/debug/exec-caller-by-code-hash",
"../contracts/target/riscv64imac-unknown-none-elf/release/exec-caller-by-code-hash",
)
.unwrap()
.read_to_end(&mut buf)
Expand All @@ -95,7 +95,7 @@ fn test_exec_by_code_hash() {
let caller_out_point = context.deploy_cell(caller_bin);
let callee_bin = {
let mut buf = Vec::new();
File::open("../contracts/target/riscv64imac-unknown-none-elf/debug/exec-callee")
File::open("../contracts/target/riscv64imac-unknown-none-elf/release/exec-callee")
.unwrap()
.read_to_end(&mut buf)
.expect("read code");
Expand Down
4 changes: 2 additions & 2 deletions test/src/type_id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ const MAX_CYCLES: u64 = 1000_0000;
fn build_bins() -> (Bytes, Bytes) {
let always_success_bin = {
let mut buf = Vec::new();
File::open("../target/riscv64imac-unknown-none-elf/debug/examples/always_success")
File::open("../target/riscv64imac-unknown-none-elf/release/examples/always_success")
.unwrap()
.read_to_end(&mut buf)
.expect("read code");
Bytes::from(buf)
};
let type_id_bin = {
let mut buf = Vec::new();
File::open("../target/riscv64imac-unknown-none-elf/debug/examples/type_id")
File::open("../target/riscv64imac-unknown-none-elf/release/examples/type_id")
.unwrap()
.read_to_end(&mut buf)
.expect("read code");
Expand Down