<div dir="ltr">We've been using the runtimes build for a while now and we're very happy with it. However, with an increasing number of targets, it can be fairly slow and I have noticed that we now spend more time in CMake than in Ninja. There are various ways we could improve things like eliminating unnecessary checks.<div><br></div><div>When running checks like check_c_compiler_flag, check_cxx_compiler_flag or check_library_exists, CMake caches the resulting variable and doesn't run the check again. The problem is that in LLVM, each subproject uses different variable names for results of these checks. For example, most subprojects check if pthread is available and store the result in:</div><div><br></div><div></div><div>COMPILER_RT_HAS_LIBPTHREAD (compiler-rt)</div><div>LIBCXX_HAS_PTHREAD_LIB (libc++)<br></div><div>LIBCXXABI_HAS_PTHREAD_LIB (libc++abi)<br></div><div>LIBUNWIND_HAS_PTHREAD_LIB (libunwind)<br></div><div>HAVE_LIBPTHREAD (llvm)<br></div><div><br></div><div>This means that even though this check would ideally be performed just once (per target) and reused everywhere, it's performed 5 times. The same is true for most flags and library checks.</div><div><br></div><div>I think that this is really unnecessary and could be easily improved by unifying CMake variable names used in checks across subprojects to benefit from caching.</div><div><br></div><div>I've looked at naming conventions used across all subprojects and I'm proposing the following:</div><div><br></div><div>C_SUPPORTS_${mangled_name}_FLAG for check_c_compiler_flag</div><div>CXX_SUPPORTS_${mangled_name}_FLAG for check_cxx_compiler_flag<br></div><div>HAVE_${mangled_name} for check_library_exists</div><div><br></div><div>Note: It'd be more consistent for check_library_exists to use HAS_${mangled_name}_LIB but that's going to cause more churn in LLVM so that's something to consider.</div><div><br></div><div>This change should be mostly invisible to LLVM developers (except for the handful of build maintainers), but it should considerably speed up the runtimes build and hopefully pave the way to eventually hoist most of the common CMake logic into a shared location.</div><div><br></div><div>I'm happy to implement this change, but I want to get your opinion on the proposal as well as the proposed naming. <br></div></div>