[all-commits] [llvm/llvm-project] a59165: [runtimes] Don't try passing --target flags to GCC

Louis Dionne via All-commits all-commits at lists.llvm.org
Thu Jul 15 13:52:33 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: a59165b01778a3b02c510a96951d115d39babd86
      https://github.com/llvm/llvm-project/commit/a59165b01778a3b02c510a96951d115d39babd86
  Author: Louis Dionne <ldionne.2 at gmail.com>
  Date:   2021-07-15 (Thu, 15 Jul 2021)

  Changed paths:
    M libcxx/CMakeLists.txt
    M libcxx/cmake/Modules/HandleLibcxxFlags.cmake
    M libcxxabi/CMakeLists.txt
    M libcxxabi/cmake/Modules/HandleLibcxxabiFlags.cmake
    M libunwind/CMakeLists.txt
    M libunwind/cmake/Modules/HandleLibunwindFlags.cmake

  Log Message:
  -----------
  [runtimes] Don't try passing --target flags to GCC

When a target triple is specified in CMake via XXX_TARGET_TRIPLE, we tried
passing the --target=<...> flag to the compiler. However, not all compilers
support that flag (e.g. GCC, which is not a cross-compiler). As a result,
setting e.g. LIBCXX_TARGET_TRIPLE=<host-triple> would end up trying to
pass --target=<host-triple> to GCC, which breaks everything because the
flag isn't even supported.

This commit only adds `--target=<...>` & friends to the flags if it is
supported by the compiler.

One could argue that it's confusing to pass LIBCXX_TARGET_TRIPLE=<...>
and have it be ignored. That's correct, and one possibility would be
to assert that the requested triple is the same as the host triple when
we know the compiler is unable to cross-compile. However, note that this
is a pre-existing issue (setting the TARGET_TRIPLE variable never had an
influence on the flags passed to the compiler), and also fixing that is
starting to look like reimplementing a lot of CMake logic that is already
handled with CMAKE_CXX_COMPILER_TARGET.

Differential Revision: https://reviews.llvm.org/D106082




More information about the All-commits mailing list