clang-dkms.patch 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. --- dkms.in 2022-07-15 03:42:14.000000000 -0300
  2. +++ dkms.in 2022-09-10 22:26:16.103277917 -0300
  3. @@ -926,6 +926,17 @@
  4. esac
  5. }
  6. +check_clang()
  7. +{
  8. + set_kernel_source_dir "$kernelver"
  9. + if [[ ! -z $(strings ${kernel_source_dir}/vmlinux | grep clang) ]] ; then
  10. + _clangopts="CC=clang LD=ld.lld AR=llvm-ar NM=llvm-nm RANLIB=llvm-ranlib STRIP=llvm-strip OBJCOPY=llvm-objcopy"
  11. + echo "Using llvm tools..."
  12. + else
  13. + _clangopts=""
  14. + fi
  15. +}
  16. +
  17. # Get ready to build a module that has been registered with DKMS.
  18. prepare_build()
  19. {
  20. @@ -937,6 +948,9 @@
  21. local -r base_dir="$dkms_tree/$module/$module_version/$kernelver/$arch"
  22. local -r build_dir="$dkms_tree/$module/$module_version/build"
  23. local -r source_dir="$dkms_tree/$module/$module_version/source"
  24. +
  25. + # check if the kernel was compiled with clang
  26. + check_clang
  27. # Check that the module has not already been built for this kernel
  28. [[ -d $base_dir ]] && die 3 \
  29. @@ -994,7 +1008,7 @@
  30. invoke_command "$clean" "Cleaning build area" background
  31. echo $"DKMS make.log for $module-$module_version for kernel $kernelver ($arch)" >> "$build_log"
  32. date >> "$build_log"
  33. - local the_make_command="${make_command/#make/make -j$parallel_jobs KERNELRELEASE=$kernelver}"
  34. + local the_make_command="${make_command/#make/make -j$parallel_jobs KERNELRELEASE=$kernelver $_clangopts}"
  35. invoke_command "{ $the_make_command; } >> $build_log 2>&1" "$the_make_command" background || \
  36. report_build_problem 10 $"Bad return status for module build on kernel: $kernelver ($arch)" \