Skip to content

Commit

Permalink
Auto merge of #11347 - kamirr:fix-split-debuginfo-windows, r=weihanglo
Browse files Browse the repository at this point in the history
Fix split-debuginfo support detection

cargo assumed that if `-Csplit-debuginfo=packed` worked, all values would be correct. This however is not the case -- as of Rust 1.65.0, rustc supports `packed`, but not `unpacked` or `off` on Windows. Because of this, having `split-debuginfo="unpacked`" on Windows has caused builds to fail, as cargo assumed that the option is fine (`split-debuginfo=packed` worked), but rustc then failed when being passed `-Csplit-debuginfo=unpacked`.

Consider an empty project with the following change to `Cargo.toml`:
```toml
[profile.dev]
split-debuginfo="unpacked"
```
`cargo +1.64.0 build` will work, but `cargo +1.65.0 build` will fail with the following error message:

```
PS C:\REDACTED> cargo build
   Compiling tmp v0.1.0 (C:\REDACTED)
error: `-Csplit-debuginfo=unpacked` is unstable on this platform

error: could not compile `tmp` due to previous error
```

With this patch and 1.65.0 rustc, cargo will ignore all `split-debuginfo` settings, but with rust-lang/rust#104104 rustc (approved, awaiting merge), it will properly detect supported values for `split-debuginfo` and only ignore those that are unsupported.
  • Loading branch information
bors authored and aleasims committed Nov 22, 2023
1 parent d252bce commit 9e07464
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/cargo/core/compiler/build_context/target_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,18 @@ impl TargetInfo {
loop {
let extra_fingerprint = kind.fingerprint_hash();

// Query rustc for supported -Csplit-debuginfo values
let support_split_debuginfo = rustc
.cached_output(
rustc.workspace_process().arg("--print=split-debuginfo"),
extra_fingerprint,
)
.unwrap_or_default()
.0
.lines()
.map(String::from)
.collect();

// Query rustc for several kinds of info from each line of output:
// 0) file-names (to determine output file prefix/suffix for given crate type)
// 1) sysroot
Expand Down

0 comments on commit 9e07464

Please sign in to comment.