Skip to content

#[thread_local] + #[no_mangle] produces a "symbol already defined" error on Windows targets #134939

Open
@saethlin

Description

@saethlin
#![feature(thread_local)]

#[no_mangle]
#[thread_local]
pub static FOO: u32 = 3;

Does not compile on x86_64-pc-windows-msvc and x86_64-pc-windows-gnu, due to:

error: symbol `FOO` is already defined
 --> lib.rs:5:1
  |
5 | pub static FOO: u32 = 3;
  | ^^^^^^^^^^^^^^^^^^^

error: aborting due to 1 previous error

Found this while working on #134777

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-thread-localsArea: Thread local storage (TLS)C-bugCategory: This is a bug.F-thread_local`#![feature(thread_local)]`O-windowsOperating system: WindowsT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions