Skip to content

Commit a3d52ea

Browse files
authored
[Cygwin] RTTI and VTable should be dllexport-ed (#139798)
Behaves as same as both of Clang and GCC targetting MinGW. Required for compatibility for Cygwin-GCC. Divided from #138773
1 parent 76d866f commit a3d52ea

File tree

8 files changed

+20
-10
lines changed

8 files changed

+20
-10
lines changed

clang/lib/CodeGen/ItaniumCXXABI.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3754,7 +3754,7 @@ static bool ShouldUseExternalRTTIDescriptor(CodeGenModule &CGM,
37543754
bool IsDLLImport = RD->hasAttr<DLLImportAttr>();
37553755

37563756
// Don't import the RTTI but emit it locally.
3757-
if (CGM.getTriple().isWindowsGNUEnvironment())
3757+
if (CGM.getTriple().isOSCygMing())
37583758
return false;
37593759

37603760
if (CGM.getVTables().isVTableExternal(RD)) {
@@ -4041,10 +4041,7 @@ static llvm::GlobalVariable::LinkageTypes getTypeInfoLinkage(CodeGenModule &CGM,
40414041
return llvm::GlobalValue::ExternalLinkage;
40424042
// MinGW always uses LinkOnceODRLinkage for type info.
40434043
if (RD->isDynamicClass() &&
4044-
!CGM.getContext()
4045-
.getTargetInfo()
4046-
.getTriple()
4047-
.isWindowsGNUEnvironment())
4044+
!CGM.getContext().getTargetInfo().getTriple().isOSCygMing())
40484045
return CGM.getVTableLinkage(RD);
40494046
}
40504047

clang/lib/Sema/SemaDeclCXX.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6274,7 +6274,7 @@ static void ReferenceDllExportedMembers(Sema &S, CXXRecordDecl *Class) {
62746274
}
62756275
} MarkingDllexportedContext(S, Class, ClassAttr->getLocation());
62766276

6277-
if (S.Context.getTargetInfo().getTriple().isWindowsGNUEnvironment())
6277+
if (S.Context.getTargetInfo().getTriple().isOSCygMing())
62786278
S.MarkVTableUsed(Class->getLocation(), Class, true);
62796279

62806280
for (Decl *Member : Class->decls()) {

clang/test/CodeGenCXX/dllexport-missing-key.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// RUN: %clang_cc1 -triple x86_64-windows-gnu -emit-llvm -std=c++11 -o - %s | FileCheck --check-prefix=GNU %s
2+
// RUN: %clang_cc1 -triple x86_64-pc-cygwin -emit-llvm -std=c++11 -o - %s | FileCheck --check-prefix=GNU %s
23

34
class __declspec(dllexport) QAbstractLayoutStyleInfo {
45
public:

clang/test/CodeGenCXX/dllimport-missing-key.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// RUN: %clang_cc1 -triple i686-windows-gnu -emit-llvm -std=c++1y -O0 -o - %s -w | FileCheck --check-prefix=GNU %s
2+
// RUN: %clang_cc1 -triple i686-pc-cygwin -emit-llvm -std=c++1y -O0 -o - %s -w | FileCheck --check-prefix=GNU %s
23

34
class __declspec(dllimport) QObjectData {
45
public:

clang/test/CodeGenCXX/dllimport-rtti.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1-
// RUN: %clang_cc1 -triple i686-windows-msvc -emit-llvm -std=c++1y -fms-extensions -O1 -disable-llvm-passes -o - %s | FileCheck %s --check-prefix=MSVC
2-
// RUN: %clang_cc1 -triple i686-windows-gnu -emit-llvm -std=c++1y -fms-extensions -O1 -disable-llvm-passes -o - %s | FileCheck %s --check-prefix=GNU
1+
// RUN: %clang_cc1 -triple i686-windows-msvc -emit-llvm -std=c++1y -fms-extensions -O1 -disable-llvm-passes -o - %s | FileCheck %s --check-prefix=MSVC
2+
// RUN: %clang_cc1 -triple i686-windows-gnu -emit-llvm -std=c++1y -fms-extensions -O1 -disable-llvm-passes -o - %s | FileCheck %s --check-prefix=GNU
3+
// RUN: %clang_cc1 -triple x86_64-windows-gnu -emit-llvm -std=c++1y -fms-extensions -O1 -disable-llvm-passes -o - %s | FileCheck %s --check-prefix=GNU
4+
// RUN: %clang_cc1 -triple i686-pc-cygwin -emit-llvm -std=c++1y -fms-extensions -O1 -disable-llvm-passes -o - %s | FileCheck %s --check-prefix=GNU
5+
// RUN: %clang_cc1 -triple x86_64-pc-cygwin -emit-llvm -std=c++1y -fms-extensions -O1 -disable-llvm-passes -o - %s | FileCheck %s --check-prefix=GNU
36

47
struct __declspec(dllimport) S {
58
virtual void f() {}

clang/test/CodeGenCXX/rtti-mingw64.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
// RUN: %clang_cc1 -triple x86_64-windows-gnu %s -emit-llvm -o - | FileCheck %s
2+
// RUN: %clang_cc1 -triple x86_64-pc-cygwin %s -emit-llvm -o - | FileCheck %s
3+
24
struct A { int a; };
35
struct B : virtual A { int b; };
46
B b;

clang/test/CodeGenCXX/virt-dtor-key.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1-
// RUN: %clang_cc1 -triple i386-linux -emit-llvm %s -o - | FileCheck %s
2-
// RUN: %clang_cc1 -triple i386-windows-gnu -emit-llvm %s -o - | FileCheck %s -check-prefix CHECK-MINGW
1+
// RUN: %clang_cc1 -triple i686-linux -emit-llvm %s -o - | FileCheck %s
2+
// RUN: %clang_cc1 -triple i686-windows-gnu -emit-llvm %s -o - | FileCheck %s -check-prefix CHECK-MINGW
3+
// RUN: %clang_cc1 -triple x86_64-windows-gnu -emit-llvm %s -o - | FileCheck %s -check-prefix CHECK-MINGW
4+
// RUN: %clang_cc1 -triple i686-pc-cygwin -emit-llvm %s -o - | FileCheck %s -check-prefix CHECK-MINGW
5+
// RUN: %clang_cc1 -triple x86_64-pc-cygwin -emit-llvm %s -o - | FileCheck %s -check-prefix CHECK-MINGW
6+
37
// CHECK: @_ZTI3foo ={{.*}} constant
48
// CHECK-MINGW: @_ZTI3foo = linkonce_odr
59
class foo {

clang/test/CodeGenCXX/vtable-key-function-ios.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
// RUN: %clang_cc1 %s -triple=x86_64-pc-windows-gnu -emit-llvm -o - | FileCheck -check-prefixes=CHECK,CHECK-MINGW %s
55
// RUN: %clang_cc1 %s -triple=x86_64-pc-windows-gnu -emit-llvm -o - | FileCheck -check-prefix=CHECK-LATE %s
6+
// RUN: %clang_cc1 %s -triple=x86_64-pc-cygwin -emit-llvm -o - | FileCheck -check-prefixes=CHECK,CHECK-MINGW %s
7+
// RUN: %clang_cc1 %s -triple=x86_64-pc-cygwin -emit-llvm -o - | FileCheck -check-prefix=CHECK-LATE %s
68

79
// The 'a' variants ask for the vtable first.
810
// The 'b' variants ask for the vtable second.

0 commit comments

Comments
 (0)