Skip to content

Commit

Permalink
lto_bug
Browse files Browse the repository at this point in the history
  • Loading branch information
mohanson committed Sep 26, 2024
1 parent f7c7b7f commit cf93fb9
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,9 @@ log = { version = "0.4", optional = true, default-features = false }
[workspace]
exclude = ["test"]
resolver = "2"

[profile.release]
overflow-checks = true
opt-level = 's'
lto = true
codegen-units = 1
26 changes: 26 additions & 0 deletions examples/lto_bug.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#![no_std]
#![no_main]

use ckb_std::ckb_types::prelude::Entity;
use ckb_std::default_alloc;

ckb_std::entry!(program_entry);
default_alloc!();

/// program entry
fn program_entry() -> i8 {
let data = [
0x55, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x31, 0x00, 0x00,
0x00, 0xbc, 0x12, 0x7d, 0x21, 0xe2, 0x8a, 0x30, 0x7b, 0x44, 0xfe, 0xff, 0xaa, 0xc9, 0x2b,
0x5f, 0xb1, 0x70, 0xc5, 0x5c, 0x72, 0xca, 0xfb, 0xc0, 0xf0, 0x66, 0x90, 0xee, 0x45, 0x5f,
0xf4, 0xe8, 0x61, 0x01, 0x20, 0x00, 0x00, 0x00, 0x9a, 0x01, 0xcc, 0x4d, 0x15, 0xa2, 0x16,
0x03, 0x69, 0x02, 0xa2, 0xf8, 0x90, 0x77, 0x16, 0xa6, 0xab, 0x3f, 0x7f, 0x35, 0xec, 0xcf,
0x0e, 0x3b, 0x09, 0x29, 0xcc, 0xdc, 0x8e, 0xb0, 0x31, 0xc7,
];

let args = ckb_std::ckb_types::packed::Script::from_slice(&data)
.unwrap()
.args();
ckb_std::debug!("args: {:x}", args);
0
}
2 changes: 2 additions & 0 deletions lto_bug.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
RUSTFLAGS="-C target-feature=-a --cfg debug_assertions" cargo build --release --target riscv64imac-unknown-none-elf --features build-with-clang --example lto_bug
ckb-debugger --bin target/riscv64imac-unknown-none-elf/release/examples/lto_bug

0 comments on commit cf93fb9

Please sign in to comment.