diff --git a/src/cargo/core/compiler/build_context/mod.rs b/src/cargo/core/compiler/build_context/mod.rs index d28386f4f6f..8632b50dc8e 100644 --- a/src/cargo/core/compiler/build_context/mod.rs +++ b/src/cargo/core/compiler/build_context/mod.rs @@ -69,11 +69,11 @@ impl<'a, 'cfg> BuildContext<'a, 'cfg> { } })?; rustc.push_wrapper(RustcWrapper::new(tool)); - } else if build_config.cargo_as_rustc_wrapper { - let mut wrapper = RustcWrapper::new(env::current_exe()?); - let prog = rustc.path.as_os_str().to_owned(); - wrapper.env("RUSTC", prog); - rustc.push_wrapper(wrapper); + // } else if build_config.cargo_as_rustc_wrapper { + // let mut wrapper = RustcWrapper::new(env::current_exe()?); + // let prog = dbg!(rustc.path.as_os_str().to_owned()); + // wrapper.env("RUSTC", prog); + // rustc.push_wrapper(wrapper); } let host_config = TargetConfig::new(config, &rustc.host)?; diff --git a/src/cargo/core/compiler/compilation.rs b/src/cargo/core/compiler/compilation.rs index 5313a3b10a6..354d6b568f4 100644 --- a/src/cargo/core/compiler/compilation.rs +++ b/src/cargo/core/compiler/compilation.rs @@ -75,7 +75,20 @@ pub struct Compilation<'cfg> { impl<'cfg> Compilation<'cfg> { pub fn new<'a>(bcx: &BuildContext<'a, 'cfg>) -> CargoResult> { - let mut rustc = bcx.rustc.process(); + // If we're using cargo as a rustc wrapper then we're in a situation + // like `cargo fix`. For now just disregard the `RUSTC_WRAPPER` env var + // (which is typically set to `sccache` for now). Eventually we'll + // probably want to implement `RUSTC_WRAPPER` for `cargo fix`, but we'll + // leave that open as a bug for now. + let mut rustc = if bcx.build_config.cargo_as_rustc_wrapper { + let mut rustc = bcx.rustc.process_no_wrapper(); + let prog = rustc.get_program().to_owned(); + rustc.env("RUSTC", prog); + rustc.program(env::current_exe()?); + rustc + } else { + bcx.rustc.process() + }; if bcx.config.extra_verbose() { rustc.display_env_vars(); diff --git a/src/cargo/util/config.rs b/src/cargo/util/config.rs index 46996ef724d..5072b8c199f 100644 --- a/src/cargo/util/config.rs +++ b/src/cargo/util/config.rs @@ -197,7 +197,7 @@ impl Config { .join(".rustc_info.json") .into_path_unlocked() }); - let wrapper = self.maybe_get_tool("rustc-wrapper")?; + let wrapper = self.maybe_get_tool("rustc_wrapper")?; Rustc::new( self.get_tool("rustc")?, wrapper,