Skip to content

Commit be3452a

Browse files
committed
Test that TLS access works outside of the dylib it's defined in
1 parent fdbc432 commit be3452a

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

Diff for: tests/ui/auxiliary/tls-export.rs

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#![crate_type = "dylib"]
2+
#![feature(thread_local)]
3+
#![feature(cfg_target_thread_local)]
4+
5+
#[cfg(target_thread_local)]
6+
#[thread_local]
7+
pub static FOO: bool = true;
8+
9+
#[cfg(target_thread_local)]
10+
#[inline(never)]
11+
pub fn foo_addr() -> usize {
12+
&FOO as *const bool as usize
13+
}

Diff for: tests/ui/tls-dylib-access.rs

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// aux-build: tls-export.rs
2+
// run-pass
3+
4+
#![feature(cfg_target_thread_local)]
5+
6+
#[cfg(target_thread_local)]
7+
extern crate tls_export;
8+
9+
fn main() {
10+
// Check that we get the real address of the TLS in the dylib
11+
#[cfg(target_thread_local)]
12+
assert_eq!(&tls_export::FOO as *const bool as usize, tls_export::foo_addr());
13+
}

0 commit comments

Comments
 (0)