Skip to content

Commit 8081536

Browse files
jeremyd2019mati865
andcommitted
[Clang][Cygwin] Enable few conditions that are shared with MinGW (llvm#149637)
The Cygwin target is generally very similar to the MinGW target. The default auto-import behavior, the default calling convention, the `.dll.a` import library extension, the `__GXX_TYPEINFO_EQUALITY_INLINE` pre-define by `g++`, and the long double configuration. Co-authored-by: Mateusz Mikuła <[email protected]>
1 parent 6204214 commit 8081536

File tree

7 files changed

+16
-13
lines changed

7 files changed

+16
-13
lines changed

clang/lib/AST/RecordLayoutBuilder.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1946,7 +1946,7 @@ void ItaniumRecordLayoutBuilder::LayoutField(const FieldDecl *D,
19461946
// silently there. For other targets that have ms_struct enabled
19471947
// (most probably via a pragma or attribute), trigger a diagnostic
19481948
// that defaults to an error.
1949-
if (!Context.getTargetInfo().getTriple().isWindowsGNUEnvironment())
1949+
if (!Context.getTargetInfo().getTriple().isOSCygMing())
19501950
Diag(D->getLocation(), diag::warn_npot_ms_struct);
19511951
}
19521952
if (TypeSize > FieldAlign &&

clang/lib/Driver/ToolChain.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -749,7 +749,7 @@ std::string ToolChain::buildCompilerRTBasename(const llvm::opt::ArgList &Args,
749749
break;
750750
case ToolChain::FT_Shared:
751751
Suffix = TT.isOSWindows()
752-
? (TT.isWindowsGNUEnvironment() ? ".dll.a" : ".lib")
752+
? (TT.isOSCygMing() ? ".dll.a" : ".lib")
753753
: ".so";
754754
break;
755755
}

clang/lib/Driver/ToolChains/Clang.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6121,7 +6121,7 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
61216121
CmdArgs.push_back("-mms-bitfields");
61226122
}
61236123

6124-
if (Triple.isWindowsGNUEnvironment()) {
6124+
if (Triple.isOSCygMing()) {
61256125
Args.addOptOutFlag(CmdArgs, options::OPT_fauto_import,
61266126
options::OPT_fno_auto_import);
61276127
}

clang/lib/Frontend/InitPreprocessor.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -945,8 +945,8 @@ static void InitializePredefinedMacros(const TargetInfo &TI,
945945
if (LangOpts.GNUCVersion && LangOpts.CPlusPlus11)
946946
Builder.defineMacro("__GXX_EXPERIMENTAL_CXX0X__");
947947

948-
if (TI.getTriple().isWindowsGNUEnvironment()) {
949-
// Set ABI defining macros for libstdc++ for MinGW, where the
948+
if (TI.getTriple().isOSCygMing()) {
949+
// Set ABI defining macros for libstdc++ for MinGW and Cygwin, where the
950950
// default in libstdc++ differs from the defaults for this target.
951951
Builder.defineMacro("__GXX_TYPEINFO_EQUALITY_INLINE", "0");
952952
}

clang/lib/Sema/SemaDecl.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12514,9 +12514,9 @@ static bool isDefaultStdCall(FunctionDecl *FD, Sema &S) {
1251412514
if (FD->getName() == "main" || FD->getName() == "wmain")
1251512515
return false;
1251612516

12517-
// Default calling convention for MinGW is __cdecl
12517+
// Default calling convention for MinGW and Cygwin is __cdecl
1251812518
const llvm::Triple &T = S.Context.getTargetInfo().getTriple();
12519-
if (T.isWindowsGNUEnvironment())
12519+
if (T.isOSCygMing())
1252012520
return false;
1252112521

1252212522
// Default calling convention for WinMain, wWinMain and DllMain

clang/test/CodeGen/ms_struct-long-double.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// RUN: %clang_cc1 -emit-llvm-only -triple i686-windows-gnu -fdump-record-layouts %s | FileCheck %s
2+
// RUN: %clang_cc1 -emit-llvm-only -triple i686-windows-cygnus -fdump-record-layouts %s | FileCheck %s
23
// RUN: %clang_cc1 -emit-llvm-only -triple i686-linux -fdump-record-layouts -Wno-incompatible-ms-struct %s | FileCheck %s
34
// RUN: not %clang_cc1 -emit-llvm-only -triple i686-linux -fdump-record-layouts %s 2>&1 | FileCheck %s -check-prefix=ERROR
45

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
#ifndef RC_INVOKED
2-
#error RC_INVOKED not defined
2+
# error RC_INVOKED not defined
33
#endif
4-
#ifndef _WIN32
5-
#error _WIN32 not defined
6-
#endif
7-
#ifndef __MINGW32__
8-
#error __MINGW32__ not defined
4+
#ifndef __CYGWIN__
5+
# ifndef _WIN32
6+
# error _WIN32 not defined
7+
# endif
8+
# ifndef __MINGW32__
9+
# error __MINGW32__ not defined
10+
# endif
911
#endif
1012
#define MY_ID 42

0 commit comments

Comments
 (0)