Skip to content

Commit

Permalink
Fix link error with #[thread_local] introduced by #71192
Browse files Browse the repository at this point in the history
  • Loading branch information
Amanieu committed Jun 6, 2020
1 parent 826cb06 commit e9b67d2
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/librustc_mir/monomorphize/collector.rs
Expand Up @@ -586,6 +586,14 @@ impl<'a, 'tcx> MirVisitor<'tcx> for MirNeighborCollector<'a, 'tcx> {
self.output.push(create_fn_mono_item(instance));
}
}
mir::Rvalue::ThreadLocalRef(def_id) => {
assert!(self.tcx.is_thread_local_static(def_id));
let instance = Instance::mono(self.tcx, def_id);
if should_monomorphize_locally(self.tcx, &instance) {
trace!("collecting thread-local static {:?}", def_id);
self.output.push(MonoItem::Static(def_id));
}
}
_ => { /* not interesting */ }
}

Expand Down
12 changes: 12 additions & 0 deletions src/test/ui/tls.rs
@@ -0,0 +1,12 @@
// run-pass

#![feature(thread_local)]

#[thread_local]
static S: u32 = 222;

fn main() {
let local = &S as *const u32 as usize;
let foreign = std::thread::spawn(|| &S as *const u32 as usize).join().unwrap();
assert_ne!(local, foreign);
}

0 comments on commit e9b67d2

Please sign in to comment.