Repository navigation
Allow setting -Zembed-metadata value from the config
#17266
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 1 commit
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 |
|---|---|---|
|
|
@@ -124,15 +124,14 @@ use std::fmt::{self, Write}; | |
| use std::path::PathBuf; | ||
| use std::str::FromStr; | ||
|
|
||
| use anyhow::{Error, bail}; | ||
| use cargo_util::ProcessBuilder; | ||
| use serde::{Deserialize, Serialize}; | ||
| use tracing::debug; | ||
|
|
||
| use crate::GlobalContext; | ||
| use crate::resolver::ResolveBehavior; | ||
| use crate::util::errors::CargoResult; | ||
| use crate::util::indented_lines; | ||
| use anyhow::{Error, bail}; | ||
| use cargo_util::ProcessBuilder; | ||
| use serde::{Deserialize, Serialize}; | ||
| use tracing::debug; | ||
|
|
||
| pub const SEE_CHANNELS: &str = "See https://doc.rust-lang.org/book/appendix-07-nightly-rust.html for more information \ | ||
| about Rust release channels."; | ||
|
|
@@ -409,7 +408,7 @@ enum Status { | |
| } | ||
|
|
||
| /// Config for the `-Zembed-metadata` option. | ||
| #[derive(Debug, Default, Deserialize)] | ||
| #[derive(Debug, Default)] | ||
| pub enum EmbedMetadata { | ||
| /// Embed metadata in .rlib files, the original rustc behavior. | ||
| Embed, | ||
|
|
@@ -883,6 +882,7 @@ macro_rules! unstable_cli_options { | |
| unstable_cli_options!( | ||
| // Permanently unstable features: | ||
| allow_features: Option<AllowFeatures> = ("Allow *only* the listed unstable features"), | ||
| #[serde(deserialize_with = "deserialize_embed_metadata")] | ||
| embed_metadata: EmbedMetadata = ("Avoid embedding metadata in library artifacts"), | ||
| print_im_a_teapot: bool, | ||
|
|
||
|
|
@@ -1051,6 +1051,18 @@ where | |
| Ok(Some(v)) | ||
| } | ||
|
|
||
| fn deserialize_embed_metadata<'de, D>(deserializer: D) -> Result<EmbedMetadata, D::Error> | ||
|
Member
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 we have one simple test verifying it works?
Member
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. Probably in
Member
Author
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. I tried that, the problem is that the config tests use
Member
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. 😞
Member
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. That is different than this PR's
Member
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. If we are going to have third option,
Member
Author
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. The third option is really just equivalent to
Member
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. The what about this? pub fn should_embed_metadata(&self) -> bool {
- match self.cli_unstable().embed_metadata {
- EmbedMetadata::Embed => true,
- EmbedMetadata::DoNotEmbed => false,
- EmbedMetadata::Unset => true,
- }
+ self.cli_unstable().embed_metadata.unwrap_or(true)
}
// ...
unstable_cli_options!(
// Permanently unstable features:
allow_features: Option<AllowFeatures> = ("Allow *only* the listed unstable features"),
- embed_metadata: EmbedMetadata = ("Avoid embedding metadata in library artifacts"),
+ embed_metadata: Option<bool> = ("Avoid embedding metadata in library artifacts"),
print_im_a_teapot: bool,It should work under this requirement right?
Member
Author
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. Yeah, |
||
| where | ||
| D: serde::Deserializer<'de>, | ||
| { | ||
| let data = Option::<bool>::deserialize(deserializer)?; | ||
| match data { | ||
| Some(true) => Ok(EmbedMetadata::Embed), | ||
| Some(false) => Ok(EmbedMetadata::DoNotEmbed), | ||
| None => Ok(EmbedMetadata::Unset), | ||
| } | ||
| } | ||
|
|
||
| #[derive(Debug, Copy, Clone, Default, Deserialize, Ord, PartialOrd, Eq, PartialEq)] | ||
| #[serde(default)] | ||
| pub struct GitFeatures { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.