Compiling Linux Kernel Using LLVM

I have a particular itch that I want to scratch…Compiling the Linux Kernel with just LLVM toolchain on Alpine Linux.
I use Alpine Linux on top of WSL2 for majority of my work except when it comes to compiling Linux.

WSL2 has its own documentation for building the kernel which works fine on Ubuntu/Debian.

But when I use Alpine Linux as my base distro with only LLVM toolchain as documented by main linux docs I get the following error:

$  make LLVM=1 V=1 KCONFIG_CONFIG=Microsoft/config-wsl
  clang -Wp,-MMD,scripts/basic/.fixdep.d -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 -fomit-frame-pointer -std=gnu89         -o scripts/basic/fixdep scripts/basic/fixdep.c
clang-13: error: unable to execute command: Executable "ld" doesn't exist!
clang-13: error: linker command failed with exit code 1 (use -v to see invocation)
.....

I tried compiling the vanilla kernel in the same Alpine environment and got the same error message, so I guess Microsoft’s custom configs aren’t to be blamed for this error.

Anyone has any idea what I am doing wrong here? Why is clang calling ld when I have lld already installed.

The LLVM=1 flag automatically uses lld as the linker according to the docs

I am pretty new to C compiler flags, so any help or hint would be greatly appreciated. The goal here is to just build Linux without any GNU components (except libgcc and libstdc++ maybe)

Thank you!

Fair warning, I am not a user of LLVM. Your post intrigued me, so I did some online search; I haven’t tested the suggestion below.

Various posts (often years old) suggest that it is appropriate to make a symbolic link so that /usr/bin/ld is redirected to the LLVM linker ld.lld (wherever it is located on your machine). Recent LLVM documentation mentions this as one of a few alternatives; see the “Using LLVM” section in this link:
https://releases.llvm.org/14.0.0/tools/lld/docs/index.html

Hope that proves useful, and that this reply is “better late than never”.