Introduce target feature crt_static_allows_dylibs
Most UNIX-like platforms do not allow shared libraries to statically link their own libc, as libc expects to have consistent process-global state. On those platforms, when we do not have a shared libc available, we must not attempt to link dylibs or cdylibs. On Windows, however, it is expected to statically link the CRT into dynamic libraries. This feature is only relevant for targets that support both fully-static and fully-dynamic linkage, such as musl on Linux.
This commit is contained in:
parent
beb8abe9a5
commit
12ceed013c
3 changed files with 11 additions and 2 deletions
|
|
@ -123,8 +123,11 @@ pub fn invalid_output_for_target(sess: &Session,
|
|||
match (sess.target.target.options.dynamic_linking,
|
||||
sess.target.target.options.executables, crate_type) {
|
||||
(false, _, config::CrateTypeCdylib) |
|
||||
(false, _, config::CrateTypeProcMacro) |
|
||||
(false, _, config::CrateTypeDylib) => true,
|
||||
(false, _, config::CrateTypeDylib) |
|
||||
(false, _, config::CrateTypeProcMacro) => true,
|
||||
(true, _, config::CrateTypeCdylib) |
|
||||
(true, _, config::CrateTypeDylib) => sess.crt_static() &&
|
||||
!sess.target.target.options.crt_static_allows_dylibs,
|
||||
(_, false, config::CrateTypeExecutable) => true,
|
||||
_ => false
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue