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

Enable debug info with flag in command build #131

Closed
wants to merge 6 commits into from

Conversation

clearloop
Copy link

@clearloop clearloop commented Dec 29, 2020

Desc

Currently cargo-contract trims name section by default while building contracts, strip_custom_sections, wasm-opt and an operation in parity-wasm(paritytech/parity-wasm#300) will remove name section, which makes it hard to debug contracts.

We are trying to set up a flag --debug to keep name section in this PR, we have kept the name section after strip_custom_sections but not in wasm_opt(not sure if it is a bug, name section optimized even passing debug_info: true to binaryen, but wasm-opt works fine using the same arguments in command-line wasm-opt -O3 -s 1 --debuginfo contract.wasm)

Instead, we left target/ink/<contract>.src.wasm after the process, which contains name section.

Refs

#169

@Robbepop
Copy link
Contributor

Robbepop commented Jan 6, 2021

I think as long as it is still guaranteed that non-debug builds behaves as before this is fine and could be a valuable addition.

Comment on lines +141 to +146
let mut flags =
"-C link-arg=-z -C link-arg=stack-size=65536 -C link-arg=--import-memory".to_string();
if debug {
flags.push_str(" -C opt-level=1");
}
std::env::set_var("RUSTFLAGS", flags);
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure using the rustc flag or building debug wasm binary under --debug

@@ -339,30 +375,32 @@ pub(crate) fn execute_with_crate_metadata(
optimize_contract: bool,
build_artifact: BuildArtifacts,
unstable_flags: UnstableFlags,
) -> Result<(Option<PathBuf>, Option<OptimizationResult>)> {
debug: bool,
) -> Result<(Option<PathBuf>, Option<PathBuf>, Option<OptimizationResult>)> {
Copy link
Author

@clearloop clearloop Jan 6, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This modification is quite dirty, would you mind offering some advice if this PR is welcome in the next days? @Robbepop

The code in this PR is a mess, it works, but I'm not satisfied even myself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants