microsoft / WSL

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

Hello, I have a problem when compiling the WSL2 kernel #7253

Closed GayFirends closed 10 months ago

GayFirends commented 3 years ago

Windows Build Number

10.0.22000.100

WSL Version

Kernel Version

5.10.43.3

Distro Version

Debian

Other Software

No response

Repro Steps

This problem occurs when I compile the WSL2 kernel I am using Nvidia Geforce GTX1050 graphics card

Expected Behavior

He will compile successfully

Actual Behavior

drivers/hv/dxgkrnl/dxgmodule.c:392:39: error: initializer element is not constant const int DXGK_VMBUS_VERSION_OFFSET = DXGK_VMBUS_CHANNEL_ID_OFFSET + ^~~~~~~~ drivers/hv/dxgkrnl/dxgmodule.c:395:41: error: initializer element is not constant const int DXGK_VMBUS_VGPU_LUID_OFFSET = DXGK_VMBUS_VERSION_OFFSET + ^~~~~~~~~ drivers/hv/dxgkrnl/dxgmodule.c:398:41: error: initializer element is not constant const int DXGK_VMBUS_GUESTCAPS_OFFSET = DXGK_VMBUS_VERSION_OFFSET + ^~~~~~~~~ scripts/Makefile.build:279: recipe for target 'drivers/hv/dxgkrnl/dxgmodule.o' failed make[3]: [drivers/hv/dxgkrnl/dxgmodule.o] Error 1 scripts/Makefile.build:496: recipe for target 'drivers/hv/dxgkrnl' failed make[2]: [drivers/hv/dxgkrnl] Error 2 scripts/Makefile.build:496: recipe for target 'drivers/hv' failed make[1]: [drivers/hv] Error 2 Makefile:1821: recipe for target 'drivers' failed make: [drivers] Error 2

Diagnostic Logs

No response

benhillis commented 3 years ago

Which branch / tag are you trying to build?

hiseholuwa commented 3 years ago

I also have the same issue. Trying to compile the linux-msft-wsl-5.10.y branch. Changed in .config file CONFIG_SOUND=y to enable ALSA dummy module compilation with the kernel. Compiling in Ubuntu 18.04 on WSL2.

hiseholuwa commented 3 years ago

I fixed this by changing the constants to enums in the driver dxgmodule.c file. Apparently, C does not regard const-qualified objects as constants, and as such, they cannot be used to initialize objects with static storage.

enum { DXGK_VMBUS_CHANNEL_ID_OFFSET = 192 };
enum { DXGK_VMBUS_VERSION_OFFSET = DXGK_VMBUS_CHANNEL_ID_OFFSET + sizeof(guid_t) };
enum { DXGK_VMBUS_VGPU_LUID_OFFSET = DXGK_VMBUS_VERSION_OFFSET + sizeof(u32) };
enum { DXGK_VMBUS_GUESTCAPS_OFFSET = DXGK_VMBUS_VERSION_OFFSET + sizeof(u32) };
microsoft-github-policy-service[bot] commented 10 months ago

This issue has been automatically closed since it has not had any activity for the past year. If you're still experiencing this issue please re-file this as a new issue or feature request.

Thank you!