From: David Majnemer Date: Tue, 9 Jun 2015 06:30:01 +0000 (+0000) Subject: [Driver] Preserve the object file format in ComputeEffectiveClangTriple X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d76ed7e8f6fb4b1558bf41974891c5316361f413;p=clang [Driver] Preserve the object file format in ComputeEffectiveClangTriple 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 --- diff --git a/lib/Driver/MSVCToolChain.cpp b/lib/Driver/MSVCToolChain.cpp index 95e6895cea..d824fe4c10 100644 --- a/lib/Driver/MSVCToolChain.cpp +++ b/lib/Driver/MSVCToolChain.cpp @@ -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(); } diff --git a/test/Driver/msvc-triple.c b/test/Driver/msvc-triple.c index 72bb4a37ff..f181b3199a 100644 --- a/test/Driver/msvc-triple.c +++ b/test/Driver/msvc-triple.c @@ -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"