From f092476f6b6b7065f79d8147b8566cdd1e627d64 Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Tue, 12 May 2020 10:35:39 +0200 Subject: [PATCH 1/3] Revert "Enable lto for sysroot build to fix missing bitcode error (#70)" This reverts commit 5eb0bc255af54b7cb48d43d68e7e4c7f86cf6f59. --- src/cargo.rs | 14 +++++--------- src/sysroot.rs | 5 +---- 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/src/cargo.rs b/src/cargo.rs index 0d7be14..5a6b6e0 100644 --- a/src/cargo.rs +++ b/src/cargo.rs @@ -194,11 +194,11 @@ pub fn config() -> Result> { } } -pub struct Profile { - table: Value, +pub struct Profile<'t> { + table: &'t Value, } -impl Profile { +impl<'t> Profile<'t> { pub fn hash(&self, hasher: &mut H) where H: Hasher, @@ -218,13 +218,9 @@ impl Profile { v.to_string().hash(hasher); } - - pub fn set_lto(&mut self) { - self.table.as_table_mut().expect("[profile.release] not a table").insert("lto".into(), Value::Boolean(true)); - } } -impl fmt::Display for Profile { +impl<'t> fmt::Display for Profile<'t> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { let mut map = toml::map::Map::new(); map.insert("profile".to_owned(), { @@ -247,7 +243,7 @@ impl Toml { self.table .get("profile") .and_then(|v| v.get("release")) - .map(|t| Profile { table: t.clone() }) + .map(|t| Profile { table: t }) } } diff --git a/src/sysroot.rs b/src/sysroot.rs index 02f7b94..e33c628 100644 --- a/src/sysroot.rs +++ b/src/sysroot.rs @@ -74,11 +74,8 @@ fn build_crate( let target_dir = td.join("target"); - if let Some(mut profile) = ctoml.profile() { - profile.set_lto(); + if let Some(profile) = ctoml.profile() { stoml.push_str(&profile.to_string()) - } else { - stoml.push_str("[profile.release]\nlto = true"); } util::write(&td.join("Cargo.toml"), &stoml)?; From 911bfebcb796491ecb391da2e21b0b57fc0270bc Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Tue, 12 May 2020 11:55:07 +0200 Subject: [PATCH 2/3] Set `-Clinker-plugin-lto` for the sysroot build --- src/sysroot.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sysroot.rs b/src/sysroot.rs index e33c628..24786dc 100644 --- a/src/sysroot.rs +++ b/src/sysroot.rs @@ -84,7 +84,7 @@ fn build_crate( let cargo = std::env::var("CARGO").unwrap_or("cargo".to_string()); let mut cmd = Command::new(cargo); - cmd.env_remove("RUSTFLAGS"); + cmd.env("RUSTFLAGS", "-Clinker-plugin-lto"); cmd.env("CARGO_TARGET_DIR", &target_dir); cmd.env("__CARGO_DEFAULT_LIB_METADATA", "XARGO"); From 26b945f4dc501c406447b25ea16084107cd4c118 Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Tue, 12 May 2020 11:57:38 +0200 Subject: [PATCH 3/3] Update changelog for #71 --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c0b1022..0521398 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,10 @@ This project adheres to [Semantic Versioning](http://semver.org/). ## Unreleased +- Set `-Clinker-plugin-lto` for the sysroot build ([#71](https://github.com/rust-osdev/cargo-xbuild/pull/71)) + - Second try to fix missing bitcode error for LTO builds (see [#69](https://github.com/rust-osdev/cargo-xbuild/issues/69)) + - Reverts "Enable lto for sysroot build to fix missing bitcode error ([#70](https://github.com/rust-osdev/cargo-xbuild/pull/70))" + ## 0.5.30 - 2020-05-11 - Enable lto for sysroot build to fix missing bitcode error ([#70](https://github.com/rust-osdev/cargo-xbuild/pull/70))