-
Notifications
You must be signed in to change notification settings - Fork 49
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
ctor not running for statically linked C library #280
Comments
@vsbogd Try with the new 0.2.1 and |
I receive an error when try using
Do I miss something? |
You'll need to add a feature to
|
Thanks @mmastrac . I also needed to add Unfortunately it doesn't help. I still can see
and cannot see it in executable linked with
|
This issue is still present today. At least in my case, the issue seems to be related to the # Cargo.toml
# ...
[profile.dev]
codegen-units = 16 |
Messing with codegen-units unfortunately doesn't seem to be a surefire way of solving this problem. The only way I've found to keep the initializer around was to have a static variable that Rust thinks might be touched by the code run from main. |
What pattern ended up working for you? |
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:
ctor
;cargo
andcbindgen
and depends on the Rust library withctor
When C API library is built in
release
mode and linked to the executable binary thenctor
is successfully called on start. If library is build indebug
mode thenctor
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 bothdebug
andrelease
: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
The text was updated successfully, but these errors were encountered: