Trying to compile a USB WiFi adapter driver whose Makefile I was modifying to include riscv64 for the RISC-V VisionFive 2 with Debian, I ran into what appears to be the same error.
user@starfive:~/Documents/github/rtl88x2bu$ make
make ARCH=riscv64 CROSS_COMPILE= -C /lib/modules/5.15.0-starfive/build M=/home/user/Documents/github/rtl88x2bu modules
make[1]: Entering directory '/lib/modules/5.15.0-starfive/build'
warning: the compiler differs from the one used to build the kernel
The kernel was built by: gcc-12 (Debian 12.2.0-9) 12.2.0
You are using: gcc (Debian 12.2.0-10) 12.2.0
CC [M] /home/user/Documents/github/rtl88x2bu/core/rtw_cmd.o
In file included from /usr/src/linux-headers-6.0.0-6-common/include/linux/types.h:6,
from /home/user/Documents/github/rtl88x2bu/include/basic_types.h:75,
from /home/user/Documents/github/rtl88x2bu/include/drv_types.h:26,
from /home/user/Documents/github/rtl88x2bu/core/rtw_cmd.c:17:
/usr/src/linux-headers-6.0.0-6-common/include/uapi/linux/types.h:5:10: fatal error: asm/types.h: No such file or directory
5 | #include <asm/types.h>
| ^~~~~~~~~~~~~
compilation terminated.
make[2]: *** [/usr/src/linux-headers-6.0.0-6-common/scripts/Makefile.build:254: /home/user/Documents/github/rtl88x2bu/core/rtw_cmd.o] Error 1
make[1]: *** [/usr/src/linux-headers-6.0.0-6-common/Makefile:1876: /home/user/Documents/github/rtl88x2bu] Error 2
make[1]: Leaving directory '/lib/modules/5.15.0-starfive/build'
make: *** [Makefile:2410: modules] Error 2
user@starfive:~/Documents/github/rtl88x2bu$
I made a quick change in the types.h file to use asm-generic/types.h and ran into another include directive also using the asm directory rather than asm-generic.
So I reverted the change I had made and took a different tack. I created a symbolic link named asm to the directory asm-generic.
user@starfive:~/Documents/github/rtl88x2bu$ cd /usr/src/linux-headers-6.0.0-6-common/include/uapi
user@starfive:/usr/src/linux-headers-6.0.0-6-common/include/uapi$ ls
Kbuild asm-generic drm linux misc mtd rdma scsi sound video xen
user@starfive:/usr/src/linux-headers-6.0.0-6-common/include/uapi$ sudo ln -s ./asm-generic ./asm
user@starfive:/usr/src/linux-headers-6.0.0-6-common/include/uapi$
I was then able to redo make however I ran into another usage of asm rather than asm-generic in a different include directory.
user@starfive:~/Documents/github/rtl88x2bu$ make
make ARCH=riscv64 CROSS_COMPILE= -C /lib/modules/5.15.0-starfive/build M=/home/user/Documents/github/rtl88x2bu modules
make[1]: Entering directory '/lib/modules/5.15.0-starfive/build'
warning: the compiler differs from the one used to build the kernel
The kernel was built by: gcc-12 (Debian 12.2.0-9) 12.2.0
You are using: gcc (Debian 12.2.0-10) 12.2.0
CC [M] /home/user/Documents/github/rtl88x2bu/core/rtw_cmd.o
In file included from /usr/src/linux-headers-6.0.0-6-common/include/linux/build_bug.h:5,
from /usr/src/linux-headers-6.0.0-6-common/include/linux/container_of.h:5,
from /usr/src/linux-headers-6.0.0-6-common/include/linux/list.h:5,
from /usr/src/linux-headers-6.0.0-6-common/include/linux/module.h:12,
from /home/user/Documents/github/rtl88x2bu/include/basic_types.h:76,
from /home/user/Documents/github/rtl88x2bu/include/drv_types.h:26,
from /home/user/Documents/github/rtl88x2bu/core/rtw_cmd.c:17:
/usr/src/linux-headers-6.0.0-6-common/include/linux/compiler.h:254:10: fatal error: asm/rwonce.h: No such file or directory
254 | #include <asm/rwonce.h>
| ^~~~~~~~~~~~~~
compilation terminated.
make[2]: *** [/usr/src/linux-headers-6.0.0-6-common/scripts/Makefile.build:254: /home/user/Documents/github/rtl88x2bu/core/rtw_cmd.o] Error 1
make[1]: *** [/usr/src/linux-headers-6.0.0-6-common/Makefile:1876: /home/user/Documents/github/rtl88x2bu] Error 2
make[1]: Leaving directory '/lib/modules/5.15.0-starfive/build'
make: *** [Makefile:2410: modules] Error 2
user@starfive:~/Documents/github/rtl88x2bu$
So I used the same procedure in the different include tree.
user@starfive:~/Documents/github/rtl88x2bu$ cd /usr/src/linux-headers-6.0.0-6-common/include
user@starfive:/usr/src/linux-headers-6.0.0-6-common/include$ ls
acpi crypto keys linux memory pcmcia rv sound uapi video
asm-generic drm kunit math-emu misc ras scsi target ufs xen
clocksource dt-bindings kvm media net rdma soc trace vdso
user@starfive:/usr/src/linux-headers-6.0.0-6-common/include$ sudo ln -s ./asm-generic ./asm
I've just run into an error due to a needed option change in the Makefile I'm modifying to support riscv64. However the source seems to be compiling reasonably well though with warnings. Most warnings have some connection to the size of an int such as cast from pointer to int.