diff options
| author | Amanieu d'Antras <amanieu@gmail.com> | 2020-06-06 18:26:15 +0100 |
|---|---|---|
| committer | Amanieu d'Antras <amanieu@gmail.com> | 2020-06-06 18:26:15 +0100 |
| commit | e9b67d281a3a1e740217ded7df9fc292f5ba6559 (patch) | |
| tree | 5c61b1f84f5aa9def736cae2c0adf9bff45e3aee | |
| parent | 826cb062a659f7b719a8a0ab1497a78229318aab (diff) | |
| download | rust-e9b67d281a3a1e740217ded7df9fc292f5ba6559.tar.gz rust-e9b67d281a3a1e740217ded7df9fc292f5ba6559.zip | |
Fix link error with #[thread_local] introduced by #71192
| -rw-r--r-- | src/librustc_mir/monomorphize/collector.rs | 8 | ||||
| -rw-r--r-- | src/test/ui/tls.rs | 12 |
2 files changed, 20 insertions, 0 deletions
diff --git a/src/librustc_mir/monomorphize/collector.rs b/src/librustc_mir/monomorphize/collector.rs index 297b899ef0b..e0e9bea5eb2 100644 --- a/src/librustc_mir/monomorphize/collector.rs +++ b/src/librustc_mir/monomorphize/collector.rs @@ -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 */ } } diff --git a/src/test/ui/tls.rs b/src/test/ui/tls.rs new file mode 100644 index 00000000000..cfc94c10c9e --- /dev/null +++ b/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); +} |
