[PATCH] D40229: [cmake] Remove redundant call to cmake when building host tools.

Justin Bogner via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 6 15:36:33 PST 2017


bogner added a comment.

In https://reviews.llvm.org/D40229#946331, @labath wrote:

> I think this breaks any non-trivial cross-compilation scenario.
>
> When compiling for android, we compile the android binaries with the compiler in the android ndk (so `CMAKE_C**_COMPILER` points to the android ndk). However, this compiler is not capable of compiling any host binaries. So the way we make this work is by setting the host compilers via `-DCROSS_TOOLCHAIN_FLAGS_NATIVE`. This worked because command line has precedence over the compiler specified by the environment variables. However, this now appends `-DCMAKE_C**_COMPILER`, which will override whatever compiler we have specified via cross toolchain flags.
>
> I am not sure we ever want to be specifying the native compiler, as this is likely to be different in any non-trivial cross-compilation scenario, but if we're going to do that, could we at least put `CROSS_TOOLCHAIN_FLAGS` last so that this can be overridden by the user who needs it?


I'm getting a similar problem where passing in CMAKE_CXX_COMPILER breaks my native build, except it's harder to work around because I don't specify CROSS_TOOLCHAIN_FLAGS. I'm building for a device, and specify a C++ compiler for that build, but that compiler isn't the correct one for building my native tools. When no compiler was specified on the cross-compile-native cmake invocation, this worked, but now this ends up using the wrong compiler and failing.

I could probably pass in the default compiler to CROSS_TOOLCHAIN_FLAGS_NATIVE to work around this, but that's awkward since I just want to use cmake's native logic to find it.


Repository:
  rL LLVM

https://reviews.llvm.org/D40229





More information about the llvm-commits mailing list