Some nerds might be interested: Building the WSL2 kernel with Clang Last updated: 22:10 30.10.2020 Or just get it and this documentation from here: https://www.dropbox.com/sh/nhcbxnv5zllxuof/AABbHdkf3Yd4RuEPnkBf5MMLa?dl=0 Sources https://nathanchance.dev/posts/wsl2-kernel-clang/ https://www.xyb.name/2020/03/14/build-your-kernel-for-wsl2/ Howto 1. Download and install the needed tools. Use Ubuntu 20.04. Ubuntu 20.10 seems not to work at the moment. $ sudo apt update $ sudo apt upgrade $ sudo apt install -y --no-install-recommends bc bison build-essential ca-certificates flex git gnupg libelf-dev libssl-dev lsb-release software-properties-common wget Install Clang 11 $ cd ~ $ wget https://apt.llvm.org/llvm.sh $ chmod +x llvm.sh $ sudo ./llvm.sh 11 2. Download the kernel source code The latest is 5.9.2 at the moment. $ wget https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.9.2.tar.xz $ tar xf linux-5.9.2.tar.xz $ cd linux-5.9.2 $ wget https://raw.githubusercontent.com/microsoft/WSL2-Linux-Kernel/master/Microso... 3. Build the kernel. An out directory (out.x86_64) can be handy to have a clean environment. $ make -j$(nproc) -s CC=clang-11 KCONFIG_CONFIG=config-wsl LD=ld.lld-11 O=out.x86_64 distclean olddefconfig all 1. Move the kernel to the Windows file system. I have my kernels sitting at e:\wsl\kernel. $ cp out.x86_64/arch/x86/boot/bzImage /mnt/e/wsl/kernel/linux-5.9.2 2. Tell WSL2 to use that kernel when booting up. Create a .wslconfig file in your user directory for example at c:\users\username. This file should contain the following: [wsl2] kernel = e:\\wsl\\kernel\\linux-5.9.2 Note that you need to use double backslashes. Then do on a cmd window. $ wsl --shutdown Then load a linux distro and type $ cat /proc/version Now you should see something like that Linux version 5.9.2-microsoft-standard (root@SimonPC) (Ubuntu clang version 11.0.0-++20201021094914+176249bd673-1~exp1~2 0201021075533.113, LLD 11.0.0) #1 SMP Fri Oct 30 21:04:46 CET 2020 Some have noticed that the VM gets stuck starting with a custom kernel at times; if that happens, run wsl --shutdown and try reopening one of the distributions again, it will usually work after a couple of times. Enjoy.
Thank you for the reference. I didn't realize that efforts to enable the Linux kernel to be compiled with Clang had progressed this far.
Hi, at least it seems to work. :-) Here's the latest documentation and binaries: https://www.dropbox.com/sh/nhcbxnv5zllxuof/AABbHdkf3Yd4RuEPnkBf5MMLa?dl=0 Linux 5.9.3 has been compiled and already uploaded. I am using the original microsoft kernel config file from their github repo. So not sure if its the latest and greatest but it seems to work fine. I don't know if the kernel makefile can do autodetect everything what it needs and takes out the maximum performance and features. But maybe a linux guy who already has compiled kernels might chime in here. Greetings, Simon Am 01.11.2020 um 18:47 schrieb Jason White via Blind-sysadmins:
Thank you for the reference. I didn't realize that efforts to enable the Linux kernel to be compiled with Clang had progressed this far. _______________________________________________ Blind-sysadmins mailing list -- blind-sysadmins@lists.hodgsonfamily.org To unsubscribe send an email to blind-sysadmins-leave@lists.hodgsonfamily.org
participants (2)
-
Jason White
-
Simon Eigeldinger