-
Notifications
You must be signed in to change notification settings - Fork 552
Open
Labels
A-attributesArea: AttributesArea: Attributes
Description
[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
Metadata
Metadata
Assignees
Labels
A-attributesArea: AttributesArea: Attributes