Re: Very slow clang kernel config ..

From: Dan Aloni
Date: Sun May 02 2021 - 01:19:31 EST


On Fri, Apr 30, 2021 at 06:48:11PM -0700, Nick Desaulniers wrote:
> On Fri, Apr 30, 2021 at 6:22 PM Linus Torvalds
> <torvalds@xxxxxxxxxxxxxxxxxxxx> wrote:
> > 0.92% libLLVM-12.so llvm::StringMapImpl::LookupBucketFor
>
> ^ wait a minute; notice how in your profile the `Shared Object` is
> attributed to `libLLVM-12.so` while mine is `clang-13`? Clang can be
> built as either having libllvm statically linked or dynamically; see
> the cmake variables
> LLVM_BUILD_LLVM_DYLIB:BOOL
> LLVM_LINK_LLVM_DYLIB:BOOL
> BUILD_SHARED_LIBS:BOOL
> https://llvm.org/docs/CMake.html
>
> I think those are frowned upon; useful for cutting down on developers
> iteration speed due to not having to relink llvm when developing
> clang. But shipping that in production? I just checked and it doesn't
> look like we do that for AOSP's build of LLVM.

There's also `-DLLVM_ENABLE_LTO=Thin` that enables LTO for building LLVM
and Clang themselves, considered they can be bootstrapped like this
using a previous version of Clang. Combining that with a non-shared
library build mode for both Clang and LLVM, the result is possibly the
fastest and most optimized build that is achievable. Unfortunately I
see distributions neglecting to enable this in packaging this as well.

On a side note, I'm also a Fedora user and agree with Linus about this.
I'd like to see an opt-in bypass of the shared library policy via
something like `dnf install clang-optimized` that would install the
fastest and most optimized Clang build regardless of RPM install size.

--
Dan Aloni