Skip to content

Commit 644c808

Browse files
committed
Auto merge of #7057 - hugwijst:apple-depinfo, r=ehuss
Fix overwriting .d file for binary with dSYM on apple targets. When building a binary on targets containing `-apple-`, the resulting `.d` file gets overwritten with the dependencies of the `.dSYM` file. Eg. in the changed unit test, `foo.d` would start with `p.bin(foo).with_extension("dSYM")` instead of `p.bin(foo)`. This PR fixes that problem by not generating `.d` dependency information files for outputs of the `DebugInfo` flavor.
2 parents a3eee9f + 2c488c9 commit 644c808

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

src/cargo/core/compiler/output_depinfo.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use std::path::{Path, PathBuf};
55

66
use log::debug;
77

8-
use super::{fingerprint, Context, Unit};
8+
use super::{fingerprint, Context, FileFlavor, Unit};
99
use crate::util::paths;
1010
use crate::util::{internal, CargoResult};
1111

@@ -98,7 +98,11 @@ pub fn output_depinfo<'a, 'b>(cx: &mut Context<'a, 'b>, unit: &Unit<'a>) -> Carg
9898
.map(|f| render_filename(f, basedir))
9999
.collect::<CargoResult<Vec<_>>>()?;
100100

101-
for output in cx.outputs(unit)?.iter() {
101+
for output in cx
102+
.outputs(unit)?
103+
.iter()
104+
.filter(|o| o.flavor != FileFlavor::DebugInfo)
105+
{
102106
if let Some(ref link_dst) = output.hardlink {
103107
let output_path = link_dst.with_extension("d");
104108
if success {

tests/testsuite/dep_info.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,13 @@ fn build_dep_info() {
1313
let depinfo_bin_path = &p.bin("foo").with_extension("d");
1414

1515
assert!(depinfo_bin_path.is_file());
16+
17+
let depinfo = p.read_file(depinfo_bin_path.to_str().unwrap());
18+
19+
let bin_path = p.bin("foo");
20+
let src_path = p.root().join("src").join("foo.rs");
21+
let expected_depinfo = format!("{}: {}\n", bin_path.display(), src_path.display());
22+
assert_eq!(depinfo, expected_depinfo);
1623
}
1724

1825
#[cargo_test]

0 commit comments

Comments
 (0)