Comments (3)
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.
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.
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)
- Kernel match for BUILT_MODULE_NAME HOT 9
- Introduce a `build $module for all kernels` functionality HOT 1
- Reintroduce support for `dkms add/build/install m/v --all` HOT 1
- A typo in the readme file
- Ubuntu 22.04 VM broke HOT 6
- marking built/installed modules as rebuild-needed
- parameter validation
- 3.0.13 release isn't tagged as latest on GitHub HOT 1
- OBSOLETE_BY does not prevent building HOT 1
- Retrospective from the recent XZ vuln HOT 1
- DOS-style line endings in dkms.conf break dkms in unpredictable ways HOT 1
- Stop handling dkms.conf as a bash/shell script HOT 8
- Leftover files after zfs build HOT 2
- Keep the Module.symvers file along with the *.ko HOT 2
- In the loop, why is it a read-only variable? HOT 4
- nvidia-open-dkms: Strip assertion failed (ThinLTO compiled kernel) - Module succesfully compiled but can not boot HOT 2
- automate running "`sudo mokutil --import /var/lib/dkms/mok.pub`" HOT 6
- Ship `kernel-install` snippet to `/usr/` instead of `/etc/` HOT 2
- Supporting non-DKMS modules using a vendors external tools
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dkms.