-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Explicit support for whole-archive linker option #7586
Comments
ping @alexcrichton @ehuss My previous writing is not that clear. |
Here is an example of possible workaround of this topic. However, I think it is better to have this feature as standard cargo options. |
Seems like it, thanks! |
Just a note: there are still some issues with whole archive linking. However, the issues are on the rustc side, not cargo. See: |
Some libraries using
__attribute__((constructor))
suffers when their libraries are not linked viawhole-archive
linker option.However, current cargo build script does not support this functionality.
We may use
RUSTFLAGS
option to give custom linker option, however I expect that this is not a desired use case of cargo.whole-archive
is not needed when dynamically loading a shared library.(the loader explicitly invoke the constructor function)
(in static linking case, linker finds no explicit linkage so that the library is omitted)
Add another link type to cargo's
link-lib
list.Currently, we have
static
,dylib
, andframework
.As whole-archive works on static linking case, we may name it as
static-whole
.e.g.
cargo:rustc-link-lib=static-whole=foo
at the build script.I'm aware of the risk when the linker flag is fully open.
I expect that this is the reason why linker flags are not open to build scripts.
Thus, I suggest to explicit support a single type of linking:
static-whole
along with other specialized link types.Cargo internally manages the
static-whole
database.At the final linking state, cargo opens a
whole-archive
, listing allstatic-whole
libraries from the depending crates, and closeswhole-archive
.The text was updated successfully, but these errors were encountered: