Skip to content

linux split-dwarf fails with -Clinker-plugin-lto #103932

Closed
@vlovich

Description

@vlovich

When I add split-debuginfo = "unpacked" to my profile.release in Cargo.toml (on Linux), my build fails with:

error: failed to build archive: No such file or directory

error: could not compile `cfg-if` due to previous error
warning: build failed, waiting for other jobs to finish...

In debug I initially had the same problem but a cargo clean fixed it without requiring me to turn off split-debuginfo. However, release continues to be failing even after cargo clean.

Meta

rustc --version
rustc 1.65.0 (897e375 2022-11-02)
cargo --version
cargo 1.65.0 (4bc8f24d3 2022-10-20)

Activity

davidli2010

davidli2010 commented on Nov 3, 2022

@davidli2010

It's silent in my macOS in release profile, but no dSYM generated. It's OK in dev profile.

vlovich

vlovich commented on Nov 3, 2022

@vlovich
Author

Oh not sure if it matters, but I also have debug = true set for my release build.

davidli2010

davidli2010 commented on Nov 3, 2022

@davidli2010

Thanks for your reminder. I forgot that debug is off by default in release profile.

ItsEthra

ItsEthra commented on Nov 3, 2022

@ItsEthra

Can confirm this happens for me as well but with split-debuginfo=packed.

error: failed to build archive: No such file or directory

error: could not compile `static_assertions` due to previous error
warning: build failed, waiting for other jobs to finish...
error: could not compile `lazy_static` due to previous error

rustc 1.65.0 (897e37553 2022-11-02)
cargo 1.65.0 (4bc8f24d3 2022-10-20

ehuss

ehuss commented on Nov 4, 2022

@ehuss
Contributor

Can you provide some more information, such as the target you are building for (x86_64-unknown-linux-gnu?), the output of rustc --version --verbose, and anything else that might help narrow down the issue? Is your profile exactly this?

[profile.release]
split-debuginfo = "unpacked"
debug = true
filialpails

filialpails commented on Nov 4, 2022

@filialpails

I got this same error when I tried compiling with both split debug info and linker plugin LTO.

tchollingsworth

tchollingsworth commented on Nov 4, 2022

@tchollingsworth

also need LTO enabled, works fine without here

% cargo new repro
% cd repro
% cat <<EOF >> Cargo.toml
log = "0.4.17"

[profile.release]
lto = true # or "thin"
debug = true
split-debuginfo = "unpacked" # or "packed"
EOF
% cargo build --release --verbose
   Compiling log v0.4.17
   Compiling cfg-if v1.0.0
     Running `rustc --crate-name build_script_build /home/tc/.cargo/registry/src/6github.com-1ecc6299db9ec823/log-0.4.17/build.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --crate-type bin --emit=dep-info,link -C embed-bitcode=no -C split-debuginfo=packed -C debuginfo=2 -C debug-assertions=off -C metadata=3d94976ee9c5caca -C extra-filename=-3d94976ee9c5caca --out-dir /home/tc/dev/repro/target/release/build/log-3d94976ee9c5caca -L dependency=/home/tc/dev/repro/target/release/deps --cap-lints allow`
     Running `rustc --crate-name cfg_if --edition=2018 /home/tc/.cargo/registry/src/6github.com-1ecc6299db9ec823/cfg-if-1.0.0/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --crate-type lib --emit=dep-info,metadata,link -C opt-level=3 -C linker-plugin-lto -C split-debuginfo=packed -C debuginfo=2 -C metadata=9e1e3997dce77d3a -C extra-filename=-9e1e3997dce77d3a --out-dir /home/tc/dev/repro/target/release/deps -L dependency=/home/tc/dev/repro/target/release/deps --cap-lints allow`
error: failed to build archive: No such file or directory

error: could not compile `cfg-if` due to previous error

Caused by:
  process didn't exit successfully: `rustc --crate-name cfg_if --edition=2018 /home/tc/.cargo/registry/src/6github.com-1ecc6299db9ec823/cfg-if-1.0.0/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --crate-type lib --emit=dep-info,metadata,link -C opt-level=3 -C linker-plugin-lto -C split-debuginfo=packed -C debuginfo=2 -C metadata=9e1e3997dce77d3a -C extra-filename=-9e1e3997dce77d3a --out-dir /home/tc/dev/repro/target/release/deps -L dependency=/home/tc/dev/repro/target/release/deps --cap-lints allow` (exit status: 1)
warning: build failed, waiting for other jobs to finish...
% rustc --version --verbose
rustc 1.65.0 (897e37553 2022-11-02)
binary: rustc
commit-hash: 897e37553bba8b42751c67658967889d11ecd120
commit-date: 2022-11-02
host: x86_64-unknown-linux-gnu
release: 1.65.0
LLVM version: 15.0.0
% rustup show
Default host: x86_64-unknown-linux-gnu
rustup home:  /home/tc/.rustup

stable-x86_64-unknown-linux-gnu (default)
rustc 1.65.0 (897e37553 2022-11-02)
vlovich

vlovich commented on Nov 4, 2022

@vlovich
Author

Thanks @tchollingsworth for clarifying. Yeah, I do have LTO on as well.

changed the title [-]`split-debuginfo = "unpacked"` fails in release build[/-] [+]linux split-dwarf fails with `-Clinker-plugin-lto`[/+] on Nov 5, 2022
ehuss

ehuss commented on Nov 5, 2022

@ehuss
Contributor

cc @davidtwco or @michaelwoerister in case this didn't hit your radar.

The reproduction is:

touch foo.rs
rustc --crate-type=rlib -Csplit-debuginfo=packed -Clinker-plugin-lto foo.rs

with the error:

error: failed to build archive: No such file or directory

error: aborting due to previous error

From what I can tell, the archiver is expecting a .dwo file to exist (added around here). AFAIK, that doesn't make sense with a bitcode-only output. The decision of whether or not a dwo is expected I think is made around here. I'm guessing that decision (or perhaps something at a higher level) needs to be aware that the split-dwarf won't happen with bitcode-only output? (IOW, that case should only be true if write_output_file was called with a dwo_out value with Some?)

added
A-debuginfoArea: Debugging information in compiled programs (DWARF, PDB, etc.)
on Nov 5, 2022
marmeladema

marmeladema commented on Nov 5, 2022

@marmeladema
Contributor

Should this issue be marked as a stable-to-stable regression?

20 remaining items

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-debuginfoArea: Debugging information in compiled programs (DWARF, PDB, etc.)C-bugCategory: This is a bug.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      Participants

      @ehuss@vlovich@Shnatsel@tchollingsworth@davidtwco

      Issue actions

        linux split-dwarf fails with `-Clinker-plugin-lto` · Issue #103932 · rust-lang/rust