CMake compiler flag checks are really slow, ideas to speed them up

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?

1 Like

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.

1 Like

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.

Can we run all these checks in parallel from a batch script? It’s a pity that cmake doesn’t allow any parallelism in 2024.

They are already all cached. I assume the complaint here is about a clean CMake run, not the incremental run.

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.

On Sun, May 12, 2024 at 1:24 PM Chris B via LLVM Discussion Forums <notifications@llvm.discoursemail.com> wrote:

beanz
May 12

They are already all cached. I assume the complaint here is about a clean CMake run, not the incremental run.


Visit Topic or reply to this email to respond.

To unsubscribe from these emails, click here.

1 Like

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.

2 Likes