Auto merge of #30856 - mneumann:thread_local_extern, r=alexcrichton
This will correctly add the thread_local attribute to the external static variable ```errno```:
```rust
extern {
#[thread_local]
static errno: c_int;
}
```
Before this commit, the thread_local attribute is ignored. Fixes #30795.
Thanks @alexcrichton for pointing out the solution.
This commit is contained in:
commit
798ce4ab59
3 changed files with 55 additions and 2 deletions
17
src/test/auxiliary/thread-local-extern-static.rs
Normal file
17
src/test/auxiliary/thread-local-extern-static.rs
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#![feature(thread_local)]
|
||||
#![feature(cfg_target_thread_local)]
|
||||
#![crate_type = "lib"]
|
||||
|
||||
#[no_mangle]
|
||||
#[cfg_attr(target_thread_local, thread_local)]
|
||||
pub static FOO: u32 = 3;
|
||||
26
src/test/run-pass/thread-local-extern-static.rs
Normal file
26
src/test/run-pass/thread-local-extern-static.rs
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// ignore-windows
|
||||
// aux-build:thread-local-extern-static.rs
|
||||
|
||||
#![feature(thread_local)]
|
||||
#![feature(cfg_target_thread_local)]
|
||||
|
||||
extern crate thread_local_extern_static;
|
||||
|
||||
extern {
|
||||
#[cfg_attr(target_thread_local, thread_local)]
|
||||
static FOO: u32;
|
||||
}
|
||||
|
||||
fn main() {
|
||||
assert_eq!(FOO, 3);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue