Incorrect information about `link` attribute on `extern` blocks
Opened this issue · 1 comments
[items.extern.attributes.link.intro] states:
The link attribute specifies the name of a native library that the compiler should link with for the items within an extern block.
The incorrect part of this statement is for the items within an extern block. The link attribute seems to behave exactly like rustc-link-lib which just adds a linker argument to link against another library. The current wording in the reference implies that it will only try to link the items within that specific extern block to the library, but any external symbol could be resolved by that library.
Example
/// Empty extern block
#[link(name = "foo")]
unsafe extern "C" {}
/// Extern block with no `link`
unsafe extern "C" {
/// This is a function in `libfoo`
fn bar();
}bar will be resolved with its implementation in the foo library, despite the link attribute being on a different extern block
Also, conversely, I believe that (unless you have an explicit link_ordinal attribute on windows), symbols in a #[link] extern block can be resolved by any library, and not just the linked-in one.