@@ -500,7 +500,7 @@ impl ProfileMaker {
500500 is_member : bool ,
501501 unit_for : UnitFor ,
502502 ) -> Profile {
503- let mut profile = self . default ;
503+ let mut profile = self . default . clone ( ) ;
504504
505505 // First apply profile-specific settings, things like
506506 // `[profile.release]`
@@ -626,6 +626,9 @@ fn merge_profile(profile: &mut Profile, toml: &TomlProfile) {
626626 if let Some ( incremental) = toml. incremental {
627627 profile. incremental = incremental;
628628 }
629+ if let Some ( flags) = & toml. rustflags {
630+ profile. rustflags = flags. clone ( ) ;
631+ }
629632 profile. strip = match toml. strip {
630633 Some ( StringOrBool :: Bool ( true ) ) => Strip :: Named ( InternedString :: new ( "symbols" ) ) ,
631634 None | Some ( StringOrBool :: Bool ( false ) ) => Strip :: None ,
@@ -647,7 +650,7 @@ pub enum ProfileRoot {
647650
648651/// Profile settings used to determine which compiler flags to use for a
649652/// target.
650- #[ derive( Clone , Copy , Eq , PartialOrd , Ord , serde:: Serialize ) ]
653+ #[ derive( Clone , Eq , PartialOrd , Ord , serde:: Serialize ) ]
651654pub struct Profile {
652655 pub name : InternedString ,
653656 pub opt_level : InternedString ,
@@ -666,6 +669,9 @@ pub struct Profile {
666669 pub incremental : bool ,
667670 pub panic : PanicStrategy ,
668671 pub strip : Strip ,
672+ #[ serde( skip_serializing_if = "Vec::is_empty" ) ] // remove when `rustflags` is stablized
673+ // Note that `rustflags` is used for the cargo-feature `profile_rustflags`
674+ pub rustflags : Vec < InternedString > ,
669675}
670676
671677impl Default for Profile {
@@ -685,6 +691,7 @@ impl Default for Profile {
685691 incremental : false ,
686692 panic : PanicStrategy :: Unwind ,
687693 strip : Strip :: None ,
694+ rustflags : vec ! [ ] ,
688695 }
689696 }
690697}
@@ -712,6 +719,7 @@ compact_debug! {
712719 incremental
713720 panic
714721 strip
722+ rustflags
715723 ) ]
716724 }
717725 }
0 commit comments