Skip to content

Static Library with LTO option not working properly #91624

Open
@sijupunnnoose

Description

@sijupunnnoose

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.

arm-none-eabi-readelf -a liblib.a >test.out
readelf: Error: Not an ELF file - it has the wrong magic bytes at the start

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-LTOArea: Link-time optimization (LTO)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions