You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We are facing a strange issue while building rust static library with "-Clinker-plugin-lto". On linking the generated library to C base results in linker error as below.
Fatal error: L6120U: Member mylibv7a.mylibv7a.e0989cce-cgu.0.rcgu.o in library libmylibv7a.so cannot be loaded. It is an LLVM bitcode file but the linker only accepts bitcode wrapped in an ELF object file.
When we checked more it is observed that the ELF header is corrupted in generated library.
arm-none-eabi-readelf -a liblib.a >test.out
readelf: Error: Not an ELF file - it has the wrong magic bytes at the start
How exactly are you invoking the linker? Do you use clang -flto=thin -fuse-ld=lld for this? Are you using a clang version matching the LLVM version used by rustc?
When we checked more it is observed that the ELF header is corrupted in generated library.
It isn't corrupted. Readelf is made for elf files, not llvm bitcode files.
Below error is when we use Arm DS5 toolchain.
Fatal error: L6120U: Member mylibv7a.mylibv7a.e0989cce-cgu.0.rcgu.o in library libmylibv7a.so cannot be loaded. It is an LLVM bitcode file but the linker only accepts bitcode wrapped in an ELF object file.
LLVM version is 13.0 for both Rust version 1.56.0 and Arm DS5 tool chain.
Why I said the llvm bitcode file is corrupted is due to the fact that ELF wrapping of first object file in object entries is only missing, remain all object files in it is properly wrapped.
https://llvm.org/docs/BitCodeFormat.html Section: Native Object File Wrapper Format
readelf could read any elf file even the wrapped, however it may not be able read the rest of the llvm bitcode.
Here in this case generated lib is corrupted and hence its not able to read it, same in case of DS5.
Also my local sample program, builds with arm-none-eabi, its the same error there also.
Greatings!!
We are facing a strange issue while building rust static library with "-Clinker-plugin-lto". On linking the generated library to C base results in linker error as below.
Fatal error: L6120U: Member mylibv7a.mylibv7a.e0989cce-cgu.0.rcgu.o in library libmylibv7a.so cannot be loaded. It is an LLVM bitcode file but the linker only accepts bitcode wrapped in an ELF object file.
When we checked more it is observed that the ELF header is corrupted in generated library.
Additional Details:
rustc --version
rustc 1.57.0 (f1edd04 2021-11-29)
Build command:
rustc -Clinker-plugin-lto --crate-type=staticlib src/lib.rs --target=armv7a-none-eabi
Looks like this issue is there with all targets, kindly please look into this issue on priority and suggest us a fix to resolve it.
Thanks
Siju
The text was updated successfully, but these errors were encountered: