Skip to content

Reduce compile time of rustbuild #92297

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

Merged
merged 5 commits into from
Jan 2, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Remove the merge dependency
  • Loading branch information
bjorn3 committed Jan 1, 2022
commit ad6f98cd28e02d10323c125c8ad2eef44dbfbb20
7 changes: 0 additions & 7 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,6 @@ dependencies = [
"getopts",
"ignore",
"libc",
"merge",
"num_cpus",
"once_cell",
"opener",
Expand Down Expand Up @@ -2220,12 +2219,6 @@ dependencies = [
"autocfg",
]

[[package]]
name = "merge"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "10bbef93abb1da61525bbc45eeaff6473a41907d19f8f9aa5168d214e10693e9"

[[package]]
name = "minifier"
version = "0.0.41"
Expand Down
1 change: 0 additions & 1 deletion src/bootstrap/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ toml = "0.5"
time = "0.1"
ignore = "0.4.10"
opener = "0.5"
merge = { version = "0.1.0", default-features = false, features = ["std"] }
once_cell = "1.7.2"

[target.'cfg(windows)'.dependencies.winapi]
Expand Down
11 changes: 9 additions & 2 deletions src/bootstrap/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ pub use crate::flags::Subcommand;
use crate::flags::{Color, Flags};
use crate::util::exe;
use build_helper::t;
use merge::Merge;
use serde::Deserialize;

macro_rules! check_ci_llvm {
Expand Down Expand Up @@ -334,6 +333,10 @@ struct TomlConfig {
profile: Option<String>,
}

trait Merge {
fn merge(&mut self, other: Self);
}

impl Merge for TomlConfig {
fn merge(
&mut self,
Expand All @@ -357,6 +360,8 @@ impl Merge for TomlConfig {
}
}

// We are using a decl macro instead of a derive proc macro here to reduce the compile time of
// rustbuild.
macro_rules! derive_merge {
($(#[$attr:meta])* struct $name:ident {
$($field:ident: $field_ty:ty,)*
Expand All @@ -369,7 +374,9 @@ macro_rules! derive_merge {
impl Merge for $name {
fn merge(&mut self, other: Self) {
$(
Merge::merge(&mut self.$field, other.$field);
if !self.$field.is_some() {
self.$field = other.$field;
}
)*
}
}
Expand Down