Skip to content

Commit c83cdc6

Browse files
committed
Auto merge of #8335 - ehuss:1.45-beta-backport, r=alexcrichton
1.45 beta backports Beta backports for: * #8290 — Fix fingerprinting for lld on Windows with dylib. * #8329 — Don't hash executable filenames on apple platforms. (fix macos backtraces)
2 parents 9fcb8c1 + fcfb13c commit c83cdc6

File tree

5 files changed

+51
-8
lines changed

5 files changed

+51
-8
lines changed

src/cargo/core/compiler/context/compilation_files.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -608,6 +608,12 @@ fn should_use_metadata(bcx: &BuildContext<'_, '_>, unit: &Unit) -> bool {
608608
// - wasm32 executables: When using emscripten, the path to the .wasm file
609609
// is embedded in the .js file, so we don't want the hash in there.
610610
// TODO: Is this necessary for wasm32-unknown-unknown?
611+
// - apple executables: The executable name is used in the dSYM directory
612+
// (such as `target/debug/foo.dSYM/Contents/Resources/DWARF/foo-64db4e4bf99c12dd`).
613+
// Unfortunately this causes problems with our current backtrace
614+
// implementation which looks for a file matching the exe name exactly.
615+
// See https://github.com/rust-lang/rust/issues/72550#issuecomment-638501691
616+
// for more details.
611617
//
612618
// This is only done for local packages, as we don't expect to export
613619
// dependencies.
@@ -622,7 +628,8 @@ fn should_use_metadata(bcx: &BuildContext<'_, '_>, unit: &Unit) -> bool {
622628
if (unit.target.is_dylib()
623629
|| unit.target.is_cdylib()
624630
|| (unit.target.is_executable() && short_name.starts_with("wasm32-"))
625-
|| (unit.target.is_executable() && short_name.contains("msvc")))
631+
|| (unit.target.is_executable() && short_name.contains("msvc"))
632+
|| (unit.target.is_executable() && short_name.contains("-apple-")))
626633
&& unit.pkg.package_id().source_id().is_path()
627634
&& env::var("__CARGO_DEFAULT_LIB_METADATA").is_err()
628635
{

src/cargo/core/compiler/fingerprint.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1229,7 +1229,7 @@ fn calculate_normal(cx: &mut Context<'_, '_>, unit: &Unit) -> CargoResult<Finger
12291229
let outputs = cx
12301230
.outputs(unit)?
12311231
.iter()
1232-
.filter(|output| output.flavor != FileFlavor::DebugInfo)
1232+
.filter(|output| !matches!(output.flavor, FileFlavor::DebugInfo | FileFlavor::Auxiliary))
12331233
.map(|output| output.path.clone())
12341234
.collect();
12351235

tests/testsuite/build.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4149,7 +4149,7 @@ fn uplift_dsym_of_bin_on_mac() {
41494149
assert!(p.target_debug_dir().join("foo.dSYM").is_dir());
41504150
assert!(p.target_debug_dir().join("b.dSYM").is_dir());
41514151
assert!(p.target_debug_dir().join("b.dSYM").is_symlink());
4152-
assert!(p.target_debug_dir().join("examples/c.dSYM").is_symlink());
4152+
assert!(p.target_debug_dir().join("examples/c.dSYM").is_dir());
41534153
assert!(!p.target_debug_dir().join("c.dSYM").exists());
41544154
assert!(!p.target_debug_dir().join("d.dSYM").exists());
41554155
}

tests/testsuite/collisions.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,9 @@ This may become a hard error in the future; see <https://github.com/rust-lang/ca
9191
}
9292

9393
#[cargo_test]
94-
// --out-dir and examples are currently broken on MSVC.
94+
// --out-dir and examples are currently broken on MSVC and apple.
9595
// See https://github.com/rust-lang/cargo/issues/7493
96-
#[cfg(not(target_env = "msvc"))]
96+
#[cfg_attr(any(target_env = "msvc", target_vendor = "apple"), ignore)]
9797
fn collision_export() {
9898
// `--out-dir` combines some things which can cause conflicts.
9999
let p = project()

tests/testsuite/freshness.rs

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -491,8 +491,8 @@ fn changing_bin_features_caches_targets() {
491491
/* Targets should be cached from the first build */
492492

493493
let mut e = p.cargo("build");
494-
// MSVC does not include hash in binary filename, so it gets recompiled.
495-
if cfg!(target_env = "msvc") {
494+
// MSVC/apple does not include hash in binary filename, so it gets recompiled.
495+
if cfg!(any(target_env = "msvc", target_vendor = "apple")) {
496496
e.with_stderr("[COMPILING] foo[..]\n[FINISHED] dev[..]");
497497
} else {
498498
e.with_stderr("[FINISHED] dev[..]");
@@ -501,7 +501,7 @@ fn changing_bin_features_caches_targets() {
501501
p.rename_run("foo", "off2").with_stdout("feature off").run();
502502

503503
let mut e = p.cargo("build --features foo");
504-
if cfg!(target_env = "msvc") {
504+
if cfg!(any(target_env = "msvc", target_vendor = "apple")) {
505505
e.with_stderr("[COMPILING] foo[..]\n[FINISHED] dev[..]");
506506
} else {
507507
e.with_stderr("[FINISHED] dev[..]");
@@ -2436,3 +2436,39 @@ fn linking_interrupted() {
24362436
)
24372437
.run();
24382438
}
2439+
2440+
#[cargo_test]
2441+
#[cfg_attr(
2442+
not(all(target_arch = "x86_64", target_os = "windows", target_env = "msvc")),
2443+
ignore
2444+
)]
2445+
fn lld_is_fresh() {
2446+
// Check for bug when using lld linker that it remains fresh with dylib.
2447+
let p = project()
2448+
.file(
2449+
".cargo/config",
2450+
r#"
2451+
[target.x86_64-pc-windows-msvc]
2452+
linker = "rust-lld"
2453+
rustflags = ["-C", "link-arg=-fuse-ld=lld"]
2454+
"#,
2455+
)
2456+
.file(
2457+
"Cargo.toml",
2458+
r#"
2459+
[package]
2460+
name = "foo"
2461+
version = "0.1.0"
2462+
2463+
[lib]
2464+
crate-type = ["dylib"]
2465+
"#,
2466+
)
2467+
.file("src/lib.rs", "")
2468+
.build();
2469+
2470+
p.cargo("build").run();
2471+
p.cargo("build -v")
2472+
.with_stderr("[FRESH] foo [..]\n[FINISHED] [..]")
2473+
.run();
2474+
}

0 commit comments

Comments
 (0)