[clang] [Cygwin] Cygwin macro (PR #74973)
εΎζζ Xu Chiheng via cfe-commits
cfe-commits at lists.llvm.org
Sun Dec 31 12:53:57 PST 2023
https://github.com/xu-chiheng updated https://github.com/llvm/llvm-project/pull/74973
>From 29f213f8921c38ca8192aa32087e99771a0cfbfb Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=BE=90=E6=8C=81=E6=81=92=20Xu=20Chiheng?=
<chiheng.xu at gmail.com>
Date: Sun, 10 Dec 2023 14:04:36 +0800
Subject: [PATCH 1/2] 1
---
clang/lib/Basic/Targets/ARM.cpp | 2 --
clang/lib/Basic/Targets/X86.cpp | 9 +++++++--
clang/lib/Basic/Targets/X86.h | 4 ----
3 files changed, 7 insertions(+), 8 deletions(-)
diff --git a/clang/lib/Basic/Targets/ARM.cpp b/clang/lib/Basic/Targets/ARM.cpp
index 01f9e844da12a0..800f61c0c67864 100644
--- a/clang/lib/Basic/Targets/ARM.cpp
+++ b/clang/lib/Basic/Targets/ARM.cpp
@@ -1402,8 +1402,6 @@ void CygwinARMTargetInfo::getTargetDefines(const LangOptions &Opts,
Builder.defineMacro("__CYGWIN__");
Builder.defineMacro("__CYGWIN32__");
DefineStd(Builder, "unix", Opts);
- if (Opts.CPlusPlus)
- Builder.defineMacro("_GNU_SOURCE");
}
DarwinARMTargetInfo::DarwinARMTargetInfo(const llvm::Triple &Triple,
diff --git a/clang/lib/Basic/Targets/X86.cpp b/clang/lib/Basic/Targets/X86.cpp
index 3deaa19f8d4fc4..2e281439ae13a7 100644
--- a/clang/lib/Basic/Targets/X86.cpp
+++ b/clang/lib/Basic/Targets/X86.cpp
@@ -508,8 +508,13 @@ void X86TargetInfo::getTargetDefines(const LangOptions &Opts,
Builder.defineMacro("__GCC_ASM_FLAG_OUTPUTS__");
std::string CodeModel = getTargetOpts().CodeModel;
- if (CodeModel == "default")
- CodeModel = "small";
+ if (CodeModel == "default") {
+ if (getTriple().isWindowsCygwinEnvironment() && getTriple().getArch() == llvm::Triple::x86_64) {
+ CodeModel = "medium";
+ } else {
+ CodeModel = "small";
+ }
+ }
Builder.defineMacro("__code_model_" + CodeModel + "__");
// Target identification.
diff --git a/clang/lib/Basic/Targets/X86.h b/clang/lib/Basic/Targets/X86.h
index 0ab1c10833db26..1664fcc417b148 100644
--- a/clang/lib/Basic/Targets/X86.h
+++ b/clang/lib/Basic/Targets/X86.h
@@ -643,8 +643,6 @@ class LLVM_LIBRARY_VISIBILITY CygwinX86_32TargetInfo : public X86_32TargetInfo {
Builder.defineMacro("__CYGWIN32__");
addCygMingDefines(Opts, Builder);
DefineStd(Builder, "unix", Opts);
- if (Opts.CPlusPlus)
- Builder.defineMacro("_GNU_SOURCE");
}
};
@@ -916,8 +914,6 @@ class LLVM_LIBRARY_VISIBILITY CygwinX86_64TargetInfo : public X86_64TargetInfo {
Builder.defineMacro("__CYGWIN64__");
addCygMingDefines(Opts, Builder);
DefineStd(Builder, "unix", Opts);
- if (Opts.CPlusPlus)
- Builder.defineMacro("_GNU_SOURCE");
}
};
>From fa807942d6be7b0f486ed7f64c0113a288fa8264 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=BE=90=E6=8C=81=E6=81=92=20Xu=20Chiheng?=
<chiheng.xu at gmail.com>
Date: Sun, 10 Dec 2023 14:13:02 +0800
Subject: [PATCH 2/2] 1
---
clang/lib/Basic/Targets/X86.cpp | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/clang/lib/Basic/Targets/X86.cpp b/clang/lib/Basic/Targets/X86.cpp
index 2e281439ae13a7..e6b2d1160de9ad 100644
--- a/clang/lib/Basic/Targets/X86.cpp
+++ b/clang/lib/Basic/Targets/X86.cpp
@@ -509,7 +509,8 @@ void X86TargetInfo::getTargetDefines(const LangOptions &Opts,
std::string CodeModel = getTargetOpts().CodeModel;
if (CodeModel == "default") {
- if (getTriple().isWindowsCygwinEnvironment() && getTriple().getArch() == llvm::Triple::x86_64) {
+ if (getTriple().isWindowsCygwinEnvironment() &&
+ getTriple().getArch() == llvm::Triple::x86_64) {
CodeModel = "medium";
} else {
CodeModel = "small";
More information about the cfe-commits
mailing list