microsoft / WSL

Issues found on WSL
https://docs.microsoft.com/windows/wsl
MIT License
17.23k stars 811 forks source link

Error in Build Instructions for WSL2-Linux-Kernel #7667

Open Terminator-J opened 2 years ago

Terminator-J commented 2 years ago

Version

Microsoft Windows Version 21H1 (OS Build 19043.1348)

WSL Version

Kernel Version

5.10.74.3-microsoft-standard-WSL2+

Distro Version

Ubuntu Server 21.04 (hirsute)

Other Software

The issue isn't with WSL, the issue is with compiling the WSL2 kernel source (but of course we can't open issues/PRs against that repository, and are directed here instead).

Attempting to follow the Build Instructions as written results in an error due to the missing pahole binary, since the build-essentials metapackage no longer includes the dwarves package in recent versions of Ubuntu. Manually adding the dwarves package works successfully.

Please consider merging the following commit to correct your issue: https://github.com/Terminator-J/WSL2-Linux-Kernel/commit/70376ecb4087139b891e6222ae8e115ca82e22ef

Repro Steps

$ git clone https://github.com/microsoft/WSL2-Linux-Kernel -b linux-msft-wsl-5.10.74.3
$ cd WSL2-Linux-Kernel
$ sudo apt install build-essential flex bison libssl-dev libelf-dev
$ make KCONFIG_CONFIG=Microsoft/config-wsl

Expected Behavior

terminator-j@host:~/WSL2-Linux-Kernel$ make KCONFIG_CONFIG=Microsoft/config-wsl
  SYNC    include/config/auto.conf.cmd
  CALL    scripts/checksyscalls.sh
  CALL    scripts/atomic/check-atomics.sh
  DESCEND  objtool
  DESCEND  bpf/resolve_btfids
  CHK     include/generated/compile.h
  GEN     .version
  CHK     include/generated/compile.h
  UPD     include/generated/compile.h
  CC      init/version.o
  AR      init/built-in.a
  LD      vmlinux.o
  MODPOST vmlinux.symvers
  MODINFO modules.builtin.modinfo
  GEN     modules.builtin
  LD      .tmp_vmlinux.btf
  BTF     .btf.vmlinux.bin.o
  LD      .tmp_vmlinux.kallsyms1
  KSYMS   .tmp_vmlinux.kallsyms1.S
  AS      .tmp_vmlinux.kallsyms1.S
  LD      .tmp_vmlinux.kallsyms2
  KSYMS   .tmp_vmlinux.kallsyms2.S
  AS      .tmp_vmlinux.kallsyms2.S
  LD      vmlinux
  BTFIDS  vmlinux
  SORTTAB vmlinux
  SYSMAP  System.map
  CC      arch/x86/boot/a20.o
  AS      arch/x86/boot/bioscall.o
  CC      arch/x86/boot/cmdline.o
  AS      arch/x86/boot/copy.o
  HOSTCC  arch/x86/boot/mkcpustr
  CPUSTR  arch/x86/boot/cpustr.h
  CC      arch/x86/boot/cpu.o
  CC      arch/x86/boot/cpuflags.o
  CC      arch/x86/boot/cpucheck.o
  CC      arch/x86/boot/early_serial_console.o
  CC      arch/x86/boot/edd.o
  LDS     arch/x86/boot/compressed/vmlinux.lds
  AS      arch/x86/boot/compressed/kernel_info.o
  AS      arch/x86/boot/compressed/head_64.o
  VOFFSET arch/x86/boot/compressed/../voffset.h
  CC      arch/x86/boot/compressed/misc.o
  CC      arch/x86/boot/compressed/string.o
  CC      arch/x86/boot/compressed/cmdline.o
  CC      arch/x86/boot/compressed/error.o
  OBJCOPY arch/x86/boot/compressed/vmlinux.bin
  RELOCS  arch/x86/boot/compressed/vmlinux.relocs
  GZIP    arch/x86/boot/compressed/vmlinux.bin.gz
  HOSTCC  arch/x86/boot/compressed/mkpiggy
  MKPIGGY arch/x86/boot/compressed/piggy.S
  AS      arch/x86/boot/compressed/piggy.o
  CC      arch/x86/boot/compressed/cpuflags.o
  CC      arch/x86/boot/compressed/early_serial_console.o
  CC      arch/x86/boot/compressed/kaslr.o
  CC      arch/x86/boot/compressed/ident_map_64.o
  CC      arch/x86/boot/compressed/idt_64.o
  AS      arch/x86/boot/compressed/idt_handlers_64.o
  AS      arch/x86/boot/compressed/mem_encrypt.o
  CC      arch/x86/boot/compressed/pgtable_64.o
  CC      arch/x86/boot/compressed/acpi.o
  AS      arch/x86/boot/compressed/efi_thunk_64.o
  LD      arch/x86/boot/compressed/vmlinux
  ZOFFSET arch/x86/boot/zoffset.h
  AS      arch/x86/boot/header.o
  CC      arch/x86/boot/main.o
  CC      arch/x86/boot/memory.o
  CC      arch/x86/boot/pm.o
  AS      arch/x86/boot/pmjump.o
  CC      arch/x86/boot/printf.o
  CC      arch/x86/boot/regs.o
  CC      arch/x86/boot/string.o
  CC      arch/x86/boot/tty.o
  CC      arch/x86/boot/video.o
  CC      arch/x86/boot/video-mode.o
  CC      arch/x86/boot/version.o
  CC      arch/x86/boot/video-vga.o
  CC      arch/x86/boot/video-vesa.o
  CC      arch/x86/boot/video-bios.o
  LD      arch/x86/boot/setup.elf
  OBJCOPY arch/x86/boot/setup.bin
  OBJCOPY arch/x86/boot/vmlinux.bin
  HOSTCC  arch/x86/boot/tools/build
  BUILD   arch/x86/boot/bzImage
Kernel: arch/x86/boot/bzImage is ready  (#4)
  LDS     scripts/module.lds
  MODPOST modules-only.symvers
  GEN     Module.symvers
terminator-j@host:~/WSL2-Linux-Kernel$

Actual Behavior

terminator-j@host:~/WSL2-Linux-Kernel$ make KCONFIG_CONFIG=Microsoft/config-wsl
  SYNC    include/config/auto.conf.cmd
  CALL    scripts/checksyscalls.sh
  CALL    scripts/atomic/check-atomics.sh
  DESCEND  objtool
  DESCEND  bpf/resolve_btfids
  CHK     include/generated/compile.h
  GEN     .version
  CHK     include/generated/compile.h
  UPD     include/generated/compile.h
  CC      init/version.o
  AR      init/built-in.a
  LD      vmlinux.o
  MODPOST vmlinux.symvers
  MODINFO modules.builtin.modinfo
  GEN     modules.builtin
BTF: .tmp_vmlinux.btf: pahole (pahole) is not available
Failed to generate BTF for vmlinux
Try to disable CONFIG_DEBUG_INFO_BTF
make: *** [Makefile:1179: vmlinux] Error 1
terminator-j@host:~/WSL2-Linux-Kernel$

Diagnostic Logs

Please see https://github.com/Terminator-J/WSL2-Linux-Kernel/commit/70376ecb4087139b891e6222ae8e115ca82e22ef for resolution, since we are unable to submit PRs directly to the correct repo.

quintenvandamme commented 2 years ago

sudo apt install dwarves

cheneytianx commented 2 years ago

After rebuilding the kernel successfully, /sys/kernel/btf/directory does not exist yet.

mwoodpatrick commented 8 months ago

I hit the same issue building the 6.1 kernel, same fix appears to work

razamatan commented 7 months ago

if you're building this in gentoo, s/dwarves/pahole/

igortas commented 2 months ago

sudo apt install dwarves

dwarves also not found

razamatan commented 2 months ago

sudo apt install dwarves

dwarves also not found

try installing pahole: https://www.google.com/search?q=pahole+dwarves

https://launchpad.net/ubuntu/jammy/+package/pahole