fc5db2cd4f
`-Zlink-directives=no` will ignored `#[link]` directives while compiling a crate, so nothing is emitted into the crate's metadata. The assumption is that the build system already knows about the crate's native dependencies and can provide them at link time without these directives. This is another way to address issue # #70093, which is currently addressed by `-Zlink-native-libraries` (implemented in #70095). The latter is implemented at link time, which has the effect of ignoring `#[link]` in *every* crate. This makes it a very large hammer as it requires all native dependencies to be known to the build system to be at all usable, including those in sysroot libraries. I think this means its effectively unused, and definitely under-used. Being able to control this on a crate-by-crate basis should make it much easier to apply when needed. I'm not sure if we need both mechanisms, but we can decide that later.
11 lines
381 B
Rust
11 lines
381 B
Rust
// run-pass
|
|
// compile-flags: -Zlink-directives=no
|
|
// ignore-windows - this will probably only work on unixish systems
|
|
// ignore-fuchsia - missing __libc_start_main for some reason (#84733)
|
|
// ignore-cross-compile - default-linker-libraries=yes doesn't play well with cross compiling
|
|
|
|
#[link(name = "some-random-non-existent-library", kind = "static")]
|
|
extern "C" {}
|
|
|
|
fn main() {}
|