Build (5.15.57.1) #13
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build WSL2 Kernel | |
run-name: Build (${{ github.event.inputs.kernel_version }}) | |
on: | |
workflow_dispatch: | |
inputs: | |
kernel_version: | |
description: "WSL2 kernel version (e.g. 5.15.90.4)" | |
required: true | |
default: "5.15.90.4" | |
jobs: | |
build-and-release: | |
runs-on: ubuntu-latest | |
env: | |
KERNEL_VERSION: ${{ github.event.inputs.kernel_version }} | |
KERNEL_DIR: linux-${{ github.event.inputs.kernel_version }} | |
RELEASE_TAG: v${{ github.event.inputs.kernel_version }} | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
- name: Install Dependencies | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y \ | |
build-essential flex bison dwarves \ | |
libssl-dev libelf-dev libncurses-dev \ | |
bc rsync cpio python3 \ | |
pahole | |
- name: Download Kernel Source | |
run: | | |
mkdir -p kernel-build | |
cd kernel-build | |
wget https://github.com/microsoft/WSL2-Linux-Kernel/archive/refs/tags/linux-msft-wsl-${{ env.KERNEL_VERSION }}.tar.gz | |
tar -xzf linux-msft-wsl-${{ env.KERNEL_VERSION }}.tar.gz | |
mv WSL2-Linux-Kernel-linux-msft-wsl-${{ env.KERNEL_VERSION }} linux-${{ env.KERNEL_VERSION }} | |
echo "KERNEL_DIR=$(pwd)/linux-${{ env.KERNEL_VERSION }}" >> $GITHUB_ENV | |
- name: Configure Kernel | |
run: | | |
cd ${{ env.KERNEL_DIR }} | |
cp Microsoft/config-wsl .config | |
./scripts/config --disable DEBUG_INFO_BTF | |
./scripts/config --enable LD_NO_EXEC_STACK | |
./scripts/config --enable INIT_STACK_NONE | |
make olddefconfig | |
- name: Build Kernel | |
run: | | |
cd ${{ env.KERNEL_DIR }} | |
make -j$(nproc) \ | |
LDFLAGS="-z noexecstack -z separate-code" \ | |
LD=ld.bfd | |
if [ ! -f arch/x86/boot/bzImage ]; then | |
echo "::error::Kernel build failed!" | |
exit 1 | |
fi | |
- name: Verify Kernel Image | |
run: | | |
file ${{ env.KERNEL_DIR }}/arch/x86/boot/bzImage | |
ls -lh ${{ env.KERNEL_DIR }}/arch/x86/boot/bzImage | |
- name: Create Release | |
id: create_release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ env.RELEASE_TAG }} | |
release_name: "WSL2 Kernel ${{ env.KERNEL_VERSION }}" | |
body: | | |
### Build Information | |
- Version: ${{ env.KERNEL_VERSION }} | |
- Build Date: $(date -u +'%Y-%m-%d %H:%M:%S') | |
- Build Flags: LDFLAGS="-z noexecstack -z separate-code" | |
### Important Notes | |
This build DISABLED BTF to avoid linker errors. | |
Warnings about executable stack are suppressed but functionally safe. | |
### Installation | |
1. Download `bzImage` | |
2. Place in `C:\Windows\System32\lxss\tools` | |
3. Add to `.wslconfig`: | |
```ini | |
[wsl2] | |
kernel=C:\\Windows\\System32\\lxss\\tools\\bzImage | |
``` | |
draft: false | |
prerelease: false | |
- name: Upload Kernel Image | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ${{ env.KERNEL_DIR }}/arch/x86/boot/bzImage | |
asset_name: bzImage-${{ env.KERNEL_VERSION }} | |
asset_content_type: application/octet-stream | |
- name: Upload Kernel Config | |
uses: actions/upload-release-asset@v1 | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ${{ env.KERNEL_DIR }}/.config | |
asset_name: config-${{ env.KERNEL_VERSION }}.txt | |
asset_content_type: text/plain |