cargo-xbuild: error: failed to get bitcode from object file for LTO

Hello. I use cargo xbuild to build my OS. Recently build failed with the following error message.

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

My repository is this and cargo_settings.json is specified as the target. You can reproduce this by running make on the master branch. I also tried with phil-opp’s .json file, but build failed. The only thing which made it possible to build is to disable lto ( lto = false in Cargo.toml) . cargo clean && cargo xbuild did not solve the problem. This is my CI history. You can see that the same commit succeeds and fails to build.

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 23 (20 by maintainers)

Most upvoted comments

Seems like I messed something up… I can also still reproduce the error. I’ll take a look at it again right now.

Fixed version released as v0.5.31.

I created a minimal example to reproduce: https://github.com/toku-sa-n/cargo_bug cargo xbuild should cause the error.

I’m currently investigating: this looks to be the culprit https://github.com/rust-lang/cargo/pull/8192.

Compiling with rlib enabled in Cargo.toml works, produces the following rustc flags:

-Cembed-bitcode=no

With rlib removed we get:

-C lto

Manually running rustc with -C lto replaced with -C linker-plugin-lto seems to work okay.

I’ll look a bit further but that is what I’ve figured out so far.