google / gasket-driver

GNU General Public License v2.0
47 stars 29 forks source link

Build failure on RHEL9 #14

Closed cyqsimon closed 11 months ago

cyqsimon commented 11 months ago
DKMS make.log for gasket-0.0.git.250.9fef422e for kernel 5.14.0-284.25.1.el9_2.x86_64 (x86_64)
Thu Aug 17 09:37:16 PM CST 2023
make -C "/lib/modules/5.14.0-284.25.1.el9_2.x86_64/build" M="/var/lib/dkms/gasket/0.0.git.250.9fef422e/build" modules
make[1]: warning: jobserver unavailable: using -j1.  Add '+' to parent make rule.
make[1]: Entering directory '/usr/src/kernels/5.14.0-284.25.1.el9_2.x86_64'
  CC [M]  /var/lib/dkms/gasket/0.0.git.250.9fef422e/build/gasket_core.o
  CC [M]  /var/lib/dkms/gasket/0.0.git.250.9fef422e/build/gasket_ioctl.o
  CC [M]  /var/lib/dkms/gasket/0.0.git.250.9fef422e/build/gasket_interrupt.o
  CC [M]  /var/lib/dkms/gasket/0.0.git.250.9fef422e/build/gasket_page_table.o
  CC [M]  /var/lib/dkms/gasket/0.0.git.250.9fef422e/build/gasket_sysfs.o
  LD [M]  /var/lib/dkms/gasket/0.0.git.250.9fef422e/build/gasket.o
  CC [M]  /var/lib/dkms/gasket/0.0.git.250.9fef422e/build/apex_driver.o
  LD [M]  /var/lib/dkms/gasket/0.0.git.250.9fef422e/build/apex.o
  MODPOST /var/lib/dkms/gasket/0.0.git.250.9fef422e/build/Module.symvers
ERROR: modpost: module gasket uses symbol dma_buf_detach from namespace DMA_BUF, but does not import it.
ERROR: modpost: module gasket uses symbol dma_buf_put from namespace DMA_BUF, but does not import it.
ERROR: modpost: module gasket uses symbol dma_buf_get from namespace DMA_BUF, but does not import it.
ERROR: modpost: module gasket uses symbol dma_buf_unmap_attachment from namespace DMA_BUF, but does not import it.
ERROR: modpost: module gasket uses symbol dma_buf_map_attachment from namespace DMA_BUF, but does not import it.
ERROR: modpost: module gasket uses symbol dma_buf_attach from namespace DMA_BUF, but does not import it.
make[2]: *** [scripts/Makefile.modpost:134: /var/lib/dkms/gasket/0.0.git.250.9fef422e/build/Module.symvers] Error 1
make[2]: *** Deleting file '/var/lib/dkms/gasket/0.0.git.250.9fef422e/build/Module.symvers'
make[1]: *** [Makefile:1838: modules] Error 2
make[1]: Leaving directory '/usr/src/kernels/5.14.0-284.25.1.el9_2.x86_64'
make: *** [Makefile:15: all] Error 2

It seems like it's the same issue as #3. I can see that it's already patched in #6, but that patch only imports DMA_BUF on kernel version 5.16.0 or higher. I manually deleted the conditional checks and it compiled successfully.

I guess what's happening here is that a Redhat backport causes its "5.14.0" kernels to behave similarly to 5.16.0+ kernels. So my question is, is there a better way to check whether importing DMA_BUF namespace is necessary than a hard-coded version comparison? Sorry for not being of much help; I'm not a C developer.

robertzaage commented 11 months ago

Hmm, kernel backports are a real bummer...

How about this (untested)?

#if __has_include(<linux/dma-buf.h>)
    MODULE_IMPORT_NS(DMA_BUF);
#endif
cyqsimon commented 11 months ago

Yep that does it! Verified to build on RHEL9 with your patch.

robertzaage commented 11 months ago

Okay, thank you for verifying! I'll create a PR for this, hoping that this method doesn't have any drawbacks. 😄