Skip to content

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

Description

@mauricelam

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions