[PATCH] D126313: [CMake] Don't pass CMAKE_C(XX)_COMPILER to the nested NATIVE build

Martin Storsjö via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri May 27 14:34:14 PDT 2022


mstorsjo added a comment.

In D126313#3543213 <https://reviews.llvm.org/D126313#3543213>, @phosek wrote:

> I looked at the change and read your description but still don't understand the motivation, Can you explain why is using `CMAKE_C(XX)_COMPILER` a problem

When I cross compile LLVM on linux, targeting Windows, I configure that build with e.g. `-DCMAKE_CROSSCOMPILING=TRUE -DCMAKE_SYSTEM_NAME=Windows -DCMAKE_C_COMPILER=x86_64-w64-mingw32-clang -DCMAKE_CXX_COMPILER=x86_64-w64-mingw32-clang++`. Now this cross build will try to build native tblgen executables with `x86_64-w64-mingw32-clang++`, which obviously isn't going to work.

> and how do we know that the default that's picked up by CMake will be the correct one?

The assumption is that if you run CMake without `CMAKE_CROSSCOMPILING` and without specifying `CMAKE_CXX_COMPILER` (which it will do for the nested native build), it will pick the system's default compiler (`cc` and `c++` on unix, or MSVC and/or gcc on windows, etc) which is supposed to produce executables that can run on the build host.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D126313/new/

https://reviews.llvm.org/D126313



More information about the llvm-commits mailing list