4 ms·
no I think I tried just about everything: pub, extern etc. The only thing that worked was adding a linker argumment: "-C", "link_args=--undefined=<name_of_func
by fwsgonzo 6y ago
no I think I tried just about everything: pub, extern etc.
The only thing that worked was adding a linker argumment: "-C", "link_args=--undefined=<name_of_function>"
That will force the linker to assume it's referenced.
- lzutao 6y agoIf the function you trying to keep is in non-pub module, it will be removed. Maybe you could move it out of private module: <https://rust.godbolt.org/z/PYPbG8 https://rust.godbolt.org/z/PYPbG8>. There's also an `#[used]`[1] attribute, but only for static items. If your use case is special, consider open a feature request in Rust repo. [1]: https://doc.rust-lang.org/nightly/reference/abi.html#the-used-attribute https://doc.rust-lang.org/nightly/reference/abi.html#the-use...