Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
vlovich opened this issue Nov 3, 2022 · 19 comments · Fixed by #104105
Closed

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

vlovich opened this issue Nov 3, 2022 · 19 comments · Fixed by #104105
Labels
A-debuginfo Area: Debugging information in compiled programs (DWARF, PDB, etc.) C-bug Category: This is a bug.

Comments

@vlovich
Copy link

vlovich commented Nov 3, 2022

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)

@vlovich vlovich added the C-bug Category: This is a bug. label Nov 3, 2022
@davidli2010
Copy link

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

@vlovich
Copy link
Author

vlovich commented Nov 3, 2022

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

@davidli2010
Copy link

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

@ItsEthra
Copy link

ItsEthra commented Nov 3, 2022

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
Copy link
Contributor

ehuss commented Nov 4, 2022

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
Copy link

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

@tchollingsworth
Copy link

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/github.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/github.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/github.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
Copy link
Author

vlovich commented Nov 4, 2022

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

@ehuss ehuss changed the title split-debuginfo = "unpacked" fails in release build linux split-dwarf fails with -Clinker-plugin-lto Nov 5, 2022
@ehuss
Copy link
Contributor

ehuss commented Nov 5, 2022

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?)

@ehuss ehuss added the A-debuginfo Area: Debugging information in compiled programs (DWARF, PDB, etc.) label Nov 5, 2022
@marmeladema
Copy link
Contributor

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

@davidtwco
Copy link
Member

Submitted #104105 to fix this.

@michaelwoerister
Copy link
Member

Thanks for the ping and the great pre-investigation, @ehuss!

Manishearth added a commit to Manishearth/rust that referenced this issue Nov 10, 2022
…elwoerister

llvm: dwo only emitted when object code emitted

Fixes rust-lang#103932.

`CompiledModule` should not think a DWARF object was emitted when a bitcode-only compilation has happened, this can confuse archive file creation (which expects to create an archive containing non-existent dwo files).

r? `@michaelwoerister`
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Nov 10, 2022
…elwoerister

llvm: dwo only emitted when object code emitted

Fixes rust-lang#103932.

`CompiledModule` should not think a DWARF object was emitted when a bitcode-only compilation has happened, this can confuse archive file creation (which expects to create an archive containing non-existent dwo files).

r? ``@michaelwoerister``
Manishearth added a commit to Manishearth/rust that referenced this issue Nov 11, 2022
…elwoerister

llvm: dwo only emitted when object code emitted

Fixes rust-lang#103932.

`CompiledModule` should not think a DWARF object was emitted when a bitcode-only compilation has happened, this can confuse archive file creation (which expects to create an archive containing non-existent dwo files).

r? ``@michaelwoerister``
Manishearth added a commit to Manishearth/rust that referenced this issue Nov 11, 2022
…elwoerister

llvm: dwo only emitted when object code emitted

Fixes rust-lang#103932.

`CompiledModule` should not think a DWARF object was emitted when a bitcode-only compilation has happened, this can confuse archive file creation (which expects to create an archive containing non-existent dwo files).

r? ```@michaelwoerister```
Manishearth added a commit to Manishearth/rust that referenced this issue Nov 11, 2022
…elwoerister

llvm: dwo only emitted when object code emitted

Fixes rust-lang#103932.

`CompiledModule` should not think a DWARF object was emitted when a bitcode-only compilation has happened, this can confuse archive file creation (which expects to create an archive containing non-existent dwo files).

r? ````@michaelwoerister````
Manishearth added a commit to Manishearth/rust that referenced this issue Nov 12, 2022
…elwoerister

llvm: dwo only emitted when object code emitted

Fixes rust-lang#103932.

`CompiledModule` should not think a DWARF object was emitted when a bitcode-only compilation has happened, this can confuse archive file creation (which expects to create an archive containing non-existent dwo files).

r? `````@michaelwoerister`````
@Shnatsel
Copy link
Member

I am encountering this on cargo install without LTO. (Or at least I'm not explicitly enabling LTO, and I don't have LTO enabled in ~/.cargo/config.toml). Builds in local projects work fine, only cargo install is affected.

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

Adding the following to ~/.cargo/config.toml triggers it:

[target.x86_64-unknown-linux-gnu]
rustflags = ["-Csplit-debuginfo=packed"]

Should I open a new issue, or do you want to track this together with the LTO case?

@ehuss
Copy link
Contributor

ehuss commented Nov 13, 2022

@Shnatsel Can you put together a reproduction? Also, it might help to post the output of --verbose with your cargo install command (along with the exact command you are running).

@Shnatsel
Copy link
Member

Shnatsel commented Nov 13, 2022

Here are the outputs of cargo install --verbose:

Successful run
$ cargo install rustfilt --force --verbose
    Updating crates.io index
  Installing rustfilt v0.2.1
   Compiling libc v0.2.137
   Compiling memchr v2.5.0
   Compiling unicode-width v0.1.10
   Compiling bitflags v1.3.2
     Running `rustc --crate-name build_script_build /home/shnatsel/.cargo/registry/src/github.com-1ecc6299db9ec823/libc-0.2.137/build.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --crate-type bin --emit=dep-info,link -C embed-bitcode=no -C debug-assertions=off --cfg 'feature="default"' --cfg 'feature="std"' -C metadata=d85166fb06ca004c -C extra-filename=-d85166fb06ca004c --out-dir /tmp/cargo-installJNHGjk/release/build/libc-d85166fb06ca004c -C linker=clang -L dependency=/tmp/cargo-installJNHGjk/release/deps --cap-lints allow -C link-arg=-fuse-ld=/home/shnatsel/Code/mold-1.7.0-x86_64-linux/bin/mold`
     Running `rustc --crate-name build_script_build --edition=2018 /home/shnatsel/.cargo/registry/src/github.com-1ecc6299db9ec823/memchr-2.5.0/build.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --crate-type bin --emit=dep-info,link -C embed-bitcode=no -C debug-assertions=off --cfg 'feature="default"' --cfg 'feature="std"' -C metadata=88d0c53e2b65722b -C extra-filename=-88d0c53e2b65722b --out-dir /tmp/cargo-installJNHGjk/release/build/memchr-88d0c53e2b65722b -C linker=clang -L dependency=/tmp/cargo-installJNHGjk/release/deps --cap-lints allow -C link-arg=-fuse-ld=/home/shnatsel/Code/mold-1.7.0-x86_64-linux/bin/mold`
     Running `rustc --crate-name unicode_width /home/shnatsel/.cargo/registry/src/github.com-1ecc6299db9ec823/unicode-width-0.1.10/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 --cfg 'feature="default"' -C metadata=11e76149b1936834 -C extra-filename=-11e76149b1936834 --out-dir /tmp/cargo-installJNHGjk/release/deps -C linker=clang -L dependency=/tmp/cargo-installJNHGjk/release/deps --cap-lints allow -C link-arg=-fuse-ld=/home/shnatsel/Code/mold-1.7.0-x86_64-linux/bin/mold`
     Running `rustc --crate-name bitflags --edition=2018 /home/shnatsel/.cargo/registry/src/github.com-1ecc6299db9ec823/bitflags-1.3.2/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 --cfg 'feature="default"' -C metadata=d46765a3b633fb20 -C extra-filename=-d46765a3b633fb20 --out-dir /tmp/cargo-installJNHGjk/release/deps -C linker=clang -L dependency=/tmp/cargo-installJNHGjk/release/deps --cap-lints allow -C link-arg=-fuse-ld=/home/shnatsel/Code/mold-1.7.0-x86_64-linux/bin/mold`
   Compiling regex-syntax v0.6.28
     Running `rustc --crate-name regex_syntax --edition=2018 /home/shnatsel/.cargo/registry/src/github.com-1ecc6299db9ec823/regex-syntax-0.6.28/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 --cfg 'feature="default"' --cfg 'feature="unicode"' --cfg 'feature="unicode-age"' --cfg 'feature="unicode-bool"' --cfg 'feature="unicode-case"' --cfg 'feature="unicode-gencat"' --cfg 'feature="unicode-perl"' --cfg 'feature="unicode-script"' --cfg 'feature="unicode-segment"' -C metadata=e35256232c1948d0 -C extra-filename=-e35256232c1948d0 --out-dir /tmp/cargo-installJNHGjk/release/deps -C linker=clang -L dependency=/tmp/cargo-installJNHGjk/release/deps --cap-lints allow -C link-arg=-fuse-ld=/home/shnatsel/Code/mold-1.7.0-x86_64-linux/bin/mold`
   Compiling lazy_static v1.4.0
     Running `rustc --crate-name lazy_static /home/shnatsel/.cargo/registry/src/github.com-1ecc6299db9ec823/lazy_static-1.4.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 metadata=7ee925333c77e06a -C extra-filename=-7ee925333c77e06a --out-dir /tmp/cargo-installJNHGjk/release/deps -C linker=clang -L dependency=/tmp/cargo-installJNHGjk/release/deps --cap-lints allow -C link-arg=-fuse-ld=/home/shnatsel/Code/mold-1.7.0-x86_64-linux/bin/mold`
   Compiling rustc-demangle v0.1.21
     Running `rustc --crate-name rustc_demangle /home/shnatsel/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-demangle-0.1.21/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 metadata=15612936f7fef5e0 -C extra-filename=-15612936f7fef5e0 --out-dir /tmp/cargo-installJNHGjk/release/deps -C linker=clang -L dependency=/tmp/cargo-installJNHGjk/release/deps --cap-lints allow -C link-arg=-fuse-ld=/home/shnatsel/Code/mold-1.7.0-x86_64-linux/bin/mold`
     Running `/tmp/cargo-installJNHGjk/release/build/memchr-88d0c53e2b65722b/build-script-build`
     Running `rustc --crate-name memchr --edition=2018 /home/shnatsel/.cargo/registry/src/github.com-1ecc6299db9ec823/memchr-2.5.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 --cfg 'feature="default"' --cfg 'feature="std"' -C metadata=6e01bdf3860805eb -C extra-filename=-6e01bdf3860805eb --out-dir /tmp/cargo-installJNHGjk/release/deps -C linker=clang -L dependency=/tmp/cargo-installJNHGjk/release/deps --cap-lints allow -C link-arg=-fuse-ld=/home/shnatsel/Code/mold-1.7.0-x86_64-linux/bin/mold --cfg memchr_runtime_simd --cfg memchr_runtime_sse2 --cfg memchr_runtime_sse42 --cfg memchr_runtime_avx`
     Running `/tmp/cargo-installJNHGjk/release/build/libc-d85166fb06ca004c/build-script-build`
     Running `rustc --crate-name libc /home/shnatsel/.cargo/registry/src/github.com-1ecc6299db9ec823/libc-0.2.137/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 --cfg 'feature="default"' --cfg 'feature="std"' -C metadata=a9605eacbbd6e178 -C extra-filename=-a9605eacbbd6e178 --out-dir /tmp/cargo-installJNHGjk/release/deps -C linker=clang -L dependency=/tmp/cargo-installJNHGjk/release/deps --cap-lints allow -C link-arg=-fuse-ld=/home/shnatsel/Code/mold-1.7.0-x86_64-linux/bin/mold --cfg freebsd11 --cfg libc_priv_mod_use --cfg libc_union --cfg libc_const_size_of --cfg libc_align --cfg libc_int128 --cfg libc_core_cvoid --cfg libc_packedN --cfg libc_cfg_target_vendor --cfg libc_non_exhaustive --cfg libc_ptr_addr_of --cfg libc_underscore_const_names --cfg libc_const_extern_fn`
   Compiling term_size v0.3.2
     Running `rustc --crate-name term_size /home/shnatsel/.cargo/registry/src/github.com-1ecc6299db9ec823/term_size-0.3.2/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 --cfg 'feature="default"' -C metadata=4a30d455725d4ab2 -C extra-filename=-4a30d455725d4ab2 --out-dir /tmp/cargo-installJNHGjk/release/deps -C linker=clang -L dependency=/tmp/cargo-installJNHGjk/release/deps --extern libc=/tmp/cargo-installJNHGjk/release/deps/liblibc-a9605eacbbd6e178.rmeta --cap-lints allow -C link-arg=-fuse-ld=/home/shnatsel/Code/mold-1.7.0-x86_64-linux/bin/mold`
   Compiling aho-corasick v0.7.19
     Running `rustc --crate-name aho_corasick --edition=2018 /home/shnatsel/.cargo/registry/src/github.com-1ecc6299db9ec823/aho-corasick-0.7.19/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 --cfg 'feature="default"' --cfg 'feature="std"' -C metadata=264eef3857a19106 -C extra-filename=-264eef3857a19106 --out-dir /tmp/cargo-installJNHGjk/release/deps -C linker=clang -L dependency=/tmp/cargo-installJNHGjk/release/deps --extern memchr=/tmp/cargo-installJNHGjk/release/deps/libmemchr-6e01bdf3860805eb.rmeta --cap-lints allow -C link-arg=-fuse-ld=/home/shnatsel/Code/mold-1.7.0-x86_64-linux/bin/mold`
   Compiling textwrap v0.11.0
     Running `rustc --crate-name textwrap /home/shnatsel/.cargo/registry/src/github.com-1ecc6299db9ec823/textwrap-0.11.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 --cfg 'feature="term_size"' -C metadata=d236928f06fe9291 -C extra-filename=-d236928f06fe9291 --out-dir /tmp/cargo-installJNHGjk/release/deps -C linker=clang -L dependency=/tmp/cargo-installJNHGjk/release/deps --extern term_size=/tmp/cargo-installJNHGjk/release/deps/libterm_size-4a30d455725d4ab2.rmeta --extern unicode_width=/tmp/cargo-installJNHGjk/release/deps/libunicode_width-11e76149b1936834.rmeta --cap-lints allow -C link-arg=-fuse-ld=/home/shnatsel/Code/mold-1.7.0-x86_64-linux/bin/mold`
   Compiling clap v2.34.0
     Running `rustc --crate-name clap --edition=2018 /home/shnatsel/.cargo/registry/src/github.com-1ecc6299db9ec823/clap-2.34.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 --cfg 'feature="term_size"' --cfg 'feature="wrap_help"' -C metadata=43a72a8ebe0ba1ec -C extra-filename=-43a72a8ebe0ba1ec --out-dir /tmp/cargo-installJNHGjk/release/deps -C linker=clang -L dependency=/tmp/cargo-installJNHGjk/release/deps --extern bitflags=/tmp/cargo-installJNHGjk/release/deps/libbitflags-d46765a3b633fb20.rmeta --extern term_size=/tmp/cargo-installJNHGjk/release/deps/libterm_size-4a30d455725d4ab2.rmeta --extern textwrap=/tmp/cargo-installJNHGjk/release/deps/libtextwrap-d236928f06fe9291.rmeta --extern unicode_width=/tmp/cargo-installJNHGjk/release/deps/libunicode_width-11e76149b1936834.rmeta --cap-lints allow -C link-arg=-fuse-ld=/home/shnatsel/Code/mold-1.7.0-x86_64-linux/bin/mold`
   Compiling regex v1.7.0
     Running `rustc --crate-name regex --edition=2018 /home/shnatsel/.cargo/registry/src/github.com-1ecc6299db9ec823/regex-1.7.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 --cfg 'feature="aho-corasick"' --cfg 'feature="default"' --cfg 'feature="memchr"' --cfg 'feature="perf"' --cfg 'feature="perf-cache"' --cfg 'feature="perf-dfa"' --cfg 'feature="perf-inline"' --cfg 'feature="perf-literal"' --cfg 'feature="std"' --cfg 'feature="unicode"' --cfg 'feature="unicode-age"' --cfg 'feature="unicode-bool"' --cfg 'feature="unicode-case"' --cfg 'feature="unicode-gencat"' --cfg 'feature="unicode-perl"' --cfg 'feature="unicode-script"' --cfg 'feature="unicode-segment"' -C metadata=edca3c761c44f9e3 -C extra-filename=-edca3c761c44f9e3 --out-dir /tmp/cargo-installJNHGjk/release/deps -C linker=clang -L dependency=/tmp/cargo-installJNHGjk/release/deps --extern aho_corasick=/tmp/cargo-installJNHGjk/release/deps/libaho_corasick-264eef3857a19106.rmeta --extern memchr=/tmp/cargo-installJNHGjk/release/deps/libmemchr-6e01bdf3860805eb.rmeta --extern regex_syntax=/tmp/cargo-installJNHGjk/release/deps/libregex_syntax-e35256232c1948d0.rmeta --cap-lints allow -C link-arg=-fuse-ld=/home/shnatsel/Code/mold-1.7.0-x86_64-linux/bin/mold`
   Compiling rustfilt v0.2.1
     Running `rustc --crate-name rustfilt /home/shnatsel/.cargo/registry/src/github.com-1ecc6299db9ec823/rustfilt-0.2.1/src/main.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --crate-type bin --emit=dep-info,link -C opt-level=3 -C lto -C metadata=9446a90ba4cc0a16 -C extra-filename=-9446a90ba4cc0a16 --out-dir /tmp/cargo-installJNHGjk/release/deps -C linker=clang -L dependency=/tmp/cargo-installJNHGjk/release/deps --extern clap=/tmp/cargo-installJNHGjk/release/deps/libclap-43a72a8ebe0ba1ec.rlib --extern lazy_static=/tmp/cargo-installJNHGjk/release/deps/liblazy_static-7ee925333c77e06a.rlib --extern regex=/tmp/cargo-installJNHGjk/release/deps/libregex-edca3c761c44f9e3.rlib --extern rustc_demangle=/tmp/cargo-installJNHGjk/release/deps/librustc_demangle-15612936f7fef5e0.rlib --cap-lints allow -C link-arg=-fuse-ld=/home/shnatsel/Code/mold-1.7.0-x86_64-linux/bin/mold`
    Finished release [optimized] target(s) in 25.49s
   Replacing /home/shnatsel/.cargo/bin/rustfilt
    Replaced package `rustfilt v0.2.1` with `rustfilt v0.2.1` (executable `rustfilt`)
Failed run
$ cargo install rustfilt --force --verbose
    Updating crates.io index
  Installing rustfilt v0.2.1
   Compiling libc v0.2.137
   Compiling memchr v2.5.0
   Compiling unicode-width v0.1.10
   Compiling regex-syntax v0.6.28
     Running `rustc --crate-name build_script_build /home/shnatsel/.cargo/registry/src/github.com-1ecc6299db9ec823/libc-0.2.137/build.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --crate-type bin --emit=dep-info,link -C embed-bitcode=no -C debug-assertions=off --cfg 'feature="default"' --cfg 'feature="std"' -C metadata=d85166fb06ca004c -C extra-filename=-d85166fb06ca004c --out-dir /tmp/cargo-installsUrxpw/release/build/libc-d85166fb06ca004c -L dependency=/tmp/cargo-installsUrxpw/release/deps --cap-lints allow -Csplit-debuginfo=packed`
     Running `rustc --crate-name unicode_width /home/shnatsel/.cargo/registry/src/github.com-1ecc6299db9ec823/unicode-width-0.1.10/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 --cfg 'feature="default"' -C metadata=11e76149b1936834 -C extra-filename=-11e76149b1936834 --out-dir /tmp/cargo-installsUrxpw/release/deps -L dependency=/tmp/cargo-installsUrxpw/release/deps --cap-lints allow -Csplit-debuginfo=packed`
     Running `rustc --crate-name build_script_build --edition=2018 /home/shnatsel/.cargo/registry/src/github.com-1ecc6299db9ec823/memchr-2.5.0/build.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --crate-type bin --emit=dep-info,link -C embed-bitcode=no -C debug-assertions=off --cfg 'feature="default"' --cfg 'feature="std"' -C metadata=88d0c53e2b65722b -C extra-filename=-88d0c53e2b65722b --out-dir /tmp/cargo-installsUrxpw/release/build/memchr-88d0c53e2b65722b -L dependency=/tmp/cargo-installsUrxpw/release/deps --cap-lints allow -Csplit-debuginfo=packed`
     Running `rustc --crate-name regex_syntax --edition=2018 /home/shnatsel/.cargo/registry/src/github.com-1ecc6299db9ec823/regex-syntax-0.6.28/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 --cfg 'feature="default"' --cfg 'feature="unicode"' --cfg 'feature="unicode-age"' --cfg 'feature="unicode-bool"' --cfg 'feature="unicode-case"' --cfg 'feature="unicode-gencat"' --cfg 'feature="unicode-perl"' --cfg 'feature="unicode-script"' --cfg 'feature="unicode-segment"' -C metadata=e35256232c1948d0 -C extra-filename=-e35256232c1948d0 --out-dir /tmp/cargo-installsUrxpw/release/deps -L dependency=/tmp/cargo-installsUrxpw/release/deps --cap-lints allow -Csplit-debuginfo=packed`
error: failed to build archive: No such file or directory

error: could not compile `unicode-width` due to previous error

Caused by:
  process didn't exit successfully: `rustc --crate-name unicode_width /home/shnatsel/.cargo/registry/src/github.com-1ecc6299db9ec823/unicode-width-0.1.10/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 --cfg 'feature="default"' -C metadata=11e76149b1936834 -C extra-filename=-11e76149b1936834 --out-dir /tmp/cargo-installsUrxpw/release/deps -L dependency=/tmp/cargo-installsUrxpw/release/deps --cap-lints allow -Csplit-debuginfo=packed` (exit status: 1)
warning: build failed, waiting for other jobs to finish...
error: could not compile `regex-syntax` due to previous error

Caused by:
  process didn't exit successfully: `rustc --crate-name regex_syntax --edition=2018 /home/shnatsel/.cargo/registry/src/github.com-1ecc6299db9ec823/regex-syntax-0.6.28/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 --cfg 'feature="default"' --cfg 'feature="unicode"' --cfg 'feature="unicode-age"' --cfg 'feature="unicode-bool"' --cfg 'feature="unicode-case"' --cfg 'feature="unicode-gencat"' --cfg 'feature="unicode-perl"' --cfg 'feature="unicode-script"' --cfg 'feature="unicode-segment"' -C metadata=e35256232c1948d0 -C extra-filename=-e35256232c1948d0 --out-dir /tmp/cargo-installsUrxpw/release/deps -L dependency=/tmp/cargo-installsUrxpw/release/deps --cap-lints allow -Csplit-debuginfo=packed` (exit status: 1)
error: failed to compile `rustfilt v0.2.1`, intermediate artifacts can be found at `/tmp/cargo-installsUrxpw`

I imagine simply running Ubuntu 20.04 and adding this to ~/.cargo/config.toml should do the trick:

[target.x86_64-unknown-linux-gnu]
rustflags = ["-Csplit-debuginfo=packed"]

But I'll verify it and let you know.

@Shnatsel
Copy link
Member

Yes, I've verified that this is reproducible on a clean Ubuntu 20.04 installation or live CD.

Other than the commands above you need to sudo apt install curl build-essential and install Rust through rustup.rs

@Shnatsel
Copy link
Member

Oh, I see that the failed run does contain the -C linker-plugin-lto flag. So it is the same issue.

I'm confused why cargo install implicitly enables it by default while other invocations don't, but that's a separate issue.

@ehuss
Copy link
Contributor

ehuss commented Nov 14, 2022

rustfilt sets LTO here. I don't know what other commands you are running, but if it is cargo build, then that would use the dev profile without LTO.

@bors bors closed this as completed in e284780 Nov 14, 2022
@punkeel
Copy link

punkeel commented Nov 30, 2022

Up on @marmeladema's message:

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-debuginfo Area: Debugging information in compiled programs (DWARF, PDB, etc.) C-bug Category: This is a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.