[all-commits] [llvm/llvm-project] 7017e6: [cmake] Partially deduplicate `{llvm, compiler_rt}_...

John Ericson via All-commits all-commits at lists.llvm.org
Fri Jan 28 22:07:36 PST 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 7017e6c9cfd2de3122ce9528f338a97d61e96373
      https://github.com/llvm/llvm-project/commit/7017e6c9cfd2de3122ce9528f338a97d61e96373
  Author: John Ericson <John.Ericson at Obsidian.Systems>
  Date:   2022-01-29 (Sat, 29 Jan 2022)

  Changed paths:
    R cmake/Modules/CheckLinkerFlag.cmake
    A cmake/Modules/LLVMCheckCompilerLinkerFlag.cmake
    M compiler-rt/cmake/config-ix.cmake
    M libcxx/cmake/config-ix.cmake
    M libunwind/cmake/config-ix.cmake
    M llvm/cmake/modules/LLVMCheckLinkerFlag.cmake
    M runtimes/CMakeLists.txt

  Log Message:
  -----------
  [cmake] Partially deduplicate `{llvm,compiler_rt}_check_linker_flag` for runtime libs and llvm

We previously had a few varied definitions of this floating around.

I had tried to make the one installed with LLVM handle all the cases, and then made the others use it, but this ran into issues with `HandleOutOfTreeLLVM` not working for compiler-rt, and also `CMAKE_EXE_LINKER_FLAGS` not working right without `CMP0056` set to the new behavior.

 My compromise solution is this:

 - No not completely deduplicate: the runtime libs will instead use a version that still exists as part of the internal and not installed common shared CMake utilities. This avoids `HandleOutOfTreeLLVM` or a workaround for compiler-rt.

- Continue to use `CMAKE_REQUIRED_FLAGS`, which effects compilation and linking. Maybe this is unnecessary, but it's safer to leave that as a future change. Also means we can avoid `CMP0056` for now, to try out later, which is good incrementality too.

- Call it `llvm_check_compiler_linker_flag` since it, in fact is about both per its implementation (before and after this patch), so there is no name collision.

In the future, we might still enable CMP0056 and make compiler-rt work with HandleOutOfTreeLLVM, which case we delete `llvm_check_compiler_flag` and go back to the old way (as these are, in fact, linking related flags), but that I leave for someone else as future work.

The original issue was reported to me in https://reviews.llvm.org/D116521#3248117 as
D116521 made clang and LLVM use the common cmake utils.

Reviewed By: sebastian-ne, phosek, #libunwind, #libc, #libc_abi, ldionne

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




More information about the All-commits mailing list