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

error: Did not find ELF magic number on latest nightly #109

Open
mauricelam opened this issue Dec 6, 2023 · 0 comments
Open

error: Did not find ELF magic number on latest nightly #109

mauricelam opened this issue Dec 6, 2023 · 0 comments

Comments

@mauricelam
Copy link

mauricelam commented Dec 6, 2023

When running cargo call-stack using the latest nightly, it fails with error: Did not find ELF magic number.

Repro steps:

  1. rustup install nightly-2023-12-02
  2. rustup component add rust-src --toolchain nightly-2023-12-02-x86_64-unknown-linux-gnu
  3. cd cargo-call-stack/firmware
  4. cargo +nightly-2023-12-02 call-stack --example function-pointer --target thumbv7m-none-eabi > cg.dot
$ cargo +nightly-2023-12-02 call-stack --example function-pointer --target thumbv7m-none-eabi > cg.dot
 Downloading crates ...
  Downloaded hashbrown v0.14.2
   Compiling compiler_builtins v0.1.103
   Compiling core v0.0.0 (/usr/local/google/home/yukl/.rustup/toolchains/nightly-2023-12-02-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core)
   Compiling rustc-std-workspace-core v1.99.0 (/usr/local/google/home/yukl/.rustup/toolchains/nightly-2023-12-02-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/rustc-std-workspace-core)
   Compiling alloc v0.0.0 (/usr/local/google/home/yukl/.rustup/toolchains/nightly-2023-12-02-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc)
   Compiling panic-halt v0.2.0
   Compiling firmware v0.1.0 (/usr/local/google/home/yukl/cargo-call-stack/firmware)
    Finished release [optimized + debuginfo] target(s) in 11.44s
error: Did not find ELF magic number

cargo bisect-rustc shows the culprit as rust-lang/rust@8c2b577

As far as I can tell, it is failing when trying to read the .o file inside target/thumbv7m-none-eabi/release/deps/libcompiler_builtins-7f005ebede32330f.rlib, because it is LLVM IR bitcode, not an ELF file

$ ar x target/thumbv7m-none-eabi/release/deps/libcompiler_builtins-7f005ebede32330f.rlib
$ file compiler_builtins-7f005ebede32330f.compiler_builtins.5df481aafd5f48ed-cgu.0.rcgu.o
compiler_builtins-7f005ebede32330f.compiler_builtins.5df481aafd5f48ed-cgu.0.rcgu.o: LLVM IR bitcode

I don't really understand what rust-lang/rust#113923 is doing, and weren't able to find configuration flags that would make rustc revert back to creating ELF file for compiler_builtins. Any suggestions for a fix or workaround would be appreciated.

mauricelam pushed a commit to mauricelam/cargo-call-stack that referenced this issue Dec 6, 2023
Instead of exiting when failed to read compiler_builtins objects, just
log an error and continue. This is a temporary workaround for
japaric#109.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant