1

I am trying to build a kernel in Ubuntu-18.04 WSL2 with this tutorial: https://www.frakkingsweet.com/running-pi-gen-on-wsl2/

Configuring worked all fine. But while building it with:

make KCONFIG_CONFIG=Microsoft/config-wsl.new -j4

this error appeared:

drivers/hyperv/dxgkrnl/dxgmodule.c:422:39: error: initializer element is not constant const int DXGK_VMBUS_VERSION_OFFSET = DXGK_VMBUS_CHANNEL_ID_OFFSET +

The dxgmodule file in which the error occurs is a C-file. Content of the file:

419: /* vGPU VM bus channel instance ID */

420: const int DXGK_VMBUS_CHANNEL_ID_OFFSET = 192;

421: /* DXGK_VMBUS_INTERFACE_VERSION (u32) */

422: const int DXGK_VMBUS_VERSION_OFFSET = DXGK_VMBUS_CHANNEL_ID_OFFSET +

423: sizeof(guid_t);

How do I change the code, so that the compiler reads the initializer expression as constant?

Tillmann2018
  • 327
  • 5
  • 10
  • 2
    I think the code is relying on a recent version of GCC where this form of initialization is allowed. It does not work in older GCC versions. The code ought to be changed to be compatible with the minimum GCC version that can be used to build the kernel. I guess this problem will be caught if and when the Microsoft code gets upstreamed to Linux. – Ian Abbott Jul 12 '21 at 11:22
  • Also see this question: [Why “initializer element is not a constant” is… not working anymore?](https://stackoverflow.com/questions/54135942). – Ian Abbott Jul 12 '21 at 11:34
  • installing gcc 9 solved the issue – Tillmann2018 Jul 13 '21 at 09:21

1 Answers1

0

I got a solution.

I changed it to

419: /* vGPU VM bus channel instance ID */

420: const int DXGK_VMBUS_CHANNEL_ID_OFFSET = 192;

421: /* DXGK_VMBUS_INTERFACE_VERSION (u32) */

422: const int DXGK_VMBUS_VERSION_OFFSET = 192 +

423: sizeof(guid_t);

Tillmann2018
  • 327
  • 5
  • 10