nervosnetwork / capsule

Capsule is an out-of-box development framework for creating smart contract on Nervos' CKB.
MIT License
60 stars 34 forks source link

fix: change codegen-units value to fix invalid binary built with release mode #32

Closed TheWaWaR closed 1 year ago

TheWaWaR commented 3 years ago

@jordanmack

I'm having a strange problem with a script I'm working on. It seems like the debug version is fine, but the release version might be broken. Using capsule test all the tests run fine with the debug version. Using capsule test --release all the tests failed. Using a different script, both worked just fine. Do you have any suggestion on how to debug this?

https://github.com/jordanmack/token-buy-lock

I've been experimenting with changing the profile.release flags in Cargo.toml, with some luck. Changing the opt-level, lto, and codegen-units values sometimes produces a working release binary. So far, increasing codegen-units to 2 seems to be the best combination for producing a small and functional release binary.

Tested with rust nightly 2021-06-09, the same error. I suspect it's a bug of ckb-vm or rustc.

NOTE: this is a workaround fix, should investigate it by looking at the assembly code.

jjyr commented 3 years ago

https://github.com/nervosnetwork/godwoken-scripts/pull/61

A similar error here, I think we should turn off LTO by default.

jjyr commented 1 year ago

Out dated