aboutsummarylogtreecommitdiffstats
path: root/patch-dkms-for-llvm-clang-support.patch
blob: 02ae95d93b06d7f44c12129dc6222005b41bcdb9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
--- a/dkms	2021-11-16 05:26:18.292805661 -0800
+++ b/dkms	2021-11-16 05:26:23.014733213 -0800
@@ -571,6 +571,22 @@
         make_command="${MAKE[$index]}"
     done
 
+    ## https://github.com/dell/dkms/issues/124#issuecomment-960709722
+
+    # overkill LLVM tools specification:
+    clangopts=( "CC=clang" "LD=ld.lld" "AR=llvm-ar" "NM=llvm-nm" \
+                "RANLIB=llvm-ranlib" "STRIP=llvm-strip" "OBJCOPY=llvm-objcopy" \
+                "OBJDUMP=llvm-objdump" "READOBJ=llvm-readobj LLVM=1 LLVM_IAS=1")
+
+    if [[ -e $kernel_source_dir/vmlinux ]]; then
+      if readelf -p .comment $kernel_source_dir/vmlinux | grep -q clang; then
+        make_command="${clangopts[@]} ${make_command}"
+        #echo -n " (using llvm tools from $(which clang))" >&2
+      fi
+    fi
+
+    # see also: https://git.io/JXzyo
+
     # Use the generic make and make clean commands if not specified
     [[ ! $make_command ]] && make_command="make -C $kernel_source_dir M=$dkms_tree/$module/$module_version/build"
     [[ ! $clean ]] && clean="make -C $kernel_source_dir M=$dkms_tree/$module/$module_version/build clean"