Skip to content

Rustc fails to compile a program with ThinLTO and split-debuginfo = "packed" #132677

Open
@zamazan4ik

Description

@zamazan4ik

Hi!

A person on Reddit posted a strange build error when ThinLTO is enabled. I performed additional build tests in different configurations and I can confirm the error on current Rustc compilers (see the versions below). My environment is Fedora 41 + AMD Ryzen 5900x (x86-64). The test project is https://github.com/anza-xyz/agave on the master branch with 144925eda5eba98ef28a47a659be68b93211cdb2. The test command is cargo +stable test --profile release-with-debug/cargo +nightly test --profile release-with-debug.

The original report is when ThinLTO is enabled, some binaries fail to be built with the duplicate split compilation unit error. I performed the build in multiple configurations and here are my results:

Build ok:

[profile.release-with-debug]
inherits = "release"
debug = true
#split-debuginfo = "packed"
lto = "thin"

Build ok:

[profile.release-with-debug]
inherits = "release"
debug = true
split-debuginfo = "packed"
#lto = "thin"

Build ok:

[profile.release-with-debug]
inherits = "release"
debug = true
split-debuginfo = "packed"
lto = "fat"

Build ok:

[profile.release-with-debug]
inherits = "release"
debug = true
split-debuginfo = "unpacked"
lto = "thin"

Build fails:

[profile.release-with-debug]
inherits = "release"
debug = true
split-debuginfo = "packed"
lto = "thin"

Build fails:

[profile.release-with-debug]
inherits = "release"
debug = true
split-debuginfo = "packed"
lto = "thin"
codegen-units = 1

According to the tests, the buggy is only the combination of ThinLTO and split-debuginfo = "packed". Disabling one of these options or enabling Fat LTO instead of ThinLTO resolves the issue.

I expected to see this happen: the build with lto = "thin" + split-debuginfo = "packed" is successful

Instead, this happened: the build fails with the duplicate split compilation unit error

Meta

The issue is reproduced on both Rustc versions: stable and current nightly

rustc --version --verbose:

rustc 1.82.0 (f6e511eec 2024-10-15)
binary: rustc
commit-hash: f6e511eec7342f59a25f7c0534f1dbea00d01b14
commit-date: 2024-10-15
host: x86_64-unknown-linux-gnu
release: 1.82.0
LLVM version: 19.1.1

rustc +nightly --version --verbose

rustc 1.84.0-nightly (fbab78289 2024-11-04)
binary: rustc
commit-hash: fbab78289dd8c6e8860034e0048cfb538f217700
commit-date: 2024-11-04
host: x86_64-unknown-linux-gnu
release: 1.84.0-nightly
LLVM version: 19.1.3

Providing RUST_BACKTRACE=1 doesn't give more information so no backtraces here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-LTOArea: Link-time optimization (LTO)A-codegenArea: Code generationA-debuginfoArea: Debugging information in compiled programs (DWARF, PDB, etc.)C-bugCategory: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions