[clang] [Cygwin] Cygwin macro (PR #74973)
εΎζζ Xu Chiheng via cfe-commits
cfe-commits at lists.llvm.org
Sat Dec 9 22:05:55 PST 2023
https://github.com/xu-chiheng created https://github.com/llvm/llvm-project/pull/74973
None
>From 376c504e6a559be2b538291e066b1a67c05e5a82 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
---
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 ce7e4d4639ceac..c99c247924f99c 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 b97f88647fa49f..29a7b089bc0db7 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");
}
};
More information about the cfe-commits
mailing list