Frogging-Family / nvidia-all

Nvidia driver latest to 396 series AIO installer
768 stars 69 forks source link

Adding a workaround for building kernel modules via LLVM/Clang #65

Closed Cabopust closed 2 years ago

Cabopust commented 2 years ago

Adds a workaround for building modules via clang. Works by forcing environment variables in dkms.conf. This works fine for me and linux-tkg-llvm, but it's not a perfect solution, and I understand that it could break at every step if NVIDIA changes something.

So I'm not sure what it should be in the upstream, but still decided to leave it here.

Closes: https://github.com/Frogging-Family/nvidia-all/issues/55 https://github.com/Frogging-Family/nvidia-all/issues/36

C43H66N12O12S2 commented 2 years ago

This won't close my issue, #61, because it's not a DKMS issue. The module builds just fine (I had already setup DKMS to use LLVM). That same issue happened when I built the module without DKMS too, btw.

Cabopust commented 2 years ago

@C43H66N12O12S2 Sorry, I didn't read your last post in the issue. However, you should have declared right away that this problem is not specific to clang.

C43H66N12O12S2 commented 2 years ago

I didn't say it was specific to Clang. It may very well be, however. I didn't test with a GCC kernel. However, my point was that: This PR provides a convenient way to setup DKMS to use Clang so it's compatible with a Clang kernel. My issue wasn't related to DKMS, if it was, it would error out and not compile in the first place.

So, this PR, while useful, was completely unrelated to my issue.

timocapa commented 2 years ago

I think you should add the ability to specify a custom path, instead of forcing host tools, like linux-tkg does.

Cabopust commented 2 years ago

@timocapa As far as I remember, in nvidia-all now CUSTOM_GCC_PATH only works for non-dkms modules, at the same time this workaround is only done for DKMS so far.

Cabopust commented 2 years ago

@timocapa Nevertheless, I'll think about how else it can be implemented.

timocapa commented 2 years ago

No biggie :)

Cabopust commented 2 years ago

Now it supports regular modules. This became possible thanks to the checking added by the 8091043 commit, which provides verification of the kernel to which the driver modules are installed. In other words, now for all kernels compiled using GCC, NVIDIA modules will be compiled using GCC, and for all kernels compiled by LLVM/clang, modules will be compiled via LLVM/clang, respectively. This is both useful and allows you to get along with the GCC and LLVM kernels in the system. For now, this behavior applies only to regular modules, but I will add this for DKMS later.

Cabopust commented 2 years ago

@timocapa Done, but so far only for non-DKMS modules.

Cabopust commented 2 years ago

It looks like it should be implemented on the dkms side (https://github.com/dell/dkms/pull/169), so I will close this.