When Chromium builds LLVM, we perform a bunch of runtimes builds (Fuchsia x86-64 + aarch64, Android aarch64 + arm + i686 + riscv64 + x86-64, Linux aarch64 + arm + i386 + x86-64). These build times are dominated by CMake compiler flag checks (e.g. I see it spend minutes check flags for a target, then 10s compiling everything for that runtime).
These checks are mostly done here. Some of these should be obviously skippable in certain cases, e.g. MSVC-style flags when not using an MSVC-style compiler and vice versa. Some of these are only used in certain cases, e.g. this block of warnings. Can these be checked only if theyāre going to be used?
These seem like pretty easy compile time wins, or am I missing something?
What do we think about adding a fast path for flags which are known to exist in ToT Clang for runtimes builds?
Consider something like check_clang_flag("-Wwhatever" HAVE_WWHATEVER_FLAG) and in check_clang_flag we basically say āif Iām using ToT clang, then skip the check and return trueā. In the runtimes build, when we configure compiler-rt, weād set some cmake option to indicate that ToT clang is in use.
These flag checks mostly exist to cover building with old compiler versions.
Similarly, we could just audit whether or not flags are supported on our minimum supported compiler version and just remove all the checks that are supported.
Can the results of the checks be cached? Presumably details of the host toolchain donāt change all that often in CI. ISTM this would cover the not-using-just-built clang cases.
Right, but what about caching in a different sense, not the CMake cache⦠e.g. capture the results of the checks and stick them in a toolchain file for use in a clean run.
I prepared a patch that removes 36 compiler flag check from Clang, LLVM, and LLDB. While not addressing the checks in OP, this still should help a bit.