This is not really a bug report and I don’t need support, but I would like to help you improve the installation script. Because the drivers are closed source I cant check this, but I’m pretty sure that the driver uses /usr/bin/cc instead of cc to compile the dkms modules. It would be better to change it to use just cc. I found this out, because I got a cc version mismatch when trying to install the driver even though my kernel was built with 5.4 and my cc version was 5.4. But my cc resides in /usr/local/bin/cc. And /usr/bin/cc was still 4.8 after changing that one I could successfully build. The effected version is 390.87, but I’m sure this is an issue in other scripts as well. Am I right with this analysis? And is there maybe a good reason to use /usr/bin/cc instead of just cc which I don’t know?
Are you sure your %PATH environment variable is set correctly?
In my experience NVIDIA has always used “gcc” without any prefixes, i.e. whichever gcc that is found in $PATH by default.