]> git.lizzy.rs Git - rust.git/commitdiff
msvc: Fix TLS destructors
authorAlex Crichton <alex@alexcrichton.com>
Tue, 30 Jun 2015 06:28:39 +0000 (23:28 -0700)
committerAlex Crichton <alex@alexcrichton.com>
Wed, 1 Jul 2015 16:35:55 +0000 (09:35 -0700)
Just like the original article our Windows TLS support is based on predicted,
this symbol must be linked in on MSVC to pull in the necessary support for TLS
variables. This commit fixes a number of unit tests which require that TLS
destructors are run.

src/libstd/lib.rs
src/libstd/sys/windows/thread_local.rs

index 2117291817754a95503df5f4c586c486f96c20c8..73e45619774d7f99bc3d25e1809c146fc08542f4 100644 (file)
 #![cfg_attr(windows, feature(str_utf16))]
 #![cfg_attr(test, feature(float_from_str_radix, range_inclusive, float_extras))]
 #![cfg_attr(test, feature(test, rustc_private, float_consts))]
+#![cfg_attr(target_env = "msvc", feature(link_args))]
 
 // Don't link to std. We are std.
 #![no_std]
index 5002de559884d0f52773fd9fa75f914e9a2b0e76..a2dbb0f8342433524f6937daede9689abfc16768 100644 (file)
@@ -221,8 +221,8 @@ unsafe fn unregister_dtor(key: Key) -> bool {
 //
 // # The article mentions crazy stuff about "/INCLUDE"?
 //
-// It sure does! This seems to work for now, so maybe we'll just run into
-// that if we start linking with msvc?
+// It sure does! We include it below for MSVC targets, but it look like for GNU
+// targets we don't require it.
 
 #[link_section = ".CRT$XLB"]
 #[linkage = "external"]
@@ -231,6 +231,10 @@ unsafe fn unregister_dtor(key: Key) -> bool {
                                                         LPVOID) =
         on_tls_callback;
 
+#[cfg(target_env = "msvc")]
+#[link_args = "/INCLUDE:_tls_used"]
+extern {}
+
 #[allow(warnings)]
 unsafe extern "system" fn on_tls_callback(h: LPVOID,
                                           dwReason: DWORD,