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

Fix LTO regressions in nightly toolchain #52

Merged
merged 6 commits into from
May 12, 2020
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# Version 0.6.1 (2020-05-12)

- Fix LTO regressions in nightly toolchain [#52](https://github.com/paritytech/cargo-contract/pull/52)

# Version 0.6.0 (2020-03-25)

- First release to crates.io
Expand Down
6 changes: 3 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "cargo-contract"
version = "0.6.0"
version = "0.6.1"
authors = ["Parity Technologies <admin@parity.io>"]
build = "build.rs"
edition = "2018"
Expand Down Expand Up @@ -29,7 +29,7 @@ codec = { package = "parity-scale-codec", version = "1.2" }
which = "3.1.0"
colored = "1.9"
toml = "0.5.4"
cargo-xbuild = "0.5.26"
cargo-xbuild = "0.5.31"
rustc_version = "0.2.3"
serde_json = "1.0"
tempfile = "3.1.0"
Expand Down
4 changes: 3 additions & 1 deletion src/cmd/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,9 @@ fn build_cargo_project(crate_metadata: &CrateMetadata, verbosity: Option<Verbosi

Workspace::new(&crate_metadata.cargo_meta, &crate_metadata.root_package.id)?
.with_root_package_manifest(|manifest| {
manifest.with_removed_crate_type("rlib")?;
manifest
.with_removed_crate_type("rlib")?
.with_profile_release_lto(true)?;
Ok(())
})?
.using_temp(xbuild)?;
Expand Down
4 changes: 3 additions & 1 deletion src/cmd/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,9 @@ pub(crate) fn execute_generate_metadata(

Workspace::new(&metadata, &root_package_id)?
.with_root_package_manifest(|manifest| {
manifest.with_added_crate_type("rlib")?;
manifest
.with_added_crate_type("rlib")?
.with_profile_release_lto(false)?;
Ok(())
})?
.using_temp(generate_metadata)?;
Expand Down
20 changes: 20 additions & 0 deletions src/workspace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,26 @@ impl Manifest {
Ok(self)
}

/// Set `[profile.release]` lto flag
pub fn with_profile_release_lto(&mut self, enabled: bool) -> Result<&mut Self> {
let profile = self
.toml
.entry("profile")
.or_insert(value::Value::Table(Default::default()));
let release = profile
.as_table_mut()
.ok_or(anyhow::anyhow!("profile should be a table"))?
.entry("release")
.or_insert(value::Value::Table(Default::default()));
let lto = release
.as_table_mut()
.ok_or(anyhow::anyhow!("release should be a table"))?
.entry("lto")
.or_insert(enabled.into());
*lto = enabled.into();
Ok(self)
}

/// Remove a value from the `[lib] crate-types = []` section
///
/// If the value does not exist, does nothing.
Expand Down