Skip to content

Instantly share code, notes, and snippets.

@foundObjects
Created August 27, 2021 00:51
Show Gist options
  • Save foundObjects/f40f2d96f9c99edbce66eae9a2f5a392 to your computer and use it in GitHub Desktop.
Save foundObjects/f40f2d96f9c99edbce66eae9a2f5a392 to your computer and use it in GitHub Desktop.
dkms - check for clang compiler
--- a/usr/bin/dkms 2020-12-11 09:54:28.000000000 +0100
+++ b/usr/bin/dkms 2021-07-13 11:51:05.517800608 +0200
@@ -1284,6 +1284,17 @@
cd - >/dev/null
}
+check_clang()
+{
+ set_kernel_source_dir "$kernelver"
+ if [[ ! -z $(strings ${kernel_source_dir}/vmlinux | grep clang) ]] ; then
+ _clangopts="CC=clang LD=ld.lld AR=llvm-ar NM=llvm-nm RANLIB=llvm-ranlib STRIP=llvm-strip OBJCOPY=llvm-objcopy"
+ echo "Using llvm tools..."
+ else
+ _clangopts=""
+ fi
+}
+
# Get ready to build a module that has been registered with DKMS.
prepare_build()
{
@@ -1293,6 +1304,9 @@
set_kernel_source_dir "$kernelver"
local base_dir="$dkms_tree/$module/$module_version/$kernelver/$arch"
+ # check if the kernel was compiled with clang
+ check_clang
+
# Check that the right arguments were passed
check_module_args build
@@ -1350,7 +1364,7 @@
invoke_command "$clean" "cleaning build area" background
echo $"DKMS make.log for $module-$module_version for kernel $kernelver ($arch)" >> "$dkms_tree/$module/$module_version/build/make.log"
date >> "$dkms_tree/$module/$module_version/build/make.log"
- local the_make_command="${make_command/#make/make -j$parallel_jobs KERNELRELEASE=$kernelver}"
+ local the_make_command="${make_command/#make/make -j$parallel_jobs KERNELRELEASE=$kernelver $_clangopts}"
invoke_command "{ $the_make_command; } >> $dkms_tree/$module/$module_version/build/make.log 2>&1" "$the_make_command" background || \
report_build_problem 10 $"Bad return status for module build on kernel: $kernelver ($arch)" \
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment