Skip to content

Commit

Permalink
dkms: fix building against clang and thin/full lto
Browse files Browse the repository at this point in the history
Right now there's some issues when trying to compile open-gpu-kernel-modules against a kernel compiled using clang+Thin/Full LTO.
Also the script will pick the wrong version of the strip command, is also necessary to set the OBJCOPY environment variable.

Fixes #416.
  • Loading branch information
ltsdw authored and scaronni committed Oct 23, 2024
1 parent b29a848 commit 5aa0144
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions dkms.in
Original file line number Diff line number Diff line change
Expand Up @@ -657,17 +657,11 @@ read_conf()
# 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"
make_command="${make_command} LLVM=1"
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"
make_command="${make_command} LLVM=1"
fi
fi

Expand Down Expand Up @@ -1206,7 +1200,11 @@ actual_build()
built_module="$the_module$module_uncompressed_suffix"
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"
Expand Down

0 comments on commit 5aa0144

Please sign in to comment.