]> granicus.if.org Git - clang/commitdiff
[Driver] Preserve the object file format in ComputeEffectiveClangTriple
authorDavid Majnemer <david.majnemer@gmail.com>
Tue, 9 Jun 2015 06:30:01 +0000 (06:30 +0000)
committerDavid Majnemer <david.majnemer@gmail.com>
Tue, 9 Jun 2015 06:30:01 +0000 (06:30 +0000)
The object file format is sometimes overridden for MSVC targets to use
ELF instead of COFF.  Make sure we preserve this choice when setting the
msvc version number in the triple.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@239388 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Driver/MSVCToolChain.cpp
test/Driver/msvc-triple.c

index 95e6895cea6d7752a4ab9e1906265f3ea3ba213f..d824fe4c10839156b3dcacaf1c3217c02674c929 100644 (file)
@@ -512,7 +512,13 @@ MSVCToolChain::ComputeEffectiveClangTriple(const ArgList &Args,
   MSVT = VersionTuple(MSVT.getMajor(), MSVT.getMinor().getValueOr(0),
                       MSVT.getSubminor().getValueOr(0));
 
-  if (Triple.getEnvironment() == llvm::Triple::MSVC)
-    Triple.setEnvironmentName((Twine("msvc") + MSVT.getAsString()).str());
+  if (Triple.getEnvironment() == llvm::Triple::MSVC) {
+    StringRef ObjFmt = Triple.getEnvironmentName().split('-').second;
+    if (ObjFmt.empty())
+      Triple.setEnvironmentName((Twine("msvc") + MSVT.getAsString()).str());
+    else
+      Triple.setEnvironmentName(
+          (Twine("msvc") + MSVT.getAsString() + Twine('-') + ObjFmt).str());
+  }
   return Triple.getTriple();
 }
index 72bb4a37ff7b5f72d8d9d14984a049607537adf6..f181b3199a3f3391cdc6f4eb02fcd99d28bc5167 100644 (file)
@@ -1,7 +1,9 @@
 // RUN: %clang -target i686-pc-windows-msvc   -S -emit-llvm %s -o - | FileCheck %s --check-prefix=DEFAULT
 // RUN: %clang -target i686-pc-windows-msvc19 -S -emit-llvm %s -o - | FileCheck %s --check-prefix=TARGET-19
 // RUN: %clang -target i686-pc-windows-msvc   -S -emit-llvm %s -o - -fms-compatibility-version=19 | FileCheck %s --check-prefix=OVERRIDE-19
+// RUN: %clang -target i686-pc-windows-msvc-elf -S -emit-llvm %s -o - | FileCheck %s --check-prefix=ELF-DEFAULT
 
 // DEFAULT:     target triple = "i686-pc-windows-msvc18.0.0"
 // TARGET-19:   target triple = "i686-pc-windows-msvc19.0.0"
 // OVERRIDE-19: target triple = "i686-pc-windows-msvc19.0.0"
+// ELF-DEFAULT: target triple = "i686-pc-windows-msvc18.0.0-elf"