From 86b5c3a8449be277675109e5db953a7ef64bc800 Mon Sep 17 00:00:00 2001 From: Reid Kleckner Date: Fri, 13 Feb 2015 22:05:50 +0000 Subject: [PATCH] Triple: Make setEnvironment not override the object format Discovered by Halide users who had C++ code like this: Triple.setArch(Triple::x86); Triple.setOS(Triple::Windows); Triple.setObjectFormat(Triple::ELF); Triple.setEnvironment(Triple::MSVC); This would produce the stringified triple of x86-windows-msvc, instead of the x86-windows-msvc-elf string needed to run MCJIT. With this change, they retain the -elf suffix. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@229160 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Support/Triple.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/Support/Triple.cpp b/lib/Support/Triple.cpp index 9627f8f2f9a..e74b23ca0ca 100644 --- a/lib/Support/Triple.cpp +++ b/lib/Support/Triple.cpp @@ -816,7 +816,11 @@ void Triple::setOS(OSType Kind) { } void Triple::setEnvironment(EnvironmentType Kind) { - setEnvironmentName(getEnvironmentTypeName(Kind)); + if (ObjectFormat == getDefaultFormat(*this)) + return setEnvironmentName(getEnvironmentTypeName(Kind)); + + setEnvironmentName((getEnvironmentTypeName(Kind) + Twine("-") + + getObjectFormatTypeName(ObjectFormat)).str()); } void Triple::setObjectFormat(ObjectFormatType Kind) { -- 2.34.1