rust-lang / rust

Empowering everyone to build reliable and efficient software.
https://www.rust-lang.org
Other
98.22k stars 12.7k forks source link

failed to get bitcode from object file for LTO (Bitcode section not found in object file) #94232

Open matthiaskrgr opened 2 years ago

matthiaskrgr commented 2 years ago
git clone https://github.com/rust-lang/rust-clippy
cd rust-clippy
git checkout 9e605ef80f05fbaec22677e633971096675f2650
echo "[profile.release]
codegen-units = 1
lto = true" >> Cargo.toml

cargo test --release

fails to build without any interesting details unfortunately

.....
   Compiling clippy v0.1.60 (/home/matthias/vcs/github/rust-clippy)
error: failed to get bitcode from object file for LTO (Bitcode section not found in object file)

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

with nightly-2022-02-10

Seems to happen while compiling tests: Building [=======================> ] 140/141: compile-test(test)

ehuss commented 2 years ago

I believe this is because the compiler rlib libraries do not include bitcode in them. The compile-test.rs test depends on them, so it is not possible to build that test with LTO.

It would be nice if the error message included which file was missing the information (which would be easy to add here).

aliciawyy commented 1 year ago

Hello, I have the same problem. How should we fix it?

tseli0s commented 1 year ago

Same problem here when using lto. EDIT: Seems like it was a dependency problem, removing a few dependencies (Not sure which ones but I can search git history) solved it.

virusdefender commented 1 week ago

I have the same problem when running cargo test --release, and it seems only fails in my linux builder only, works in my Mac