[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
Tue May 24 11:55:04 PDT 2022


mstorsjo created this revision.
mstorsjo added reviewers: labath, hintonda, phosek.
Herald added a subscriber: mgorny.
Herald added a project: All.
mstorsjo requested review of this revision.
Herald added a project: LLVM.

Originally, the nested build was set up with the CMake command
`execute_process` which implicitly passes CC/CXX variables for
the configured compiler, which then was picked up by the nested
CMake. (This CMake behaviour, to implicitly pass such variables
is up for discussion and might change in the future; see
https://gitlab.kitware.com/cmake/cmake/-/issues/21378.)

How the nested cmake build is set up was changed in
aa7d6db5c8fc449b2908c6d629d6d9a067f49896 / D40229 <https://reviews.llvm.org/D40229> - the old behaviour
was brought along by manually passing
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} to the nested cmake
configuration. This was then later made optional in
f5f0fffea5ace079cc208fafa65150d23935a4d9 / D40947 <https://reviews.llvm.org/D40947>. But still,
the default if the user doesn't pass
CROSS_TOOLCHAIN_FLAGS_${target_name} (e.g. CROSS_TOOLCHAIN_FLAGS_NATIVE)
is to pass in the surrounding build's compiler - which usually
doesn't work, and is quite non-obvious to figure out.

Just drop the default passing of the outer compiler. This should
avoid surprising cases of using the cross compiler for the native
build for essentially all new users trying to cross compile, until
they've discovered CROSS_TOOLCHAIN_FLAGS_NATIVE.

This was already suggested at the end in D40229 <https://reviews.llvm.org/D40229>, but apparently never
acted upon.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D126313

Files:
  llvm/cmake/modules/CrossCompile.cmake


Index: llvm/cmake/modules/CrossCompile.cmake
===================================================================
--- llvm/cmake/modules/CrossCompile.cmake
+++ llvm/cmake/modules/CrossCompile.cmake
@@ -17,8 +17,6 @@
       -DCMAKE_TOOLCHAIN_FILE=\"${LLVM_MAIN_SRC_DIR}/cmake/platforms/${toolchain}.cmake\")
   else()
     set(CROSS_TOOLCHAIN_FLAGS_INIT
-      -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
-      -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
       )
   endif()
   set(CROSS_TOOLCHAIN_FLAGS_${target_name} ${CROSS_TOOLCHAIN_FLAGS_INIT}


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D126313.431741.patch
Type: text/x-patch
Size: 542 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220524/80c5df0b/attachment.bin>


More information about the llvm-commits mailing list