Felix Singer has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/81673?usp=email )
Change subject: util/crossgcc: Link libLLVM dynamically reducing build time with ccache ......................................................................
util/crossgcc: Link libLLVM dynamically reducing build time with ccache
When coreboot is built with Clang and ccache enabled, the build time is incredibly long and it feels like that an existing cache is not used for the build. This is not the case though since the statistics created by ccache proof that the cache is used.
While tracking down the issue, it led to our configuration of the build system, which configures the ccache option `CCACHE_COMPILERCHECK` and sets it to `content`. Enabling this option makes ccache including the state of the compiler binary in the hash in some way. While the default configuration (`mtime`) only includes the modification time and file size, the mode `content` hashes the compiler binary instead. Depending on its file size, the time to calculate the hash might vary a lot. Looking at the current sizes of the compiler binaries, it's 1.4 MB for GCC and 155 MB for Clang.
However, the huge file size for the Clang binary originates from that libLLVM is linked statically. Linking libLLVM dynamically reduces the file size of the Clang binary to 195 KB.
The build times compared without and with this patch using Clang as compiler with ccache enabled and QEMU Q35 with payload disabled:
Static, no cache (first build)
real 1m45.128s user 0m42.828s sys 1m2.428s
Static, with cache (second build)
real 1m17.927s user 0m22.290s sys 0m55.842s
Dynamic, no cache (first build)
real 0m32.648s user 0m24.244s sys 0m8.609s
Dynamic, with cache (second build)
real 0m3.635s user 0m2.250s sys 0m1.630s
Change-Id: I62d4e3fd8ce7f54bd12b1e62eca4beb1259c3da8 Signed-off-by: Felix Singer felixsinger@posteo.net --- M util/crossgcc/buildgcc 1 file changed, 1 insertion(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/73/81673/1
diff --git a/util/crossgcc/buildgcc b/util/crossgcc/buildgcc index b1cb02c..3dd8d63 100755 --- a/util/crossgcc/buildgcc +++ b/util/crossgcc/buildgcc @@ -890,6 +890,7 @@ -DLLVM_INCLUDE_EXAMPLES="OFF" \ -DCMAKE_BUILD_TYPE=Release \ -DLLVM_TARGETS_TO_BUILD="AArch64;ARM;PowerPC;RISCV;X86" \ + -DLLVM_LINK_LLVM_DYLIB="ON" \ ../llvm || touch .failed # shellcheck disable=SC2086 $MAKE $JOBS || touch .failed