Index: clang/lib/CodeGen/ItaniumCXXABI.cpp =================================================================== --- clang/lib/CodeGen/ItaniumCXXABI.cpp +++ clang/lib/CodeGen/ItaniumCXXABI.cpp @@ -2516,6 +2516,10 @@ if (!llvm::GlobalVariable::isLinkOnceLinkage(VarLinkage) && !llvm::GlobalVariable::isWeakODRLinkage(VarLinkage)) return VarLinkage; + // On Windows, WeakODR is a no-op, boiling down to the same as normal external + // linkage. + if (CGM.getTriple().isOSWindows()) + return llvm::GlobalValue::LinkOnceODRLinkage; return llvm::GlobalValue::WeakODRLinkage; } Index: clang/test/CodeGenCXX/tls-init-funcs.cpp =================================================================== --- clang/test/CodeGenCXX/tls-init-funcs.cpp +++ clang/test/CodeGenCXX/tls-init-funcs.cpp @@ -1,4 +1,5 @@ // RUN: %clang_cc1 -triple x86_64-apple-macosx10.8 -std=c++1y -S -emit-llvm %s -o - | FileCheck %s +// RUN: %clang_cc1 -triple x86_64-windows-gnu -std=c++1y -S -emit-llvm %s -o - | FileCheck %s --check-prefix=MINGW // CHECK: @a = internal thread_local global // CHECK: @_Z2vtIiE = linkonce_odr thread_local global i32 5 @@ -10,6 +11,9 @@ // CHECK-DAG: define weak_odr hidden cxx_fast_tlscc i32* @_ZTW2vtIvE() // CHECK-DAG: define {{.*}} @_ZTW1a +// MINGW-DAG: define linkonce_odr hidden i32* @_ZTW2vtIiE() +// MINGW-DAG: define linkonce_odr hidden i32* @_ZTW2vtIvE() + struct A { ~A(); };