-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Recompile on profile rustflag changes #11121
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,7 @@ use crate::util::{closest_msg, config, CargoResult, Config}; | |
use anyhow::{bail, Context as _}; | ||
use std::collections::{BTreeMap, HashMap, HashSet}; | ||
use std::hash::Hash; | ||
use std::{cmp, env, fmt, hash}; | ||
use std::{env, fmt}; | ||
|
||
/// Collection of all profiles. | ||
#[derive(Clone, Debug)] | ||
|
@@ -539,10 +539,16 @@ pub enum ProfileRoot { | |
|
||
/// Profile settings used to determine which compiler flags to use for a | ||
/// target. | ||
#[derive(Clone, Eq, PartialOrd, Ord, serde::Serialize)] | ||
#[derive(Clone, Eq, PartialOrd, Ord, serde::Serialize, derivative::Derivative)] | ||
/// Don't compare/hash fields which wont affect compilation. | ||
/// This is necessary for `Unit` deduplication for things like "test" and | ||
/// "dev" which are essentially the same. | ||
#[derivative(Hash, PartialEq)] | ||
pub struct Profile { | ||
#[derivative(Hash = "ignore", PartialEq = "ignore")] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you re-do the commits so that one commit is the refactor with the other commit having the fix? And describe the problem and the fix in the PR? This is putting the burden on the reviewer to figure out what is happening with this and the team is already strapped for availability. |
||
pub name: InternedString, | ||
pub opt_level: InternedString, | ||
#[derivative(Hash = "ignore", PartialEq = "ignore")] | ||
#[serde(skip)] // named profiles are unstable | ||
pub root: ProfileRoot, | ||
pub lto: Lto, | ||
|
@@ -620,21 +626,6 @@ impl fmt::Display for Profile { | |
} | ||
} | ||
|
||
impl hash::Hash for Profile { | ||
fn hash<H>(&self, state: &mut H) | ||
where | ||
H: hash::Hasher, | ||
{ | ||
self.comparable().hash(state); | ||
} | ||
} | ||
|
||
impl cmp::PartialEq for Profile { | ||
fn eq(&self, other: &Self) -> bool { | ||
self.comparable() == other.comparable() | ||
} | ||
} | ||
|
||
impl Profile { | ||
fn default_dev() -> Profile { | ||
Profile { | ||
|
@@ -656,26 +647,6 @@ impl Profile { | |
..Profile::default() | ||
} | ||
} | ||
|
||
/// Compares all fields except `name`, which doesn't affect compilation. | ||
/// This is necessary for `Unit` deduplication for things like "test" and | ||
/// "dev" which are essentially the same. | ||
fn comparable(&self) -> impl Hash + Eq { | ||
( | ||
self.opt_level, | ||
self.lto, | ||
self.codegen_backend, | ||
self.codegen_units, | ||
self.debuginfo, | ||
self.split_debuginfo, | ||
self.debug_assertions, | ||
self.overflow_checks, | ||
self.rpath, | ||
self.incremental, | ||
self.panic, | ||
self.strip, | ||
) | ||
} | ||
} | ||
|
||
/// The link-time-optimization setting. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When adding a dependency, please expand on why it is helpful and why it is worth taking on.
In particular, this is adding a dependency in place of hand-implementing one
Hash
and onePartialEq
. That seems like a fairly small scope that I would expect the dependency to be pulling a lot of weight.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i don't feel code like that should be allowed to exist
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please expand.
Communication is critical in open source, especially when maintains have limited availability. So far the communication has been pretty minimal between this comment, this PR, and #11120.
I can make my own guesses and some of them might be quite valid but that is a one sided conversation with myself. I'm wanting to understand your intentions and reasoning.