1
Fork 0

Support TLS access into dylibs on Windows

This commit is contained in:
John Kåre Alsaker 2023-02-03 09:04:12 +01:00
parent 51c93553d4
commit 0d89c6a2d4
23 changed files with 207 additions and 47 deletions

View file

@ -1468,6 +1468,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.
@ -1859,6 +1861,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,
@ -2530,6 +2533,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)?;
@ -2783,6 +2787,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);

View file

@ -8,6 +8,7 @@ pub fn opts() -> TargetOptions {
TargetOptions {
linker_flavor: LinkerFlavor::Msvc(Lld::No),
dll_tls_export: false,
is_like_windows: true,
is_like_msvc: true,
pre_link_args,

View file

@ -78,6 +78,7 @@ pub fn opts() -> TargetOptions {
function_sections: false,
linker: Some("gcc".into()),
dynamic_linking: true,
dll_tls_export: false,
dll_prefix: "".into(),
dll_suffix: ".dll".into(),
exe_suffix: ".exe".into(),

View file

@ -23,6 +23,7 @@ pub fn opts() -> TargetOptions {
abi: "llvm".into(),
linker: Some("clang".into()),
dynamic_linking: true,
dll_tls_export: false,
dll_prefix: "".into(),
dll_suffix: ".dll".into(),
exe_suffix: ".exe".into(),