-
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
It looks like some #[ctor] was missing #220
Comments
Interesting. Thanks for the repro. I haven't tested anything, but perhaps it has something to do with all the functions having the same name and contents. The compiler may be aliasing them all to the same function and leaving just a single implementation. What I'd try as a next step is:
I'll see if I can get around to looking at this at some point. |
I confirmed that this is because the other file contains no other used functions. Rust is pruning the module entirely, despite it being marked as used. By adding a fake function "foo" to the |
Summary: Work around [this issue](mmastrac/rust-ctor#220): linker on macos erases `#[ctor]` calls. More details in [this workplace post](https://fb.workplace.com/groups/buck2dev/posts/3459190721035642). All `LateBinding` for `buck2` binary are initialized from `main` functions, while each test crate still have `#[ctor]` which calls the initialization: this `#[ctor]` won't be erased because there's a dummy test next to it. This workaround makes initialization verbose, and I'm not very happy about it. But it is safe: initialization is always performed before any buck2 implementation or tests, it either always work or never works. Reviewed By: krallin Differential Revision: D45845229 fbshipit-source-id: 96a4ff7d9161e45de3c698efb404047f892cf799
I came across something that wasn't easy to understand,
When I referenced a crate that used rust-ctor, It seems that not all of the functions with the #[ctor] flag in Crate are executed, looks like something has been optimized out somewhere, but it seems normal to test crate alone.
I've written an example for simplicity, https://github.com/kookyleo/a-ctor-failed-case
git clone https://github.com/kookyleo/a-ctor-failed-case.git
cd a-ctor-failed-case
cargo run
And then you can see the weird results.
I got the same results at ubuntu@x86_64 and mac@m1
The text was updated successfully, but these errors were encountered: