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.
This is not C++ specific so C should be enough.