diff --git a/src/cargo/core/compiler/build_context/target_info.rs b/src/cargo/core/compiler/build_context/target_info.rs index 2f7cafedaea..80f1d51c3ed 100644 --- a/src/cargo/core/compiler/build_context/target_info.rs +++ b/src/cargo/core/compiler/build_context/target_info.rs @@ -192,7 +192,10 @@ impl TargetInfo { fn not_user_specific_cfg(cfg: &CargoResult) -> bool { if let Ok(Cfg::Name(cfg_name)) = cfg { - if cfg_name == "debug_assertions" || cfg_name == "proc_macro" { + // This should also include "debug_assertions", but it causes + // regressions. Maybe some day in the distant future it can be + // added (and possibly change the warning to an error). + if cfg_name == "proc_macro" { return false; } } diff --git a/src/cargo/core/compiler/custom_build.rs b/src/cargo/core/compiler/custom_build.rs index 9d6bd6cd058..2bc320e56d8 100644 --- a/src/cargo/core/compiler/custom_build.rs +++ b/src/cargo/core/compiler/custom_build.rs @@ -228,6 +228,11 @@ fn build_work<'a, 'cfg>(cx: &mut Context<'a, 'cfg>, unit: &Unit<'a>) -> CargoRes } } for (k, v) in cfg_map { + if k == "debug_assertions" { + // This cfg is always true and misleading, so avoid setting it. + // That is because Cargo queries rustc without any profile settings. + continue; + } let k = format!("CARGO_CFG_{}", super::envify(&k)); match v { Some(list) => {