-
Notifications
You must be signed in to change notification settings - Fork 13.9k
Open
Labels
A-linkageArea: linking into static, shared libraries and binariesArea: linking into static, shared libraries and binariesC-bugCategory: This is a bug.Category: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
The main goal of +crt-static (at least on non-Windows targets) is to produce self-contained statically linked executables.
With this goal in mind rustc switches linking of 1) Rust crates and 2) libc to static if possible. (The libc part is done in the libraries through lazy cfgs though.)
However, for native dependencies with unspecified kind rustc will still prefer the dynamic version of the library if both are available.
Unfortunately, doing this is not entirely trivial because -Bstatic -lmylib won't just prefer the static version (e.g. libmylib.a), it will require it.
So we need to check for the existence of libmylib.a first (in which directories exactly?) and then pass -l:libmylib.a instead of -lmylib if it exists.
Metadata
Metadata
Assignees
Labels
A-linkageArea: linking into static, shared libraries and binariesArea: linking into static, shared libraries and binariesC-bugCategory: This is a bug.Category: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.