[PATCH] D46910: [Support] Avoid normalization in sys::getDefaultTargetTriple

Petr Hosek via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue May 15 15:32:16 PDT 2018


phosek created this revision.
phosek added reviewers: rnk, echristo.
Herald added subscribers: llvm-commits, hiraditya, mgorny.

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 this 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.


Repository:
  rL LLVM

https://reviews.llvm.org/D46910

Files:
  llvm/cmake/modules/GetHostTriple.cmake
  llvm/lib/Support/Unix/Host.inc
  llvm/lib/Support/Windows/Host.inc


Index: llvm/lib/Support/Windows/Host.inc
===================================================================
--- llvm/lib/Support/Windows/Host.inc
+++ llvm/lib/Support/Windows/Host.inc
@@ -30,5 +30,5 @@
     Triple = EnvTriple;
 #endif
 
-  return Triple::normalize(Triple);
+  return Triple;
 }
Index: llvm/lib/Support/Unix/Host.inc
===================================================================
--- llvm/lib/Support/Unix/Host.inc
+++ llvm/lib/Support/Unix/Host.inc
@@ -64,5 +64,5 @@
     TargetTripleString = EnvTriple;
 #endif
 
-  return Triple::normalize(TargetTripleString);
+  return TargetTripleString;
 }
Index: llvm/cmake/modules/GetHostTriple.cmake
===================================================================
--- llvm/cmake/modules/GetHostTriple.cmake
+++ llvm/cmake/modules/GetHostTriple.cmake
@@ -4,15 +4,15 @@
 function( get_host_triple var )
   if( MSVC )
     if( CMAKE_SIZEOF_VOID_P EQUAL 8 )
-      set( value "x86_64-pc-win32" )
+      set( value "x86_64-pc-windows-msvc" )
     else()
-      set( value "i686-pc-win32" )
+      set( value "i686-pc-windows-msvc" )
     endif()
   elseif( MINGW AND NOT MSYS )
     if( CMAKE_SIZEOF_VOID_P EQUAL 8 )
-      set( value "x86_64-w64-mingw32" )
+      set( value "x86_64-w64-windows-gnu" )
     else()
-      set( value "i686-pc-mingw32" )
+      set( value "i686-pc-windows-gnu" )
     endif()
   else( MSVC )
     set(config_guess ${LLVM_MAIN_SRC_DIR}/cmake/config.guess)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D46910.146941.patch
Type: text/x-patch
Size: 1451 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180515/3c7b6254/attachment.bin>


More information about the llvm-commits mailing list