The following error occurred when I built nvidia driver on acrn, an open source virtualization project. The graphics card I used was RTX2000 12G
ld -r -o /tmp/selfgz159504/NVIDIA-Linux-x86_64-535.98/kernel/nvidia-modeset/nv-modeset-interface.o /tmp/selfgz159504/NVIDIA-Linux-x86_64-535.98/kernel/nvidia-modeset/nvidia-modeset-linux.o /tmp/selfgz159504/NVIDIA-Linux-x86_64-535.98/kernel/nvidia-modeset/nv-kthread-q.o
LD [M] /tmp/selfgz159504/NVIDIA-Linux-x86_64-535.98/kernel/nvidia-uvm.o
LD [M] /tmp/selfgz159504/NVIDIA-Linux-x86_64-535.98/kernel/nvidia-peermem.o
LD [M] /tmp/selfgz159504/NVIDIA-Linux-x86_64-535.98/kernel/nvidia-drm.o
MODPOST /tmp/selfgz159504/NVIDIA-Linux-x86_64-535.98/kernel/Module.symvers
ERROR: modpost: GPL-incompatible module nvidia.ko uses GPL-only symbol ‘mutex_destroy’
make[2]: *** [scripts/Makefile.modpost:134: /tmp/selfgz159504/NVIDIA-Linux-x86_64-535.98/kernel/Module.symvers] Error 1
make[2]: *** Deleting file ‘/tmp/selfgz159504/NVIDIA-Linux-x86_64-535.98/kernel/Module.symvers’
make[2]: Target ‘__modpost’ not remade because of errors.
make[1]: *** [Makefile:1783: modules] Error 2
make[1]: Leaving directory ‘/usr/src/linux-headers-5.15.44-acrn-service-vm’
make: *** [Makefile:82: modules] Error 2
→ Error.
ERROR: An error occurred while performing the step: “Building kernel modules”. See /var/log/nvidia-installer.log for details.
→ The command cd ./kernel; /usr/bin/make -k -j12 NV_EXCLUDE_KERNEL_MODULES="" SYSSRC="/usr/src/linux-headers-5.15.44-acrn-service-vm" SYSOUT="/usr/src/linux-headers-5.15.44-acrn-service-vm"
failed with the following output:
make[1]: Entering directory ‘/usr/src/linux-headers-5.15.44-acrn-service-vm’
warning: the compiler differs from the one used to build the kernel
The kernel was built by: gcc (Ubuntu 9.4.0-1ubuntu1~20.04.2) 9.4.0
You are using: cc (Ubuntu 9.4.0-1ubuntu1~20.04.2) 9.4.0
SYMLINK /tmp/selfgz159504/NVIDIA-Linux-x86_64-535.98/kernel/nvidia/nv-kernel.o
SYMLINK /tmp/selfgz159504/NVIDIA-Linux-x86_64-535.98/kernel/nvidia-modeset/nv-modeset-kernel.o