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

Add option to build with unmodified original manifest #51

Merged
merged 9 commits into from
May 22, 2020

Conversation

ascjones
Copy link
Collaborator

@ascjones ascjones commented Mar 27, 2020

By default a contract's Cargo.toml will be amended to optimize the final Wasm binary. At the moment that means just removing the rlib crate type if present, though in the future we may make further modifications.

This PR provides the option -Z original-manifest (feedback on the name appreciated) to disable all modifications to the Cargo.toml: it will just build using the original file. Note that this is introduced as an unstable-option (short -Z)

This will result in a larger final contract binary size if rlib is enabled, but gives full control to the user for options from the Cargo.toml. This is useful for troubleshooting e.g use-ink/ink#364.

Options

In general we should try to minimize the number of options/flags we support in order to keep it as simple as possible, so this and other options should be considered through that lens.

Update: with this in mind I have added this as an unstable-option (short -Z),

@ascjones
Copy link
Collaborator Author

ascjones commented Mar 27, 2020

Suggestion from @Robbepop: uglify this option to discourage use

e.g. put debug- before command

Also maybe print a warning:

[WARN] Using this flag may significantly reduce optimizations on your generated contract or cause other non intended behaviour.

@ascjones ascjones requested a review from Robbepop May 22, 2020 07:26
@ascjones
Copy link
Collaborator Author

@Robbepop I've made this an unstable option -Z, and also print a warning during build

Copy link
Contributor

@Robbepop Robbepop left a comment

Choose a reason for hiding this comment

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

LGTM

Comment on lines +115 to +120
#[derive(Debug, StructOpt)]
struct UnstableOptions {
/// Use the original manifest (Cargo.toml), do not modify for build optimizations
#[structopt(long = "unstable-options", short = "Z", number_of_values = 1)]
options: Vec<String>,
}
Copy link
Contributor

Choose a reason for hiding this comment

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

How would this look like if we specify multiple unstable options? Each having their own -Z or one -Z for all? I guess we should mimic rustc here that requires one -Z per unstable feature usage.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Indeed that should work i.e. 1 -Z per option, I took this pattern from https://github.com/TeXitoi/structopt/blob/master/examples/keyvalue.rs#L22

@ascjones ascjones merged commit 06a9e8d into master May 22, 2020
@ascjones ascjones mentioned this pull request Oct 13, 2020
@HCastano HCastano deleted the aj-original-manifest branch July 29, 2022 17:03
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