[llvm] r333307 - [Support] Avoid normalization in sys::getDefaultTargetTriple

Petr Hosek via llvm-commits llvm-commits at lists.llvm.org
Fri May 25 13:39:37 PDT 2018


Author: phosek
Date: Fri May 25 13:39:37 2018
New Revision: 333307

URL: http://llvm.org/viewvc/llvm-project?rev=333307&view=rev
Log:
[Support] Avoid normalization in sys::getDefaultTargetTriple

The return value of sys::getDefaultTargetTriple, which is derived from
-DLLVM_DEFAULT_TRIPLE, is used to construct tool names, default target,
and in the future also to control the search path directly; as such it
should be used textually, without interpretation by LLVM.

Normalization of this value may lead to unexpected results, for example
if we configure LLVM with -DLLVM_DEFAULT_TARGET_TRIPLE=x86_64-linux-gnu,
normalization will transform that value to x86_64--linux-gnu. Driver will
use that value to search for tools prefixed with x86_64--linux-gnu- which
may be confusing. This is also inconsistent with the behavior of the
--target flag which is taken as-is without any normalization and overrides
the value of LLVM_DEFAULT_TARGET_TRIPLE.

Users of sys::getDefaultTargetTriple already perform their own
normalization as needed, so this change shouldn't impact existing logic.

Differential Revision: https://reviews.llvm.org/D47153

Modified:
    llvm/trunk/lib/Support/Unix/Host.inc
    llvm/trunk/lib/Support/Windows/Host.inc

Modified: llvm/trunk/lib/Support/Unix/Host.inc
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Unix/Host.inc?rev=333307&r1=333306&r2=333307&view=diff
==============================================================================
--- llvm/trunk/lib/Support/Unix/Host.inc (original)
+++ llvm/trunk/lib/Support/Unix/Host.inc Fri May 25 13:39:37 2018
@@ -64,5 +64,5 @@ std::string sys::getDefaultTargetTriple(
     TargetTripleString = EnvTriple;
 #endif
 
-  return Triple::normalize(TargetTripleString);
+  return TargetTripleString;
 }

Modified: llvm/trunk/lib/Support/Windows/Host.inc
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Windows/Host.inc?rev=333307&r1=333306&r2=333307&view=diff
==============================================================================
--- llvm/trunk/lib/Support/Windows/Host.inc (original)
+++ llvm/trunk/lib/Support/Windows/Host.inc Fri May 25 13:39:37 2018
@@ -30,5 +30,5 @@ std::string sys::getDefaultTargetTriple(
     Triple = EnvTriple;
 #endif
 
-  return Triple::normalize(Triple);
+  return Triple;
 }




More information about the llvm-commits mailing list