Skip to content

Commit a3228b6

Browse files
jeremyd2019mati865
andauthored
[Clang][Cygwin] Enable few conditions that are shared with MinGW (#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 28b3190 commit a3228b6

File tree

8 files changed

+14
-11
lines changed

8 files changed

+14
-11
lines changed

clang/lib/AST/RecordLayoutBuilder.cpp

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

clang/lib/CIR/CodeGen/CIRGenModule.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1593,10 +1593,10 @@ static bool shouldAssumeDSOLocal(const CIRGenModule &cgm,
15931593

15941594
const llvm::Triple &tt = cgm.getTriple();
15951595
const CodeGenOptions &cgOpts = cgm.getCodeGenOpts();
1596-
if (tt.isWindowsGNUEnvironment()) {
1597-
// In MinGW, variables without DLLImport can still be automatically
1598-
// imported from a DLL by the linker; don't mark variables that
1599-
// potentially could come from another DLL as DSO local.
1596+
if (tt.isOSCygMing()) {
1597+
// In MinGW and Cygwin, variables without DLLImport can still be
1598+
// automatically imported from a DLL by the linker; don't mark variables
1599+
// that potentially could come from another DLL as DSO local.
16001600

16011601
// With EmulatedTLS, TLS variables can be autoimported from other DLLs
16021602
// (and this actually happens in the public interface of libstdc++), so

clang/lib/Driver/ToolChain.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -761,7 +761,7 @@ std::string ToolChain::buildCompilerRTBasename(const llvm::opt::ArgList &Args,
761761
break;
762762
case ToolChain::FT_Shared:
763763
if (TT.isOSWindows())
764-
Suffix = TT.isWindowsGNUEnvironment() ? ".dll.a" : ".lib";
764+
Suffix = TT.isOSCygMing() ? ".dll.a" : ".lib";
765765
else if (TT.isOSAIX())
766766
Suffix = ".a";
767767
else

clang/lib/Driver/ToolChains/Clang.cpp

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

5947-
if (Triple.isWindowsGNUEnvironment()) {
5947+
if (Triple.isOSCygMing()) {
59485948
Args.addOptOutFlag(CmdArgs, options::OPT_fauto_import,
59495949
options::OPT_fno_auto_import);
59505950
}

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
@@ -12586,9 +12586,9 @@ static bool isDefaultStdCall(FunctionDecl *FD, Sema &S) {
1258612586
if (FD->getName() == "main" || FD->getName() == "wmain")
1258712587
return false;
1258812588

12589-
// Default calling convention for MinGW is __cdecl
12589+
// Default calling convention for MinGW and Cygwin is __cdecl
1259012590
const llvm::Triple &T = S.Context.getTargetInfo().getTriple();
12591-
if (T.isWindowsGNUEnvironment())
12591+
if (T.isOSCygMing())
1259212592
return false;
1259312593

1259412594
// 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

clang/test/Preprocessor/init-x86.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1535,6 +1535,7 @@
15351535
// I386-CYGWIN:#define __GCC_ATOMIC_SHORT_LOCK_FREE 2
15361536
// I386-CYGWIN:#define __GCC_ATOMIC_TEST_AND_SET_TRUEVAL 1
15371537
// I386-CYGWIN:#define __GCC_ATOMIC_WCHAR_T_LOCK_FREE 2
1538+
// I386-CYGWIN:#define __GXX_TYPEINFO_EQUALITY_INLINE 0
15381539
// I386-CYGWIN:#define __ILP32__ 1
15391540
// I386-CYGWIN:#define __INT16_C(c) c
15401541
// I386-CYGWIN:#define __INT16_C_SUFFIX__
@@ -1746,6 +1747,7 @@
17461747
// X86_64-CYGWIN:#define __GCC_ATOMIC_SHORT_LOCK_FREE 2
17471748
// X86_64-CYGWIN:#define __GCC_ATOMIC_TEST_AND_SET_TRUEVAL 1
17481749
// X86_64-CYGWIN:#define __GCC_ATOMIC_WCHAR_T_LOCK_FREE 2
1750+
// X86_64-CYGWIN:#define __GXX_TYPEINFO_EQUALITY_INLINE 0
17491751
// X86_64-CYGWIN:#define __INT16_C(c) c
17501752
// X86_64-CYGWIN:#define __INT16_C_SUFFIX__
17511753
// X86_64-CYGWIN:#define __INT16_FMTd__ "hd"

0 commit comments

Comments
 (0)