[flang-commits] [flang] [clang] [flang] Add MSC_VER and target arch defines when targeting the MSVC ABI (PR #73250)

مهدي شينون via flang-commits flang-commits at lists.llvm.org
Sun Nov 26 23:15:29 PST 2023


================
@@ -204,6 +204,29 @@ void Flang::AddAArch64TargetArgs(const ArgList &Args,
   }
 }
 
+static void addVSDefines(const ToolChain &TC, const ArgList &Args,
+                         ArgStringList &CmdArgs) {
+
+  unsigned ver = 0;
+  const VersionTuple vt = TC.computeMSVCVersion(nullptr, Args);
+  ver = vt.getMajor() * 10000000 + vt.getMinor().value_or(0) * 100000 +
+        vt.getSubminor().value_or(0);
+  CmdArgs.push_back(Args.MakeArgString("-D_MSC_VER=" + Twine(ver / 100000)));
+  CmdArgs.push_back(Args.MakeArgString("-D_MSC_FULL_VER=" + Twine(ver)));
+
+  llvm::Triple triple = TC.getTriple();
+  if (triple.isAArch64()) {
+    CmdArgs.push_back("-D_M_ARM64=1");
+  } else if (triple.isX86() && triple.isArch32Bit()) {
+    CmdArgs.push_back("-D_M_IX86=600");
+  } else if (triple.isX86() && triple.isArch64Bit()) {
+    CmdArgs.push_back("-D_M_X64=100");
+  } else {
+    llvm_unreachable(
+        "Flang on Windows only supports X86_32, X86_64 and AArch64");
+  }
----------------
MehdiChinoune wrote:

Flang doesn't support 32bit https://github.com/llvm/llvm-project/blob/659e4017b7371efa8ce97da2d87270c60a93d03d/flang/CMakeLists.txt#L60

https://github.com/llvm/llvm-project/pull/73250


More information about the flang-commits mailing list