Skip to content

[Cygwin] RTTI and VTable should be dllexport-ed #139798

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions clang/lib/CodeGen/ItaniumCXXABI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3754,7 +3754,7 @@ static bool ShouldUseExternalRTTIDescriptor(CodeGenModule &CGM,
bool IsDLLImport = RD->hasAttr<DLLImportAttr>();

// Don't import the RTTI but emit it locally.
if (CGM.getTriple().isWindowsGNUEnvironment())
if (CGM.getTriple().isOSCygMing())
return false;

if (CGM.getVTables().isVTableExternal(RD)) {
Expand Down Expand Up @@ -4041,10 +4041,7 @@ static llvm::GlobalVariable::LinkageTypes getTypeInfoLinkage(CodeGenModule &CGM,
return llvm::GlobalValue::ExternalLinkage;
// MinGW always uses LinkOnceODRLinkage for type info.
if (RD->isDynamicClass() &&
!CGM.getContext()
.getTargetInfo()
.getTriple()
.isWindowsGNUEnvironment())
!CGM.getContext().getTargetInfo().getTriple().isOSCygMing())
return CGM.getVTableLinkage(RD);
}

Expand Down
2 changes: 1 addition & 1 deletion clang/lib/Sema/SemaDeclCXX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6274,7 +6274,7 @@ static void ReferenceDllExportedMembers(Sema &S, CXXRecordDecl *Class) {
}
} MarkingDllexportedContext(S, Class, ClassAttr->getLocation());

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

for (Decl *Member : Class->decls()) {
Expand Down
1 change: 1 addition & 0 deletions clang/test/CodeGenCXX/dllexport-missing-key.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// RUN: %clang_cc1 -triple x86_64-windows-gnu -emit-llvm -std=c++11 -o - %s | FileCheck --check-prefix=GNU %s
// RUN: %clang_cc1 -triple x86_64-pc-cygwin -emit-llvm -std=c++11 -o - %s | FileCheck --check-prefix=GNU %s

class __declspec(dllexport) QAbstractLayoutStyleInfo {
public:
Expand Down
1 change: 1 addition & 0 deletions clang/test/CodeGenCXX/dllimport-missing-key.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// RUN: %clang_cc1 -triple i686-windows-gnu -emit-llvm -std=c++1y -O0 -o - %s -w | FileCheck --check-prefix=GNU %s
// RUN: %clang_cc1 -triple i686-pc-cygwin -emit-llvm -std=c++1y -O0 -o - %s -w | FileCheck --check-prefix=GNU %s

class __declspec(dllimport) QObjectData {
public:
Expand Down
7 changes: 5 additions & 2 deletions clang/test/CodeGenCXX/dllimport-rtti.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
// 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
// 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
// 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
// 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
// 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
// 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
// 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

struct __declspec(dllimport) S {
virtual void f() {}
Expand Down
2 changes: 2 additions & 0 deletions clang/test/CodeGenCXX/rtti-mingw64.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
// RUN: %clang_cc1 -triple x86_64-windows-gnu %s -emit-llvm -o - | FileCheck %s
// RUN: %clang_cc1 -triple x86_64-pc-cygwin %s -emit-llvm -o - | FileCheck %s

struct A { int a; };
struct B : virtual A { int b; };
B b;
Expand Down
8 changes: 6 additions & 2 deletions clang/test/CodeGenCXX/virt-dtor-key.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
// RUN: %clang_cc1 -triple i386-linux -emit-llvm %s -o - | FileCheck %s
// RUN: %clang_cc1 -triple i386-windows-gnu -emit-llvm %s -o - | FileCheck %s -check-prefix CHECK-MINGW
// RUN: %clang_cc1 -triple i686-linux -emit-llvm %s -o - | FileCheck %s
// RUN: %clang_cc1 -triple i686-windows-gnu -emit-llvm %s -o - | FileCheck %s -check-prefix CHECK-MINGW
// RUN: %clang_cc1 -triple x86_64-windows-gnu -emit-llvm %s -o - | FileCheck %s -check-prefix CHECK-MINGW
// RUN: %clang_cc1 -triple i686-pc-cygwin -emit-llvm %s -o - | FileCheck %s -check-prefix CHECK-MINGW
// RUN: %clang_cc1 -triple x86_64-pc-cygwin -emit-llvm %s -o - | FileCheck %s -check-prefix CHECK-MINGW

// CHECK: @_ZTI3foo ={{.*}} constant
// CHECK-MINGW: @_ZTI3foo = linkonce_odr
class foo {
Expand Down
2 changes: 2 additions & 0 deletions clang/test/CodeGenCXX/vtable-key-function-ios.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

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

// The 'a' variants ask for the vtable first.
// The 'b' variants ask for the vtable second.
Expand Down