Auto merge of #108089 - Zoxc:windows-tls, r=bjorn3
Support TLS access into dylibs on Windows This allows access to `#[thread_local]` in upstream dylibs on Windows by introducing a MIR shim to return the address of the thread local. Accesses that go into an upstream dylib will call the MIR shim to get the address of it. `convert_tls_rvalues` is introduced in `rustc_codegen_ssa` which rewrites MIR TLS accesses to dummy calls which are replaced with calls to the MIR shims when the dummy calls are lowered to backend calls. A new `dll_tls_export` target option enables this behavior with a `false` value which is set for Windows platforms. This fixes https://github.com/rust-lang/rust/issues/84933.
This commit is contained in:
commit
f98598c6cd
28 changed files with 262 additions and 95 deletions
|
@ -1471,6 +1471,8 @@ pub struct TargetOptions {
|
|||
pub features: StaticCow<str>,
|
||||
/// Whether dynamic linking is available on this target. Defaults to false.
|
||||
pub dynamic_linking: bool,
|
||||
/// Whether dynamic linking can export TLS globals. Defaults to true.
|
||||
pub dll_tls_export: bool,
|
||||
/// If dynamic linking is available, whether only cdylibs are supported.
|
||||
pub only_cdylib: bool,
|
||||
/// Whether executables are available on this target. Defaults to true.
|
||||
|
@ -1865,6 +1867,7 @@ impl Default for TargetOptions {
|
|||
cpu: "generic".into(),
|
||||
features: "".into(),
|
||||
dynamic_linking: false,
|
||||
dll_tls_export: true,
|
||||
only_cdylib: false,
|
||||
executables: true,
|
||||
relocation_model: RelocModel::Pic,
|
||||
|
@ -2537,6 +2540,7 @@ impl Target {
|
|||
key!(cpu);
|
||||
key!(features);
|
||||
key!(dynamic_linking, bool);
|
||||
key!(dll_tls_export, bool);
|
||||
key!(only_cdylib, bool);
|
||||
key!(executables, bool);
|
||||
key!(relocation_model, RelocModel)?;
|
||||
|
@ -2791,6 +2795,7 @@ impl ToJson for Target {
|
|||
target_option_val!(cpu);
|
||||
target_option_val!(features);
|
||||
target_option_val!(dynamic_linking);
|
||||
target_option_val!(dll_tls_export);
|
||||
target_option_val!(only_cdylib);
|
||||
target_option_val!(executables);
|
||||
target_option_val!(relocation_model);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue