Auto merge of #111698 - Amanieu:force-static-lib, r=petrochenkov
Force all native libraries to be statically linked when linking a static binary Previously, `#[link]` without an explicit `kind = "static"` would confuse the linker and end up producing a dynamically linked library because of the `-Bdynamic` flag. However this binary would not work correctly anyways since it was linked with startup code for a static binary. This PR solves this by forcing all native libraries to be statically linked when the output is a static binary that cannot link to dynamic libraries anyways. Fixes #108878 Fixes #102993
This commit is contained in:
commit
f383703e32
3 changed files with 47 additions and 6 deletions
|
@ -675,6 +675,17 @@ impl LinkOutputKind {
|
|||
_ => return None,
|
||||
})
|
||||
}
|
||||
|
||||
pub fn can_link_dylib(self) -> bool {
|
||||
match self {
|
||||
LinkOutputKind::StaticNoPicExe | LinkOutputKind::StaticPicExe => false,
|
||||
LinkOutputKind::DynamicNoPicExe
|
||||
| LinkOutputKind::DynamicPicExe
|
||||
| LinkOutputKind::DynamicDylib
|
||||
| LinkOutputKind::StaticDylib
|
||||
| LinkOutputKind::WasiReactorExe => true,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Display for LinkOutputKind {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue