Repository: rust-lang/cc-rs
Pull request #1397 (2025-02-10 08:41:13)

Simplify the error output on failed `Command` invocation
Passing around the `program` we wanted to execute in `command_helpers.rs` is unnecessary, we can retrieve it from `Command::get_program` instead when required, and that path is usually more descriptive anyhow.


## Motivation

I'm currently debugging [this](https://github.com/rust-lang/rust/pull/133092#issuecomment-2647012444). The error that `cc-rs` gives is:
```
error occurred: Command "sccache" "aarch64-unknown-fuchsia-clang" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-g" "-fno-omit-frame-pointer" "--target=aarch64-unknown-fuchsia" "-I" "/checkout/src/llvm-project/compiler-rt/lib/builtins" "-fno-builtin" "-fvisibility=hidden" "-ffreestanding" "-fomit-frame-pointer" "-ffile-prefix-map=/checkout/src/llvm-project/compiler-rt=." "-DCOMPILER_RT_HAS_FLOAT16" "-DVISIBILITY_HIDDEN" "-o" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-std/aarch64-unknown-fuchsia/release/build/compiler_builtins-6830d4e928982f93/out/670c1ed24249df13-aarch64.o" "-c" "/checkout/src/llvm-project/compiler-rt/lib/builtins/cpu_model/aarch64.c" with args aarch64-unknown-fuchsia-clang did not execute successfully (status code exit status: 1).
```

This was confusing, as "aarch64-unknown-fuchsia-clang" is really the compiler and not "args". Besides, I didn't actually need to know that the tool we "wanted" to invoke; that is evident from the pretty-printed command line arguments.

With this PR, the above error would have been:
```
error occurred: command did not execute successfully (status code 1): "sccache" "aarch64-unknown-fuchsia-clang" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-g" "-fno-omit-frame-pointer" "--target=aarch64-unknown-fuchsia" "-I" "/checkout/src/llvm-project/compiler-rt/lib/builtins" "-fno-builtin" "-fvisibility=hidden" "-ffreestanding" "-fomit-frame-pointer" "-ffile-prefix-map=/checkout/src/llvm-project/compiler-rt=." "-DCOMPILER_RT_HAS_FLOAT16" "-DVISIBILITY_HIDDEN" "-o" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-std/aarch64-unknown-fuchsia/release/build/compiler_builtins-6830d4e928982f93/out/670c1ed24249df13-aarch64.o" "-c" "/checkout/src/llvm-project/compiler-rt/lib/builtins/cpu_model/aarch64.c"
```

Which is shorter, and makes it clearer where the command starts and ends (after the colon and at the end of the line).


Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 7da5092..b87da59 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -6,6 +6,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
 
 ## [Unreleased]
 
+## [1.2.14](https://github.com/rust-lang/cc-rs/compare/cc-v1.2.13...cc-v1.2.14) - 2025-02-14
+
+### Other
+
+- Regenerate target info ([#1398](https://github.com/rust-lang/cc-rs/pull/1398))
+- Add support for setting `-gdwarf-{version}` based on RUSTFLAGS ([#1395](https://github.com/rust-lang/cc-rs/pull/1395))
+- Add support for alternative network stack io-sock on QNX 7.1 aarch64 and x86_64 ([#1312](https://github.com/rust-lang/cc-rs/pull/1312))
+
 ## [1.2.13](https://github.com/rust-lang/cc-rs/compare/cc-v1.2.12...cc-v1.2.13) - 2025-02-08
 
 ### Other
diff --git a/Cargo.toml b/Cargo.toml
index 0b9af92..9a7ab6c 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
 [package]
 name = "cc"
-version = "1.2.13"
+version = "1.2.14"
 authors = ["Alex Crichton <alex@alexcrichton.com>"]
 license = "MIT OR Apache-2.0"
 repository = "https://github.com/rust-lang/cc-rs"
diff --git a/src/command_helpers.rs b/src/command_helpers.rs
index 62e3662..a34067f 100644
--- a/src/command_helpers.rs
+++ b/src/command_helpers.rs
@@ -247,7 +247,6 @@ fn write_warning(line: &[u8]) {
 
 fn wait_on_child(
     cmd: &Command,
-    program: &Path,
     child: &mut Child,
     cargo_output: &CargoOutput,
 ) -> Result<(), Error> {
@@ -258,12 +257,7 @@ fn wait_on_child(
         Err(e) => {
             return Err(Error::new(
                 ErrorKind::ToolExecError,
-                format!(
-                    "Failed to wait on spawned child process, command {:?} with args {}: {}.",
-                    cmd,
-                    program.display(),
-                    e
-                ),
+                format!("failed to wait on spawned child process `{cmd:?}`: {e}"),
             ));
         }
     };
@@ -275,12 +269,7 @@ fn wait_on_child(
     } else {
         Err(Error::new(
             ErrorKind::ToolExecError,
-            format!(
-                "Command {:?} with args {} did not execute successfully (status code {}).",
-                cmd,
-                program.display(),
-                status
-            ),
+            format!("command did not execute successfully (status code {status}): {cmd:?}"),
         ))
     }
 }
@@ -350,28 +339,16 @@ pub(crate) fn objects_from_files(files: &[Arc<Path>], dst: &Path) -> Result<Vec<
     Ok(objects)
 }
 
-pub(crate) fn run(
-    cmd: &mut Command,
-    program: impl AsRef<Path>,
-    cargo_output: &CargoOutput,
-) -> Result<(), Error> {
-    let program = program.as_ref();
-
-    let mut child = spawn(cmd, program, cargo_output)?;
-    wait_on_child(cmd, program, &mut child, cargo_output)
+pub(crate) fn run(cmd: &mut Command, cargo_output: &CargoOutput) -> Result<(), Error> {
+    let mut child = spawn(cmd, cargo_output)?;
+    wait_on_child(cmd, &mut child, cargo_output)
 }
 
-pub(crate) fn run_output(
-    cmd: &mut Command,
-    program: impl AsRef<Path>,
-    cargo_output: &CargoOutput,
-) -> Result<Vec<u8>, Error> {
-    let program = program.as_ref();
-
+pub(crate) fn run_output(cmd: &mut Command, cargo_output: &CargoOutput) -> Result<Vec<u8>, Error> {
     // We specifically need the output to be captured, so override default
     let mut captured_cargo_output = cargo_output.clone();
     captured_cargo_output.output = OutputKind::Capture;
-    let mut child = spawn(cmd, program, &captured_cargo_output)?;
+    let mut child = spawn(cmd, &captured_cargo_output)?;
 
     let mut stdout = vec![];
     child
@@ -382,16 +359,12 @@ pub(crate) fn run_output(
         .unwrap();
 
     // Don't care about this output, use the normal settings
-    wait_on_child(cmd, program, &mut child, cargo_output)?;
+    wait_on_child(cmd, &mut child, cargo_output)?;
 
     Ok(stdout)
 }
 
-pub(crate) fn spawn(
-    cmd: &mut Command,
-    program: &Path,
-    cargo_output: &CargoOutput,
-) -> Result<Child, Error> {
+pub(crate) fn spawn(cmd: &mut Command, cargo_output: &CargoOutput) -> Result<Child, Error> {
     struct ResetStderr<'cmd>(&'cmd mut Command);
 
     impl Drop for ResetStderr<'_> {
@@ -414,28 +387,18 @@ pub(crate) fn spawn(
         Ok(child) => Ok(child),
         Err(ref e) if e.kind() == io::ErrorKind::NotFound => {
             let extra = if cfg!(windows) {
-                " (see https://docs.rs/cc/latest/cc/#compile-time-requirements \
-for help)"
+                " (see https://docs.rs/cc/latest/cc/#compile-time-requirements for help)"
             } else {
                 ""
             };
             Err(Error::new(
                 ErrorKind::ToolNotFound,
-                format!(
-                    "Failed to find tool. Is `{}` installed?{}",
-                    program.display(),
-                    extra
-                ),
+                format!("failed to find tool {:?}: {e}{extra}", cmd.0.get_program()),
             ))
         }
         Err(e) => Err(Error::new(
             ErrorKind::ToolExecError,
-            format!(
-                "Command {:?} with args {} failed to start: {:?}",
-                cmd.0,
-                program.display(),
-                e
-            ),
+            format!("command `{:?}` failed to start: {e}", cmd.0),
         )),
     }
 }
@@ -465,7 +428,6 @@ pub(crate) fn command_add_output_file(cmd: &mut Command, dst: &Path, args: CmdAd
 #[cfg(feature = "parallel")]
 pub(crate) fn try_wait_on_child(
     cmd: &Command,
-    program: &Path,
     child: &mut Child,
     stdout: &mut dyn io::Write,
     stderr_forwarder: &mut StderrForwarder,
@@ -483,12 +445,7 @@ pub(crate) fn try_wait_on_child(
             } else {
                 Err(Error::new(
                     ErrorKind::ToolExecError,
-                    format!(
-                        "Command {:?} with args {} did not execute successfully (status code {}).",
-                        cmd,
-                        program.display(),
-                        status
-                    ),
+                    format!("command did not execute successfully (status code {status}): {cmd:?}"),
                 ))
             }
         }
@@ -497,12 +454,7 @@ pub(crate) fn try_wait_on_child(
             stderr_forwarder.forward_all();
             Err(Error::new(
                 ErrorKind::ToolExecError,
-                format!(
-                    "Failed to wait on spawned child process, command {:?} with args {}: {}.",
-                    cmd,
-                    program.display(),
-                    e
-                ),
+                format!("failed to wait on spawned child process `{cmd:?}`: {e}"),
             ))
         }
     }
diff --git a/src/flags.rs b/src/flags.rs
index 996c647..ed552e6 100644
--- a/src/flags.rs
+++ b/src/flags.rs
@@ -18,6 +18,7 @@ pub(crate) struct RustcCodegenFlags<'a> {
     force_frame_pointers: Option<bool>,
     no_redzone: Option<bool>,
     soft_float: Option<bool>,
+    dwarf_version: Option<u32>,
 }
 
 impl<'this> RustcCodegenFlags<'this> {
@@ -86,6 +87,10 @@ impl<'this> RustcCodegenFlags<'this> {
             }
         }
 
+        fn arg_to_u32(arg: impl AsRef<str>) -> Option<u32> {
+            arg.as_ref().parse().ok()
+        }
+
         let (flag, value) = if let Some((flag, value)) = flag.split_once('=') {
             (flag, Some(value))
         } else {
@@ -148,6 +153,14 @@ impl<'this> RustcCodegenFlags<'this> {
                 self.branch_protection =
                     Some(flag_ok_or(value, "-Zbranch-protection must have a value")?);
             }
+            // https://doc.rust-lang.org/beta/unstable-book/compiler-flags/dwarf-version.html
+            // FIXME: Drop the -Z variant and update the doc link once the option is stablized
+            "-Zdwarf-version" | "-Cdwarf-version" => {
+                self.dwarf_version = Some(value.and_then(arg_to_u32).ok_or(Error::new(
+                    ErrorKind::InvalidFlag,
+                    "-Zdwarf-version must have a value",
+                ))?);
+            }
             _ => {}
         }
         Ok(())
@@ -250,6 +263,11 @@ impl<'this> RustcCodegenFlags<'this> {
                 };
                 push_if_supported(cc_flag.into());
             }
+            // https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-gdwarf-2
+            // https://gcc.gnu.org/onlinedocs/gcc/Debugging-Options.html#index-gdwarf
+            if let Some(value) = self.dwarf_version {
+                push_if_supported(format!("-gdwarf-{value}").into());
+            }
         }
 
         // Compiler-exclusive flags
@@ -390,6 +408,7 @@ mod tests {
             "-Crelocation-model=pic",
             "-Csoft-float=yes",
             "-Zbranch-protection=bti,pac-ret,leaf",
+            "-Zdwarf-version=5",
             // Set flags we don't recognise but rustc supports next
             // rustc flags
             "--cfg",
@@ -496,6 +515,7 @@ mod tests {
                 relocation_model: Some("pic"),
                 soft_float: Some(true),
                 branch_protection: Some("bti,pac-ret,leaf"),
+                dwarf_version: Some(5),
             },
         );
     }
diff --git a/src/lib.rs b/src/lib.rs
index e799802..0a0bc98 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -1594,8 +1594,8 @@ impl Build {
 
         if objs.len() <= 1 {
             for obj in objs {
-                let (mut cmd, name) = self.create_compile_object_cmd(obj)?;
-                run(&mut cmd, &name, &self.cargo_output)?;
+                let mut cmd = self.create_compile_object_cmd(obj)?;
+                run(&mut cmd, &self.cargo_output)?;
             }
 
             return Ok(());
@@ -1623,12 +1623,8 @@ impl Build {
         // acquire the appropriate tokens, Once all objects have been compiled
         // we wait on all the processes and propagate the results of compilation.
 
-        let pendings = Cell::new(Vec::<(
-            Command,
-            Cow<'static, Path>,
-            KillOnDrop,
-            parallel::job_token::JobToken,
-        )>::new());
+        let pendings =
+            Cell::new(Vec::<(Command, KillOnDrop, parallel::job_token::JobToken)>::new());
         let is_disconnected = Cell::new(false);
         let has_made_progress = Cell::new(false);
 
@@ -1649,14 +1645,8 @@ impl Build {
 
                 cell_update(&pendings, |mut pendings| {
                     // Try waiting on them.
-                    pendings.retain_mut(|(cmd, program, child, _token)| {
-                        match try_wait_on_child(
-                            cmd,
-                            program,
-                            &mut child.0,
-                            &mut stdout,
-                            &mut child.1,
-                        ) {
+                    pendings.retain_mut(|(cmd, child, _token)| {
+                        match try_wait_on_child(cmd, &mut child.0, &mut stdout, &mut child.1) {
                             Ok(Some(())) => {
                                 // Task done, remove the entry
                                 has_made_progress.set(true);
@@ -1695,14 +1685,14 @@ impl Build {
         };
         let spawn_future = async {
             for obj in objs {
-                let (mut cmd, program) = self.create_compile_object_cmd(obj)?;
+                let mut cmd = self.create_compile_object_cmd(obj)?;
                 let token = tokens.acquire().await?;
-                let mut child = spawn(&mut cmd, &program, &self.cargo_output)?;
+                let mut child = spawn(&mut cmd, &self.cargo_output)?;
                 let mut stderr_forwarder = StderrForwarder::new(&mut child);
                 stderr_forwarder.set_non_blocking()?;
 
                 cell_update(&pendings, |mut pendings| {
-                    pendings.push((cmd, program, KillOnDrop(child, stderr_forwarder), token));
+                    pendings.push((cmd, KillOnDrop(child, stderr_forwarder), token));
                     pendings
                 });
 
@@ -1741,17 +1731,14 @@ impl Build {
         check_disabled()?;
 
         for obj in objs {
-            let (mut cmd, name) = self.create_compile_object_cmd(obj)?;
-            run(&mut cmd, &name, &self.cargo_output)?;
+            let mut cmd = self.create_compile_object_cmd(obj)?;
+            run(&mut cmd, &self.cargo_output)?;
         }
 
         Ok(())
     }
 
-    fn create_compile_object_cmd(
-        &self,
-        obj: &Object,
-    ) -> Result<(Command, Cow<'static, Path>), Error> {
+    fn create_compile_object_cmd(&self, obj: &Object) -> Result<Command, Error> {
         let asm_ext = AsmFileExt::from_path(&obj.src);
         let is_asm = asm_ext.is_some();
         let target = self.get_target()?;
@@ -1761,23 +1748,14 @@ impl Build {
         let gnu = compiler.family == ToolFamily::Gnu;
 
         let is_assembler_msvc = msvc && asm_ext == Some(AsmFileExt::DotAsm);
-        let (mut cmd, name) = if is_assembler_msvc {
-            let (cmd, name) = self.msvc_macro_assembler()?;
-            (cmd, Cow::Borrowed(Path::new(name)))
+        let mut cmd = if is_assembler_msvc {
+            self.msvc_macro_assembler()?
         } else {
             let mut cmd = compiler.to_command();
             for (a, b) in self.env.iter() {
                 cmd.env(a, b);
             }
-            (
-                cmd,
-                compiler
-                    .path
-                    .file_name()
-                    .ok_or_else(|| Error::new(ErrorKind::IOError, "Failed to get compiler path."))
-                    .map(PathBuf::from)
-                    .map(Cow::Owned)?,
-            )
+            cmd
         };
         let is_arm = matches!(target.arch, "aarch64" | "arm");
         command_add_output_file(
@@ -1817,7 +1795,7 @@ impl Build {
             self.fix_env_for_apple_os(&mut cmd)?;
         }
 
-        Ok((cmd, name))
+        Ok(cmd)
     }
 
     /// This will return a result instead of panicking; see [`Self::expand()`] for
@@ -1852,12 +1830,7 @@ impl Build {
 
         cmd.args(self.files.iter().map(std::ops::Deref::deref));
 
-        let name = compiler
-            .path
-            .file_name()
-            .ok_or_else(|| Error::new(ErrorKind::IOError, "Failed to get compiler path."))?;
-
-        run_output(&mut cmd, name, &self.cargo_output)
+        run_output(&mut cmd, &self.cargo_output)
     }
 
     /// Run the compiler, returning the macro-expanded version of the input files.
@@ -2476,7 +2449,7 @@ impl Build {
         flags_env_var_value.is_ok()
     }
 
-    fn msvc_macro_assembler(&self) -> Result<(Command, &'static str), Error> {
+    fn msvc_macro_assembler(&self) -> Result<Command, Error> {
         let target = self.get_target()?;
         let tool = if target.arch == "x86_64" {
             "ml64.exe"
@@ -2531,7 +2504,7 @@ impl Build {
             cmd.arg("-safeseh");
         }
 
-        Ok((cmd, tool))
+        Ok(cmd)
     }
 
     fn assemble(&self, lib_name: &str, dst: &Path, objs: &[Object]) -> Result<(), Error> {
@@ -2559,7 +2532,7 @@ impl Build {
             let dlink = out_dir.join(lib_name.to_owned() + "_dlink.o");
             let mut nvcc = self.get_compiler().to_command();
             nvcc.arg("--device-link").arg("-o").arg(&dlink).arg(dst);
-            run(&mut nvcc, "nvcc", &self.cargo_output)?;
+            run(&mut nvcc, &self.cargo_output)?;
             self.assemble_progressive(dst, &[dlink.as_path()])?;
         }
 
@@ -2587,12 +2560,12 @@ impl Build {
             // Non-msvc targets (those using `ar`) need a separate step to add
             // the symbol table to archives since our construction command of
             // `cq` doesn't add it for us.
-            let (mut ar, cmd, _any_flags) = self.get_ar()?;
+            let mut ar = self.try_get_archiver()?;
 
             // NOTE: We add `s` even if flags were passed using $ARFLAGS/ar_flag, because `s`
             // here represents a _mode_, not an arbitrary flag. Further discussion of this choice
             // can be seen in https://github.com/rust-lang/cc-rs/pull/763.
-            run(ar.arg("s").arg(dst), &cmd, &self.cargo_output)?;
+            run(ar.arg("s").arg(dst), &self.cargo_output)?;
         }
 
         Ok(())
@@ -2601,7 +2574,7 @@ impl Build {
     fn assemble_progressive(&self, dst: &Path, objs: &[&Path]) -> Result<(), Error> {
         let target = self.get_target()?;
 
-        let (mut cmd, program, any_flags) = self.get_ar()?;
+        let (mut cmd, program, any_flags) = self.try_get_archiver_and_flags()?;
         if target.env == "msvc" && !program.to_string_lossy().contains("llvm-ar") {
             // NOTE: -out: here is an I/O flag, and so must be included even if $ARFLAGS/ar_flag is
             // in use. -nologo on the other hand is just a regular flag, and one that we'll skip if
@@ -2619,7 +2592,7 @@ impl Build {
                 cmd.arg(dst);
             }
             cmd.args(objs);
-            run(&mut cmd, &program, &self.cargo_output)?;
+            run(&mut cmd, &self.cargo_output)?;
         } else {
             // Set an environment variable to tell the OSX archiver to ensure
             // that all dates listed in the archive are zero, improving
@@ -2648,11 +2621,7 @@ impl Build {
             // NOTE: We add cq here regardless of whether $ARFLAGS/ar_flag have been used because
             // it dictates the _mode_ ar runs in, which the setter of $ARFLAGS/ar_flag can't
             // dictate. See https://github.com/rust-lang/cc-rs/pull/763 for further discussion.
-            run(
-                cmd.arg("cq").arg(dst).args(objs),
-                &program,
-                &self.cargo_output,
-            )?;
+            run(cmd.arg("cq").arg(dst).args(objs), &self.cargo_output)?;
         }
 
         Ok(())
@@ -3114,10 +3083,6 @@ impl Build {
         }
     }
 
-    fn get_ar(&self) -> Result<(Command, PathBuf, bool), Error> {
-        self.try_get_archiver_and_flags()
-    }
-
     /// Get the archiver (ar) that's in use for this configuration.
     ///
     /// You can use [`Command::get_program`] to get just the path to the command.
@@ -3764,7 +3729,6 @@ impl Build {
                 .arg("--show-sdk-path")
                 .arg("--sdk")
                 .arg(sdk),
-            "xcrun",
             &self.cargo_output,
         )?;
 
@@ -3821,7 +3785,6 @@ impl Build {
                     .arg("--show-sdk-version")
                     .arg("--sdk")
                     .arg(sdk),
-                "xcrun",
                 &self.cargo_output,
             )
             .ok()?;
@@ -3992,7 +3955,6 @@ impl Build {
     ) -> Option<PathBuf> {
         let search_dirs = run_output(
             cc.arg("-print-search-dirs"),
-            "cc",
             // this doesn't concern the compilation so we always want to show warnings.
             cargo_output,
         )
diff --git a/src/target/generated.rs b/src/target/generated.rs
index c52cf53..6b21366 100644
--- a/src/target/generated.rs
+++ b/src/target/generated.rs
@@ -508,6 +508,18 @@ pub(crate) const LIST: &[(&str, TargetInfo<'static>)] = &[
             llvm_target: "aarch64_be-unknown-netbsd",
         },
     ),
+    (
+        "amdgcn-amd-amdhsa",
+        TargetInfo {
+            full_arch: "amdgcn",
+            arch: "amdgpu",
+            vendor: "amd",
+            os: "amdhsa",
+            env: "",
+            abi: "",
+            llvm_target: "amdgcn-amd-amdhsa",
+        },
+    ),
     (
         "arm-linux-androideabi",
         TargetInfo {
@@ -1252,6 +1264,18 @@ pub(crate) const LIST: &[(&str, TargetInfo<'static>)] = &[
             llvm_target: "i586-unknown-netbsdelf",
         },
     ),
+    (
+        "i586-unknown-redox",
+        TargetInfo {
+            full_arch: "i586",
+            arch: "x86",
+            vendor: "unknown",
+            os: "redox",
+            env: "relibc",
+            abi: "",
+            llvm_target: "i586-unknown-redox",
+        },
+    ),
     (
         "i686-apple-darwin",
         TargetInfo {
@@ -1396,18 +1420,6 @@ pub(crate) const LIST: &[(&str, TargetInfo<'static>)] = &[
             llvm_target: "i686-unknown-openbsd",
         },
     ),
-    (
-        "i686-unknown-redox",
-        TargetInfo {
-            full_arch: "i686",
-            arch: "x86",
-            vendor: "unknown",
-            os: "redox",
-            env: "relibc",
-            abi: "",
-            llvm_target: "i686-unknown-redox",
-        },
-    ),
     (
         "i686-unknown-uefi",
         TargetInfo {
diff --git a/src/tool.rs b/src/tool.rs
index 04d366d..e430d28 100644
--- a/src/tool.rs
+++ b/src/tool.rs
@@ -99,7 +99,6 @@ impl Tool {
         fn is_zig_cc(path: &Path, cargo_output: &CargoOutput) -> bool {
             run_output(
                 Command::new(path).arg("--version"),
-                path,
                 // tool detection issues should always be shown as warnings
                 cargo_output,
             )
@@ -125,7 +124,6 @@ impl Tool {
             // stdin is set to null to ensure that the help output is never paginated.
             let accepts_cl_style_flags = run(
                 Command::new(path).args(args).arg("-?").stdin(Stdio::null()),
-                path,
                 &{
                     // the errors are not errors!
                     let mut cargo_output = cargo_output.clone();
@@ -202,7 +200,6 @@ impl Tool {
 
             let stdout = run_output(
                 Command::new(path).arg("-E").arg(tmp.path()),
-                path,
                 &compiler_detect_output,
             )?;
             let stdout = String::from_utf8_lossy(&stdout);
@@ -210,7 +207,6 @@ impl Tool {
             if stdout.contains("-Wslash-u-filename") {
                 let stdout = run_output(
                     Command::new(path).arg("-E").arg("--").arg(tmp.path()),
-                    path,
                     &compiler_detect_output,
                 )?;
                 let stdout = String::from_utf8_lossy(&stdout);


Test patch:
diff --git a/tests/rustflags.rs b/tests/rustflags.rs
index cee86f0..0e594f2 100644
--- a/tests/rustflags.rs
+++ b/tests/rustflags.rs
@@ -19,12 +19,13 @@ fn inherits_rustflags() {
     // Correctly inherits flags from rustc
     std::env::set_var(
         "CARGO_ENCODED_RUSTFLAGS",
-        "-Cforce-frame-pointers=true\u{1f}-Ccode-model=small\u{1f}-Csoft-float",
+        "-Cforce-frame-pointers=true\u{1f}-Ccode-model=small\u{1f}-Csoft-float\u{1f}-Cdwarf-version=5",
     );
     let test = Test::gnu();
     test.gcc().file("foo.c").compile("foo");
     test.cmd(0)
         .must_have("-fno-omit-frame-pointer")
         .must_have("-mcmodel=small")
-        .must_have("-msoft-float");
+        .must_have("-msoft-float")
+        .must_have("-gdwarf-5");
 }