[PATCH] D22370: Respect LLVM_HOST_TRIPLE when manually specified

Luke Drummond via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 15 09:27:30 PDT 2016


ldrumm added a comment.

In https://reviews.llvm.org/D22370#485442, @beanz wrote:

> I very much believe you are doing something wrong.
>
> Your description of the problem doesn't match the error message, and I can tell you that the solution *isn't* to make get_host_triple return anything that isn't actually the host triple.


The fundamental use case I'm trying to enable is enabling specifying the host triple. If the user is in a position to manually specify the triple, I think we should allow that. I think that while my assumptions regarding the root cause of the failure are incorrect (see below), this is still valid, and of general utility.

> This is the error you posted:

> 

>   CMake Error at cmake/modules/GetHostTriple.cmake:24 (message):

> 

> 

> That code is only hit if MSVC is false. You're in the `else` block of an `if(MSVC)`. The problem is actually that `if(MSVC)` isn't really the right check. Can you give this patch a try?


You're absolutely right. I didn't read that error message correctly, and misdiagnosed the entry of the `if ( MSVC )` block. My apologies.

>   diff --git a/cmake/modules/GetHostTriple.cmake b/cmake/modules/GetHostTriple.cmake

>   index 5de710c..e3ecc5d 100644

>   --- a/cmake/modules/GetHostTriple.cmake

>   +++ b/cmake/modules/GetHostTriple.cmake

>   @@ -2,18 +2,18 @@

>    # Invokes config.guess

>    

>    function( get_host_triple var )

>   -  if( MSVC )

>   -    if( CMAKE_CL_64 )

>   -      set( value "x86_64-pc-win32" )

>   -    else()

>   -      set( value "i686-pc-win32" )

>   -    endif()

>   -  elseif( MINGW AND NOT MSYS )

>   +  if( MINGW AND NOT MSYS )

>        if( CMAKE_SIZEOF_VOID_P EQUAL 8 )

>          set( value "x86_64-w64-mingw32" )

>        else()

>          set( value "i686-pc-mingw32" )

>        endif()

>   +  elseif( CMAKE_HOST_WIN32 )

>   +    if( CMAKE_CL_64 )

>   +      set( value "x86_64-pc-win32" )

>   +    else()

>   +      set( value "i686-pc-win32" )

>   +    endif()

>      else( MSVC )

>        set(config_guess ${LLVM_MAIN_SRC_DIR}/cmake/config.guess)

>        execute_process(COMMAND sh ${config_guess}

> 


I think this is still going to set the host triple to an x86 win32 triple as the following conditions will always be true: `CMAKE_HOST_WIN32`, not using msys, and as you've shown, `CMAKE_CL_64` won't be set, because `MSVC` is not set. I may be misunderstanding the root of the problem (my CMake shops are pretty woeful, admittedly), but this looks to me like it doesn't actually solve the case of specifying the triple manually. Having said that I'll definitely give this a shot when I've access to a win32 machine on Monday, and see if it does solve the specific lldb-server case I've been experiencing.

L


Repository:
  rL LLVM

https://reviews.llvm.org/D22370





More information about the llvm-commits mailing list