[−][src]Enum inkwell::module::Linkage
This enum defines how to link a global variable or function in a module. The variant documenation is mostly taken straight from LLVM's own documentation except for some minor clarification.
It is illegal for a function declaration to have any linkage type other than external or extern_weak.
All Global Variables, Functions and Aliases can have one of the following DLL storage class: DLLImport
& DLLExport
.
Variants
Appending
Appending
linkage may only be applied to global variables of pointer to array type. When two global
variables with appending linkage are linked together, the two global arrays are appended together.
This is the LLVM, typesafe, equivalent of having the system linker append together "sections" with
identical names when .o files are linked. Unfortunately this doesn't correspond to any feature in .o
files, so it can only be used for variables like llvm.global_ctors which llvm interprets specially.
AvailableExternally
Globals with AvailableExternally
linkage are never emitted into the object file corresponding to
the LLVM module. From the linker's perspective, an AvailableExternally
global is equivalent to an
external declaration. They exist to allow inlining and other optimizations to take place given
knowledge of the definition of the global, which is known to be somewhere outside the module. Globals
with AvailableExternally
linkage are allowed to be discarded at will, and allow inlining and other
optimizations. This linkage type is only allowed on definitions, not declarations.
Common
Common
linkage is most similar to "weak" linkage, but they are used for tentative definitions
in C, such as "int X;" at global scope. Symbols with Common linkage are merged in the same way as
weak symbols, and they may not be deleted if unreferenced. Common
symbols may not have an explicit
section, must have a zero initializer, and may not be marked 'constant'. Functions and aliases may
not have Common
linkage.
DLLExport
DLLExport
causes the compiler to provide a global pointer to a pointer in a DLL, so that it can be
referenced with the dllimport attribute. On Microsoft Windows targets, the pointer name is formed by
combining _imp and the function or variable name. Since this storage class exists for defining a dll
interface, the compiler, assembler and linker know it is externally referenced and must refrain from
deleting the symbol.
DLLImport
DLLImport
causes the compiler to reference a function or variable via a global pointer to a pointer
that is set up by the DLL exporting the symbol. On Microsoft Windows targets, the pointer name is
formed by combining _imp and the function or variable name.
External
If none of the other identifiers are used, the global is externally visible, meaning that it participates in linkage and can be used to resolve external symbol references.
ExternalWeak
The semantics of this linkage follow the ELF object file model: the symbol is weak until linked, if not linked, the symbol becomes null instead of being an undefined reference.
Ghost
FIXME: Unknown linkage type
Internal
Similar to private, but the value shows as a local symbol (STB_LOCAL in the case of ELF) in the object file. This corresponds to the notion of the 'static' keyword in C.
LinkerPrivate
FIXME: Unknown linkage type
LinkerPrivateWeak
FIXME: Unknown linkage type
LinkOnceAny
Globals with LinkOnceAny
linkage are merged with other globals of the same name when linkage occurs.
This can be used to implement some forms of inline functions, templates, or other code which must be
generated in each translation unit that uses it, but where the body may be overridden with a more
definitive definition later. Unreferenced LinkOnceAny
globals are allowed to be discarded. Note that
LinkOnceAny
linkage does not actually allow the optimizer to inline the body of this function into
callers because it doesn’t know if this definition of the function is the definitive definition within
the program or whether it will be overridden by a stronger definition. To enable inlining and other
optimizations, use LinkOnceODR
linkage.
LinkOnceODRAutoHide
FIXME: Unknown linkage type
LinkOnceODR
Some languages allow differing globals to be merged, such as two functions with different semantics.
Other languages, such as C++, ensure that only equivalent globals are ever merged (the "one definition
rule" — "ODR"). Such languages can use the LinkOnceODR
and WeakODR
linkage types to indicate that
the global will only be merged with equivalent globals. These linkage types are otherwise the same
as their non-odr versions.
Private
Global values with Private
linkage are only directly accessible by objects in the current module.
In particular, linking code into a module with a private global value may cause the private to be
renamed as necessary to avoid collisions. Because the symbol is private to the module, all references
can be updated. This doesn’t show up in any symbol table in the object file.
WeakAny
WeakAny
linkage has the same merging semantics as linkonce linkage, except that unreferenced globals
with weak linkage may not be discarded. This is used for globals that are declared WeakAny in C source code.
WeakODR
Some languages allow differing globals to be merged, such as two functions with different semantics.
Other languages, such as C++, ensure that only equivalent globals are ever merged (the "one definition
rule" — "ODR"). Such languages can use the LinkOnceODR
and WeakODR
linkage types to indicate that
the global will only be merged with equivalent globals. These linkage types are otherwise the same
as their non-odr versions.
Trait Implementations
impl Eq for Linkage
[src]
impl Clone for Linkage
[src]
impl PartialOrd<Linkage> for Linkage
[src]
fn partial_cmp(&self, other: &Linkage) -> Option<Ordering>
[src]
#[must_use]
fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]
fn le(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]
fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]
fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
impl Ord for Linkage
[src]
fn cmp(&self, other: &Linkage) -> Ordering
[src]
fn max(self, other: Self) -> Self
1.21.0[src]
fn min(self, other: Self) -> Self
1.21.0[src]
fn clamp(self, min: Self, max: Self) -> Self
[src]
impl PartialEq<Linkage> for Linkage
[src]
impl Copy for Linkage
[src]
impl Debug for Linkage
[src]
Auto Trait Implementations
impl Sync for Linkage
impl Send for Linkage
impl Unpin for Linkage
impl UnwindSafe for Linkage
impl RefUnwindSafe for Linkage
Blanket Implementations
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T> From<T> for T
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,