Apparently needs-dynamic-linking is not equivalent to checking if dylib or cdylib crate types are supported.
- In compiletest,
needs-dynamic-linking performs a check based on target cfg's dynamic_linking field + --print=cfg --target $TARGET.
- However, target cfg has an additional field
only_cdylib which, if dynamic_linking is true, indicates that only cdylib crate type is supported and not dylib.
|
/// Whether dynamic linking is available on this target. Defaults to false. |
|
pub dynamic_linking: bool, |
|
/// Whether dynamic linking can export TLS globals. Defaults to true. |
|
pub dll_tls_export: bool, |
|
/// If dynamic linking is available, whether only cdylibs are supported. |
|
pub only_cdylib: bool, |
- This is the case for
wasm base, dynamic linking is supported but not dylib crate type, only cdylib is supported.
|
// we allow dynamic linking, but only cdylibs. Basically we allow a |
|
// final library artifact that exports some symbols (a wasm module) but |
|
// we don't allow intermediate `dylib` crate types |
|
dynamic_linking: true, |
|
only_cdylib: true, |
Originally posted by @jieyouxu in #130860 (comment)
Apparently
needs-dynamic-linkingis not equivalent to checking if dylib or cdylib crate types are supported.needs-dynamic-linkingperforms a check based on target cfg'sdynamic_linkingfield +--print=cfg --target $TARGET.only_cdylibwhich, ifdynamic_linkingistrue, indicates that onlycdylibcrate type is supported and notdylib.rust/compiler/rustc_target/src/spec/mod.rs
Lines 2148 to 2153 in f2becdf
wasmbase, dynamic linking is supported but notdylibcrate type, onlycdylibis supported.rust/compiler/rustc_target/src/spec/base/wasm.rs
Lines 58 to 62 in f2becdf
Originally posted by @jieyouxu in #130860 (comment)