Linux driver 525.125.06 compilation fails with kernel 6.1.58


I have been trying to compile the nvidia driver for a while now but I have never been able to. System is Debian unstable, gcc 13.2 (clang throws the same errors). I have tried to find some of the error messages on the net but I had no luck. The build log is attached:
make.log (702.4 KB)

The compile errors are quite weird, rather looks like the generic kernel headers are either not correctly installed or broken. Please purge/reinstall them.

thanks for the answer, but sadly that did not change anything. But I like the idea behind it. So I investigated more thoroughly. The first error is:

cc1: error: cannot load plugin ./scripts/gcc-plugins/ ./scripts/gcc-plugins/ cannot open shared object file: No such file or directory

However, the file is there and ldd doesn’t show any unresolved libs. The first conftest that fails fails because of this. Then I logged pwd and it says /var/lib/dkms/nvidia-tesla/525.125.06/build. However, the scripts/gcc-plugins/... is under /usr/src/linux-headers-6.1.58, which make enters right at the beginning but conftest apparently changes sometime later.

So: Are gcc-plugins not supported? Or is there a bug using a relative path to them?

Ok, quick hack as a (temporary) solution:

ln -s /usr/src/linux-headers-6.1.58/scripts /usr/src/nvidia-tesla-525.125.06

Now I can successfully build the nvidia modules!