Git Product home page Git Product logo

Comments (3)

danudey avatar danudey commented on August 10, 2024

In order to successfully compile a kernel module via DKMS, you need to provide the module build with the same LLVM-related environment variables you used to build the kernel, and as far as I can tell this doesn't happen with DKMS (i.e. there's no way for DKMS to know what those parameters were).

On Ubuntu I had to modify the dkms file in /usr/src/nvidia-<ver>/dkms.conf to add those parameters; for example, to go from this:

MAKE[0]="'make' -j__JOBS NV_EXCLUDE_BUILD_MODULES='__EXCLUDE_MODULES' KERNEL_UNAME=${kernelver} modules"

to this:

MAKE[0]="LLVM=1 'make' -j__JOBS NV_EXCLUDE_BUILD_MODULES='__EXCLUDE_MODULES' KERNEL_UNAME=${kernelver} modules"

I would assume that on Arch you would have to do a similar thing.

(Ubuntu actually uses a different dkms.conf file which needs more work to fix.)

from dkms.

ltsdw avatar ltsdw commented on August 10, 2024

While setting the envar on the dkms.conf file would work, I have other kernels which weren't compiled using clang.
Like, the dkms script can detect where you compiled your kernel using clang or not:

    # Check if clang was used to compile or lld was used to link the kernel.
    if [[ -e $kernel_source_dir/vmlinux ]]; then
      if  readelf -p .comment $kernel_source_dir/vmlinux | grep -q clang; then
        make_command="${make_command} CC=clang"
      fi
      if  readelf -p .comment $kernel_source_dir/vmlinux | grep -q LLD; then
        make_command="${make_command} LD=ld.lld"
      fi
    elif [[ -e "${kernel_config}" ]]; then
      if grep -q CONFIG_CC_IS_CLANG=y "${kernel_config}"; then
        make_command="${make_command} CC=clang"
      fi
      if grep -q CONFIG_LD_IS_LLD=y "${kernel_config}"; then
        make_command="${make_command} LD=ld.lld"
      fi
    fi

As such without ThinLTO I don't even have to worry about setting envars for clang ou llvm-strip, it compiles normally.

from dkms.

ltsdw avatar ltsdw commented on August 10, 2024

This one works for me, although some of the envars may not be needed.

--- a/dkms	2024-05-18 11:52:29.624897615 -0300
+++ b/dkms	2024-05-18 11:52:17.387875553 -0300
@@ -589,17 +589,17 @@
     # Check if clang was used to compile or lld was used to link the kernel.
     if [[ -e $kernel_source_dir/vmlinux ]]; then
       if  readelf -p .comment $kernel_source_dir/vmlinux | grep -q clang; then
-        make_command="${make_command} CC=clang"
+        make_command="${make_command} CC=clang CXX=clang++ AR=llvm-ar OBJCOPY=llvm-objcopy"
       fi
       if  readelf -p .comment $kernel_source_dir/vmlinux | grep -q LLD; then
-        make_command="${make_command} LD=ld.lld"
+        make_command="${make_command} LD=ld.lld AR=llvm-ar OBJCOPY=llvm-objcopy"
       fi
     elif [[ -e "${kernel_config}" ]]; then
       if grep -q CONFIG_CC_IS_CLANG=y "${kernel_config}"; then
-        make_command="${make_command} CC=clang"
+        make_command="${make_command} CC=clang CXX=clang++ AR=llvm-ar OBJCOPY=llvm-objcopy"
       fi
       if grep -q CONFIG_LD_IS_LLD=y "${kernel_config}"; then
-        make_command="${make_command} LD=ld.lld"
+        make_command="${make_command} LD=ld.lld AR=llvm-ar OBJCOPY=llvm-objcopy"
       fi
     fi
 
@@ -1112,7 +1112,11 @@
         local built_module="$the_module$module_uncompressed_suffix"
         local compressed_module="$the_module$module_suffix"
 
-        [[ ${strip[$count]} != no ]] && strip -g "$built_module"
+        if [[ ${strip[$count]} != no ]] && [[ ${CC} == "clang" ]]; then
+            llvm-strip -g "$built_module"
+        elif [[ ${strip[$count]} != no ]]; then
+            strip -g "$built_module"
+        fi
 
         if (( do_signing )); then
             echo "Signing module $built_module"

from dkms.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.