ClangBuiltLinux / linux

Linux kernel source tree
Other
241 stars 14 forks source link

thinLTO is linking with one thread? #1847

Open nickdesaulniers opened 1 year ago

nickdesaulniers commented 1 year ago

Doing an x86 defconfig build with CONFIG_LTO_CLANG_THIN=y enabled, I'm seeing only 1 thread being used by LLD during LD vmlinux.o. Is that expected/a regression?

cc @samitolvanen @MaskRay

samitolvanen commented 1 year ago

No, that's not expected. You should see one process with multiple threads. Unless something changed and we now have to explicitly specify the number of ThinLTO jobs?

torvic9 commented 1 year ago

Maybe related: I've never seen ThinLTO use all of the available CPUs when building the kernel (lld-15 and lld-16). At best, it uses exactly half; in my case, 12 out of 24 on a Zen2.

Is there some sort of a "limit" on how many threads LTO can use?

torvic9 commented 1 year ago

I checked it again, Linux 6.3.3 + Clang16:

Linking vmlinux.o starts off with using half of the available CPUs, then quickly goes down to just using a single thread.

samitolvanen commented 1 year ago

You could try passing --thinlto-jobs=N to lld and see if that makes any difference?

https://clang.llvm.org/docs/ThinLTO.html#controlling-backend-parallelism

nathanchance commented 1 year ago

Could https://github.com/llvm/llvm-project/commit/a8788de1c3f3c8c3a591bd3aae2acee1b43b229a be related?