File tree Expand file tree Collapse file tree 3 files changed +49
-0
lines changed Expand file tree Collapse file tree 3 files changed +49
-0
lines changed Original file line number Diff line number Diff line change 1+ #![ crate_type = "dylib" ]
2+ #![ feature( thread_local) ]
3+ #![ feature( cfg_target_thread_local) ]
4+ #![ cfg( target_thread_local) ]
5+
6+ extern crate tls_rlib;
7+
8+ pub use tls_rlib:: * ;
9+
10+ #[ thread_local]
11+ pub static FOO : bool = true ;
12+
13+ #[ inline( never) ]
14+ pub fn foo_addr ( ) -> usize {
15+ & FOO as * const bool as usize
16+ }
Original file line number Diff line number Diff line change 1+ // no-prefer-dynamic
2+
3+ #![ crate_type = "rlib" ]
4+ #![ feature( thread_local) ]
5+ #![ feature( cfg_target_thread_local) ]
6+ #![ cfg( target_thread_local) ]
7+
8+ #[ thread_local]
9+ pub static BAR : bool = true ;
10+
11+ #[ inline( never) ]
12+ pub fn bar_addr ( ) -> usize {
13+ & BAR as * const bool as usize
14+ }
Original file line number Diff line number Diff line change 1+ // aux-build: tls-rlib.rs
2+ // aux-build: tls-export.rs
3+ // run-pass
4+
5+ #![ feature( cfg_target_thread_local) ]
6+
7+ #[ cfg( target_thread_local) ]
8+ extern crate tls_export;
9+
10+ fn main ( ) {
11+ #[ cfg( target_thread_local) ]
12+ {
13+ // Check that we get the real address of the `FOO` TLS in the dylib
14+ assert_eq ! ( & tls_export:: FOO as * const bool as usize , tls_export:: foo_addr( ) ) ;
15+
16+ // Check that we get the real address of the `BAR` TLS in the rlib linked into the dylib
17+ assert_eq ! ( & tls_export:: BAR as * const bool as usize , tls_export:: bar_addr( ) ) ;
18+ }
19+ }
You can’t perform that action at this time.
0 commit comments