Skip to content

Commit dd4560a

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 6bffd01 commit dd4560a

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
@@ -1530,10 +1530,10 @@ static bool shouldAssumeDSOLocal(const CIRGenModule &cgm,
15301530

15311531
const llvm::Triple &tt = cgm.getTriple();
15321532
const CodeGenOptions &cgOpts = cgm.getCodeGenOpts();
1533-
if (tt.isWindowsGNUEnvironment()) {
1534-
// In MinGW, variables without DLLImport can still be automatically
1535-
// imported from a DLL by the linker; don't mark variables that
1536-
// potentially could come from another DLL as DSO local.
1533+
if (tt.isOSCygMing()) {
1534+
// In MinGW and Cygwin, variables without DLLImport can still be
1535+
// automatically imported from a DLL by the linker; don't mark variables
1536+
// that potentially could come from another DLL as DSO local.
15371537

15381538
// With EmulatedTLS, TLS variables can be autoimported from other DLLs
15391539
// (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
@@ -743,7 +743,7 @@ std::string ToolChain::buildCompilerRTBasename(const llvm::opt::ArgList &Args,
743743
break;
744744
case ToolChain::FT_Shared:
745745
if (TT.isOSWindows())
746-
Suffix = TT.isWindowsGNUEnvironment() ? ".dll.a" : ".lib";
746+
Suffix = TT.isOSCygMing() ? ".dll.a" : ".lib";
747747
else if (TT.isOSAIX())
748748
Suffix = ".a";
749749
else

clang/lib/Driver/ToolChains/Clang.cpp

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

5967-
if (Triple.isWindowsGNUEnvironment()) {
5967+
if (Triple.isOSCygMing()) {
59685968
Args.addOptOutFlag(CmdArgs, options::OPT_fauto_import,
59695969
options::OPT_fno_auto_import);
59705970
}

clang/lib/Frontend/InitPreprocessor.cpp

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

955-
if (TI.getTriple().isWindowsGNUEnvironment()) {
956-
// Set ABI defining macros for libstdc++ for MinGW, where the
955+
if (TI.getTriple().isOSCygMing()) {
956+
// Set ABI defining macros for libstdc++ for MinGW and Cygwin, where the
957957
// default in libstdc++ differs from the defaults for this target.
958958
Builder.defineMacro("__GXX_TYPEINFO_EQUALITY_INLINE", "0");
959959
}

clang/lib/Sema/SemaDecl.cpp

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

12581-
// Default calling convention for MinGW is __cdecl
12581+
// Default calling convention for MinGW and Cygwin is __cdecl
1258212582
const llvm::Triple &T = S.Context.getTargetInfo().getTriple();
12583-
if (T.isWindowsGNUEnvironment())
12583+
if (T.isOSCygMing())
1258412584
return false;
1258512585

1258612586
// 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)