cargo-call-stack
cargo-call-stack copied to clipboard
Failed to get bitcode from object file for LTO
When trying to use the tool I get the following error:
cargo +nightly call-stack --bin fedra --verbose
"cargo" "rustc" "--bin" "fedra" "--release" "--" "--emit=llvm-ir,obj" "-C" "embed-bitcode=yes" "-C" "lto=fat" "-Z" "emit-stack-sizes"
Compiling fedra v0.1.0 (/Users/jiayihu/Desktop/Repo/fedra-clone)
error: failed to get bitcode from object file for LTO (Bitcode section not found in object file)
rustc --version
rustc 1.50.0-nightly (593fe977a 2020-11-20)
Same error even with the previous nightly rustc 1.49.0-nightly (b1496c6e6 2020-10-18)
Ironically if I try RUSTFLAGS="-C embed-bitcode"
as said in #25 , it gives a different error:
error: BUG: failed to parse .ll file; please submit a bug report with Rust source code. Details (include the _first_ LLVM item, e.g. `define .. { .. }`, in the report):
Failure(("%0 = type { [0 x i32], { {}*, [3 x i32]* }, [0 x i32], i8*, [0 x i32] }\n%1 = type { [0 x i32], %2, [0 x i32], i8*, [0 x i8], i8, [3 x i8] }\n%2 = type { [0 x i32], %\"rtt_target::rtt::RttChannel\"*, [0 x i32], i32, [0 x i32], i32, [0 x i8], i8, [3 x i8] }\n%3 = type { [0 x i32], %\"alloc::string::String\", [0 x i32] }\n%4 = type { [0 x i32], %\"core::fmt::Formatter\"*, [0 x i32], i32, [0 x i8], i8, [0 x i8], i8, [2 x i8] }\n%5 = type { [0 x i32], %\"core::fmt::Formatter\"*, [0 x i8], i8, [0 x i8], i8, [2 x i8] }\n%6 = type { [0 x i8], i8, [11 x i8] }\n%7 = type { [0 x i32], %8, [0 x i32], i32, [0 x i32] }\n%8 = type { [0 x i32], %9, [0 x i32], %9, [0 x i32] }\n%9 = type { [1 x i32], {}*, [1 x i32] }\n%10 = type { [0 x i8], {}, [0 x i8], i32*, [0 x i32], i32*, [0 x i32], i32, [0 x i32] }\n%11 = type { [0 x i32], %\"smoltcp::wire::Icmpv4Repr\", [0 x i32] }\n%12 = type { [0 x i32], i32, [0 x i32], i32, [0 x i32], %13, [0 x i32] }\n%13 = type { [0 x i32], %\"parity_wasm::el
[...]
Any update on fixing this issue?
I got the same issue. May I know the progress of this issue ? I got exactly the same issue with @jiayihu. Hi @jiayihu do you get the solution ?
Sorry @ysun, no luck
@jiayihu Then did you get any other solution to get rust call-graph ?
We have also observed this error:
BUG: failed to parse .ll file: Failure(("define internal fastcc void @_Z....
The following is a MRE.
Run this command:
RUSTFLAGS = "-C embed-bitcode" cargo +nightly call-stack --example rme > mre.dot
With this code as examples/mre.rs
:
use lazy_static::lazy_static;
use rand::distributions::{Distribution, Uniform};
use std::time::Duration;
use tokio::time::{sleep, Instant};
lazy_static! { static ref START_TIME: Instant = Instant::now(); }
#[tokio::main]
async fn main() {
let page = get_page(42).await;
println!("Page #42: {:?}", page);
}
async fn get_page(i: usize) -> Vec<usize> {
let millis = Uniform::from(5_000..6_000).sample(&mut rand::thread_rng());
println!( "[{}] # get_page({}) will complete in {} ms on {:?}",
START_TIME.elapsed().as_millis(),
i,
millis,
std::thread::current().id()
);
sleep(Duration::from_millis(millis)).await;
println!("[{}] # get_page({}) completed",
START_TIME.elapsed().as_millis(),
i
);
(10 * i..10 * (i + 1)).collect()
}
Observing the same on the "hello world" created via cargo new
.
cargo +nightly call-stack --bin hello --target x86_64-unknown-linux-gnu > hello.dot
-
Exporting
RUSTFLAGS="-C embed-bitcode"
results in:error: failed to parse application's LLVM IR from `/tst/helloworld/target/x86_64-unknown-linux-gnu/release/deps/hello-f16df3c84b67da29.ll`: BUG: failed to parse LLVM IR; please submit a cargo-call-stack bug report and attach the `.ll` file: Failure("Eof in line 970")
.ll
file is attached to this message: hello-ll.zip -
Using LTO leads to the same problem.
-
Not using either yields the error:
error: failed to get bitcode from object file for LTO (Bitcode section not found in object file)
@jiayihu , looks suspiciously similar to what @taqtiqa-mark is experiencing in https://github.com/japaric/cargo-call-stack/issues/33
This issue seems to only affect Cargo project using the default release
profile. To get pass the "Bitcode section not found in object file" error enable fat LTO in Cargo.toml -- this is a workaround
[profile.release]
lto = 'fat'
A fix may be adding -C embed-bitcode=yes
to each rustc invocation; either that or remove the -C embed-bitcode=no
that gets passed to rustc by default (when lto = 'thin').
after enabling fat LTO I get a LLVM IR parser error when running cargo-call-stack on a "Hello, world" project but that's a separate issue from this.