Skip to content

ctor not running for statically linked C library #280

Description

@vsbogd

Very similar to #27. I am opening it to ask for help in understanding what exactly doesn't work here.

I have a project with the following structure:

  • Rust library which uses ctor;
  • static C API library, which is compiled by cargo and cbindgen and depends on the Rust library with ctor

When C API library is built in release mode and linked to the executable binary then ctor is successfully called on start. If library is build in debug mode then ctor function is not included into the final binary by the linker while it is still present in a static library itself.

I use absolutely same minimal gcc options to try both debug and release:

gcc ./main.c -o ./debug -I. -L./c/target/debug -l:libhyperonc.a -lm

I have tried to repeat the issue building a minimal example from scratch but in minimal example it works correctly.

Platform: Linux x86_64
ctor version 0.2.0
Rust version 1.69.0
GCC version 12.2.1
LD version 2.40

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions