699b33d060
It is often convenient to have forms of weak linkage or other various types of linkage. Sadly, just using these flavors of linkage are not compatible with Rust's typesystem and how it considers some pointers to be non-null. As a compromise, this commit adds support for weak linkage to external symbols, but it requires that this is only placed on extern statics of type `*T`. Codegen-wise, we get translations like: // rust code extern { #[linkage = "extern_weak"] static foo: *i32; } // generated IR @foo = extern_weak global i32 @_some_internal_symbol = internal global *i32 @foo All references to the rust value of `foo` then reference `_some_internal_symbol` instead of the symbol `_foo` itself. This allows us to guarantee that the address of `foo` will never be null while the value may sometimes be null. An example was implemented in `std::rt::thread` to determine if `__pthread_get_minstack()` is available at runtime, and a test is checked in to use it for a static value as well. Function pointers a little odd because you still need to transmute the pointer value to a function pointer, but it's thankfully better than not having this capability at all. |
||
---|---|---|
.. | ||
borrowck | ||
cfg | ||
trans | ||
typeck | ||
astencode.rs | ||
check_const.rs | ||
check_loop.rs | ||
check_match.rs | ||
check_static.rs | ||
const_eval.rs | ||
dataflow.rs | ||
dead.rs | ||
effect.rs | ||
entry.rs | ||
freevars.rs | ||
graph.rs | ||
kind.rs | ||
lang_items.rs | ||
lint.rs | ||
liveness.rs | ||
mem_categorization.rs | ||
moves.rs | ||
pat_util.rs | ||
privacy.rs | ||
reachable.rs | ||
region.rs | ||
resolve_lifetime.rs | ||
resolve.rs | ||
subst.rs | ||
ty_fold.rs | ||
ty.rs |