You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
a (static) library crate (let's call it static_library here) uses #[ctor], and
that (static) library doesn't have any public items. Instead, its only purpose is to run its functionality at start (with #[ctor]), and
a consumer binary imports/declares that (static) library in its Cargo.toml's [dependencies], but it doesn't have use static_library;nor#[allow(unused)] use static_library;, then
the function(s) in static_library marked with #[ctor] are not run (at least not on x64 Linux).
If the binary has use static_library; or #[allow(unused)] use static_library; then the #[ctor] function(s) from static_library are run as expected.
Such a use is probably rare, so this may not need any action/investigation, and a note in documentation may be enough.
FYI: I've tried with #[constructor(65535)] of static_init crate (current 1.0.3) instead of rust-ctor, and it has the same problem/limitation. Without use (of the static library) functions marked with #[constructor(...)] are not run.
Even when I use static_init's#[dynamic(drop)] together with #[used], expressions that generate initial values of such statics is not run (again, if I don't use the static library).
(I may migrate always-abort to depend on static_init instead of ctor, but there are no emotions here. Thank you for ctor.)
The text was updated successfully, but these errors were encountered:
Thanks Matt for
rust-ctor
.Situation:
static_library
here) uses#[ctor]
, and#[ctor]
), andCargo.toml
's[dependencies]
, but it doesn't haveuse static_library;
nor#[allow(unused)] use static_library;
, thenstatic_library
marked with#[ctor]
are not run (at least not on x64 Linux).If the binary has
use static_library;
or#[allow(unused)] use static_library;
then the#[ctor]
function(s) fromstatic_library
are run as expected.Such a use is probably rare, so this may not need any action/investigation, and a note in documentation may be enough.
FYI: I've tried with
#[constructor(65535)]
ofstatic_init
crate (current1.0.3
) instead ofrust-ctor
, and it has the same problem/limitation. Withoutuse
(of the static library) functions marked with#[constructor(...)]
are not run.Even when I use
static_init's
#[dynamic(drop)]
together with#[used]
, expressions that generate initial values of such statics is not run (again, if I don'tuse
the static library).(I may migrate
always-abort
to depend onstatic_init
instead ofctor
, but there are no emotions here. Thank you forctor
.)The text was updated successfully, but these errors were encountered: