510.68.02 Driver breaks installation for newer Linux kernel 5.17.8 on Ubuntu 20.04

Driver info, this driver installed from https://launchpad.net/~graphics-drivers/+archive/ubuntu/ppa

(base) ➜ build nvidia-smi

Mon May 16 17:48:23 2022       
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 510.68.02    Driver Version: 510.68.02    CUDA Version: 11.6     |
|-------------------------------+----------------------+----------------------+

System version

lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 20.04.4 LTS
Release:        20.04
Codename:       focal

Installation log

Selecting previously unselected package linux-headers-5.17.8-051708.
(Reading database ... 392159 files and directories currently installed.)
Preparing to unpack linux-headers-5.17.8-051708_5.17.8-051708.202205151940_all.deb ...
Unpacking linux-headers-5.17.8-051708 (5.17.8-051708.202205151940) ...
Selecting previously unselected package linux-headers-5.17.8-051708-generic.
Preparing to unpack linux-headers-5.17.8-051708-generic_5.17.8-051708.202205151940_amd64.deb ...
Unpacking linux-headers-5.17.8-051708-generic (5.17.8-051708.202205151940) ...
Selecting previously unselected package linux-image-unsigned-5.17.8-051708-generic.
Preparing to unpack linux-image-unsigned-5.17.8-051708-generic_5.17.8-051708.202205151940_amd64.deb ...
Unpacking linux-image-unsigned-5.17.8-051708-generic (5.17.8-051708.202205151940) ...
Selecting previously unselected package linux-modules-5.17.8-051708-generic.
Preparing to unpack linux-modules-5.17.8-051708-generic_5.17.8-051708.202205151940_amd64.deb ...
Unpacking linux-modules-5.17.8-051708-generic (5.17.8-051708.202205151940) ...
Selecting previously unselected package linux-modules-iwlwifi-5.17.8-051708-generic.
Preparing to unpack linux-modules-iwlwifi-5.17.8-051708-generic_5.17.8-051708.202205151940_amd64.deb ...
Unpacking linux-modules-iwlwifi-5.17.8-051708-generic (5.17.8-051708.202205151940) ...
Setting up linux-headers-5.17.8-051708 (5.17.8-051708.202205151940) ...
Setting up linux-headers-5.17.8-051708-generic (5.17.8-051708.202205151940) ...
/etc/kernel/header_postinst.d/dkms:
 * dkms: running auto installation service for kernel 5.17.8-051708-generic

Kernel preparation unnecessary for this kernel.  Skipping...
applying patch disable_fstack-clash-protection_fcf-protection.patch...patching file Kbuild
Hunk #1 succeeded at 82 (offset 11 lines).


Building module:
cleaning build area...
unset ARCH; [ ! -h /usr/bin/cc ] && export CC=/usr/bin/gcc; env NV_VERBOSE=1 'make' -j16 NV_EXCLUDE_BUILD_MODULES='' KERNEL_UNAME=5.17.8-051708-generic IGNORE_XEN_PRESENCE=1 IGNORE_CC_MISMATCH=1 SYSSRC=/lib/modules/5.17.8-051708-generic/build LD=/usr/bin/ld.bfd modules....(bad exit status: 2)
ERROR (dkms apport): kernel package linux-headers-5.17.8-051708-generic is not supported
Error! Bad return status for module build on kernel: 5.17.8-051708-generic (x86_64)
Consult /var/lib/dkms/nvidia/510.68.02/build/make.log for more information.
   ...done.
Setting up linux-image-unsigned-5.17.8-051708-generic (5.17.8-051708.202205151940) ...
I: /boot/vmlinuz.old is now a symlink to vmlinuz-5.16.20-051620-generic
I: /boot/initrd.img.old is now a symlink to initrd.img-5.16.20-051620-generic
I: /boot/vmlinuz is now a symlink to vmlinuz-5.17.8-051708-generic
I: /boot/initrd.img is now a symlink to initrd.img-5.17.8-051708-generic
Setting up linux-modules-5.17.8-051708-generic (5.17.8-051708.202205151940) ...
Setting up linux-modules-iwlwifi-5.17.8-051708-generic (5.17.8-051708.202205151940) ...
Processing triggers for linux-image-unsigned-5.17.8-051708-generic (5.17.8-051708.202205151940) ...
/etc/kernel/postinst.d/dkms:
 * dkms: running auto installation service for kernel 5.17.8-051708-generic

Kernel preparation unnecessary for this kernel.  Skipping...
applying patch disable_fstack-clash-protection_fcf-protection.patch...patching file Kbuild
Hunk #1 succeeded at 82 (offset 11 lines).


Building module:
cleaning build area...
unset ARCH; [ ! -h /usr/bin/cc ] && export CC=/usr/bin/gcc; env NV_VERBOSE=1 'make' -j16 NV_EXCLUDE_BUILD_MODULES='' KERNEL_UNAME=5.17.8-051708-generic IGNORE_XEN_PRESENCE=1 IGNORE_CC_MISMATCH=1 SYSSRC=/lib/modules/5.17.8-051708-generic/build LD=/usr/bin/ld.bfd modules....(bad exit status: 2)
ERROR (dkms apport): kernel package linux-headers-5.17.8-051708-generic is not supported
Error! Bad return status for module build on kernel: 5.17.8-051708-generic (x86_64)
Consult /var/lib/dkms/nvidia/510.68.02/build/make.log for more information.
   ...done.
/etc/kernel/postinst.d/initramfs-tools:
update-initramfs: Generating /boot/initrd.img-5.17.8-051708-generic

The log from the /var/lib/dkms/nvidia/510.68.02/build/, the main issue is related to a compiler flag, i am not very familiar with the Linux kernel development, just want to do some preparation for upgrading to the 5.18 kernel once its released.

I did some research on this issue, but almost the result refers to that error during nvidia-dkms rebuild kernel model and passed a wrong argument to the compiler. I have also tried different compiler versions but neither works.

./make.log:cc: error: unrecognized command-line option ‘-mharden-sls=all’

./make.log: cc -Wp,-MMD,/var/lib/dkms/nvidia/510.68.02/build/nvidia/.nv.o.d -nostdinc -I./arch/x86/include -I./arch

/x86/include/generated -I./include -I./arch/x86/include/uapi -I./arch/x86/include/generated/uapi -I./include/uapi -I

./include/generated/uapi -include ./include/linux/compiler-version.h -include ./include/linux/kconfig.h -include ./in

clude/linux/compiler_types.h -D__KERNEL__ -Wall -Wundef -Werror=strict-prototypes -Wno-trigraphs -fno-strict-aliasing

-fno-common -fshort-wchar -fno-PIE -Werror=implicit-function-declaration -Werror=implicit-int -Werror=return-type -W

no-format-security -std=gnu89 -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -mno-avx -fcf-protection=none -m64 -falign-jumps

=1 -falign-loops=1 -mno-80387 -mno-fp-ret-in-387 -mpreferred-stack-boundary=3 -mskip-rax-setup -mtune=generic -mno-re

d-zone -mcmodel=kernel -Wno-sign-compare -fno-asynchronous-unwind-tables -mindirect-branch=thunk-extern -mindirect-br

anch-register -fno-jump-tables -mharden-sls=all -fno-delete-null-pointer-checks -O2 -Wframe-larger-than=1024 -fstack-

protector-strong -Wimplicit-fallthrough=5 -Wno-main -fno-omit-frame-pointer -fno-optimize-sibling-calls -pg -mrecord-

mcount -Wdeclaration-after-statement -Wvla -Wno-pointer-sign -Wno-array-bounds -Wno-maybe-uninitialized -Wno-alloc-si

ze-larger-than -fno-strict-overflow -fno-stack-check -fconserve-stack -Werror=date-time -g -I/var/lib/dkms/nvidia/510

.68.02/build/common/inc -I/var/lib/dkms/nvidia/510.68.02/build -Wall -MD -Wno-cast-qual -Wno-error -Wno-format-extra-

args -D__KERNEL__ -DMODULE -DNVRM -DNV_VERSION_STRING=\"510.68.02\" -Wno-unused-function -Wuninitialized -fno-strict-

aliasing -mno-red-zone -mcmodel=kernel -DNV_UVM_ENABLE -DNV_SPECTRE_V2=0 -DNV_KERNEL_INTERFACE_LAYER -fno-stack-clash

-protection -fcf-protection=none -I/var/lib/dkms/nvidia/510.68.02/build/nvidia -DNVIDIA_UNDEF_LEGACY_BIT_MACROS -UDEB

UG -U_DEBUG -DNDEBUG -fsanitize=bounds -fsanitize=shift -fsanitize=bool -fsanitize=enum -DMODULE -DKBUILD_BASENAME

='"nv"' -DKBUILD_MODNAME='"nvidia"' -D__KBUILD_MODNAME=kmod_nvidia -c -o /var/lib/dkms/nvidia/510.68.02/build/nvidia/

nv.o /var/lib/dkms/nvidia/510.68.02/build/nvidia/nv.c ; ./tools/objtool/objtool check --module --retpoline --ua

ccess --sls /var/lib/dkms/nvidia/510.68.02/build/nvidia/nv.o

./make.log: cc -Wp,-MMD,/var/lib/dkms/nvidia/510.68.02/build/nvidia/.nv-pci.o.d -nostdinc -I./arch/x86/include -I./

arch/x86/include/generated -I./include -I./arch/x86/include/uapi -I./arch/x86/include/generated/uapi -I./include/uap

i -I./include/generated/uapi -include ./include/linux/compiler-version.h -include ./include/linux/kconfig.h -include

./include/linux/compiler_types.h -D__KERNEL__ -Wall -Wundef -Werror=strict-prototypes -Wno-trigraphs -fno-strict-alia

sing -fno-common -fshort-wchar -fno-PIE -Werror=implicit-function-declaration -Werror=implicit-int -Werror=return-typ

e -Wno-format-security -std=gnu89 -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -mno-avx -fcf-protection=none -m64 -falign-j

umps=1 -falign-loops=1 -mno-80387 -mno-fp-ret-in-387 -mpreferred-stack-boundary=3 -mskip-rax-setup -mtune=generic -mn

o-red-zone -mcmodel=kernel -Wno-sign-compare -fno-asynchronous-unwind-tables -mindirect-branch=thunk-extern -mindirec

t-branch-register -fno-jump-tables -mharden-sls=all -fno-delete-null-pointer-checks -O2 -Wframe-larger-than=1024 -fst

ack-protector-strong -Wimplicit-fallthrough=5 -Wno-main -fno-omit-frame-pointer -fno-optimize-sibling-calls -pg -mrec

ord-mcount -Wdeclaration-after-statement -Wvla -Wno-pointer-sign -Wno-array-bounds -Wno-maybe-uninitialized -Wno-allo

c-size-larger-than -fno-strict-overflow -fno-stack-check -fconserve-stack -Werror=date-time -g -I/var/lib/dkms/nvidia

/510.68.02/build/common/inc -I/var/lib/dkms/nvidia/510.68.02/build -Wall -MD -Wno-cast-qual -Wno-error -Wno-format-ex

tra-args -D__KERNEL__ -DMODULE -DNVRM -DNV_VERSION_STRING=\"510.68.02\" -Wno-unused-function -Wuninitialized -fno-str

ict-aliasing -mno-red-zone -mcmodel=kernel -DNV_UVM_ENABLE -DNV_SPECTRE_V2=0 -DNV_KERNEL_INTERFACE_LAYER -fno-stack-c

lash-protection -fcf-protection=none -I/var/lib/dkms/nvidia/510.68.02/build/nvidia -DNVIDIA_UNDEF_LEGACY_BIT_MACROS -

UDEBUG -U_DEBUG -DNDEBUG -fsanitize=bounds -fsanitize=shift -fsanitize=bool -fsanitize=enum -DMODULE -DKBUILD_BASE

NAME='"nv_pci"' -DKBUILD_MODNAME='"nvidia"' -D__KBUILD_MODNAME=kmod_nvidia -c -o /var/lib/dkms/nvidia/510.68.02/build

/nvidia/nv-pci.o /var/lib/dkms/nvidia/510.68.02/build/nvidia/nv-pci.c ; ./tools/objtool/objtool check --module -

-retpoline --uaccess --sls /var/lib/dkms/nvidia/510.68.02/build/nvidia/nv-pci.o

./make.log: cc -Wp,-MMD,/var/lib/dkms/nvidia/510.68.02/build/nvidia/.nv-acpi.o.d -nostdinc -I./arch/x86/include -I.

/arch/x86/include/generated -I./include -I./arch/x86/include/uapi -I./arch/x86/include/generated/uapi -I./include/ua

pi -I./include/generated/uapi -include ./include/linux/compiler-version.h -include ./include/linux/kconfig.h -include

./include/linux/compiler_types.h -D__KERNEL__ -Wall -Wundef -Werror=strict-prototypes -Wno-trigraphs -fno-strict-ali

asing -fno-common -fshort-wchar -fno-PIE -Werror=implicit-function-declaration -Werror=implicit-int -Werror=return-ty

pe -Wno-format-security -std=gnu89 -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -mno-avx -fcf-protection=none -m64 -falign-

jumps=1 -falign-loops=1 -mno-80387 -mno-fp-ret-in-387 -mpreferred-stack-boundary=3 -mskip-rax-setup -mtune=generic -m

no-red-zone -mcmodel=kernel -Wno-sign-compare -fno-asynchronous-unwind-tables -mindirect-branch=thunk-extern -mindire

ct-branch-register -fno-jump-tables -mharden-sls=all -fno-delete-null-pointer-checks -O2 -Wframe-larger-than=1024 -fs

tack-protector-strong -Wimplicit-fallthrough=5 -Wno-main -fno-omit-frame-pointer -fno-optimize-sibling-calls -pg -mre

cord-mcount -Wdeclaration-after-statement -Wvla -Wno-pointer-sign -Wno-array-bounds -Wno-maybe-uninitialized -Wno-all

oc-size-larger-than -fno-strict-overflow -fno-stack-check -fconserve-stack -Werror=date-time -g -I/var/lib/dkms/nvidi

a/510.68.02/build/common/inc -I/var/lib/dkms/nvidia/510.68.02/build -Wall -MD -Wno-cast-qual -Wno-error -Wno-format-e

xtra-args -D__KERNEL__ -DMODULE -DNVRM -DNV_VERSION_STRING=\"510.68.02\" -Wno-unused-function -Wuninitialized -fno-st

rict-aliasing -mno-red-zone -mcmodel=kernel -DNV_UVM_ENABLE -DNV_SPECTRE_V2=0 -DNV_KERNEL_INTERFACE_LAYER -fno-stack-

clash-protection -fcf-protection=none -I/var/lib/dkms/nvidia/510.68.02/build/nvidia -DNVIDIA_UNDEF_LEGACY_BIT_MACROS

-UDEBUG -U_DEBUG -DNDEBUG -fsanitize=bounds -fsanitize=shift -fsanitize=bool -fsanitize=enum -DMODULE -DKBUILD_BAS

ENAME='"nv_acpi"' -DKBUILD_MODNAME='"nvidia"' -D__KBUILD_MODNAME=kmod_nvidia -c -o /var/lib/dkms/nvidia/510.68.02/bui

ld/nvidia/nv-acpi.o /var/lib/dkms/nvidia/510.68.02/build/nvidia/nv-acpi.c ; ./tools/objtool/objtool check --module

--retpoline --uaccess --sls /var/lib/dkms/nvidia/510.68.02/build/nvidia/nv-acpi.o

./make.log:cc: error: unrecognized command-line option ‘-mharden-sls=all’

./make.log: cc -Wp,-MMD,/var/lib/dkms/nvidia/510.68.02/build/nvidia/.nv-cray.o.d -nostdinc -I./arch/x86/include -I.

/arch/x86/include/generated -I./include -I./arch/x86/include/uapi -I./arch/x86/include/generated/uapi -I./include/ua

pi -I./include/generated/uapi -include ./include/linux/compiler-version.h -include ./include/linux/kconfig.h -include

./include/linux/compiler_types.h -D__KERNEL__ -Wall -Wundef -Werror=strict-prototypes -Wno-trigraphs -fno-strict-ali

asing -fno-common -fshort-wchar -fno-PIE -Werror=implicit-function-declaration -Werror=implicit-int -Werror=return-ty

pe -Wno-format-security -std=gnu89 -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -mno-avx -fcf-protection=none -m64 -falign-

jumps=1 -falign-loops=1 -mno-80387 -mno-fp-ret-in-387 -mpreferred-stack-boundary=3 -mskip-rax-setup -mtune=generic -m

no-red-zone -mcmodel=kernel -Wno-sign-compare -fno-asynchronous-unwind-tables -mindirect-branch=thunk-extern -mindire

ct-branch-register -fno-jump-tables -mharden-sls=all -fno-delete-null-pointer-checks -O2 -Wframe-larger-than=1024 -fs

tack-protector-strong -Wimplicit-fallthrough=5 -Wno-main -fno-omit-frame-pointer -fno-optimize-sibling-calls -pg -mre

cord-mcount -Wdeclaration-after-statement -Wvla -Wno-pointer-sign -Wno-array-bounds -Wno-maybe-uninitialized -Wno-all

oc-size-larger-than -fno-strict-overflow -fno-stack-check -fconserve-stack -Werror=date-time -g -I/var/lib/dkms/nvidi

a/510.68.02/build/common/inc -I/var/lib/dkms/nvidia/510.68.02/build -Wall -MD -Wno-cast-qual -Wno-error -Wno-format-e

xtra-args -D__KERNEL__ -DMODULE -DNVRM -DNV_VERSION_STRING=\"510.68.02\" -Wno-unused-function -Wuninitialized -fno-st

rict-aliasing -mno-red-zone -mcmodel=kernel -DNV_UVM_ENABLE -DNV_SPECTRE_V2=0 -DNV_KERNEL_INTERFACE_LAYER -fno-stack-

clash-protection -fcf-protection=none -I/var/lib/dkms/nvidia/510.68.02/build/nvidia -DNVIDIA_UNDEF_LEGACY_BIT_MACROS

-UDEBUG -U_DEBUG -DNDEBUG -fsanitize=bounds -fsanitize=shift -fsanitize=bool -fsanitize=enum -DMODULE -DKBUILD_BAS

ENAME='"nv_cray"' -DKBUILD_MODNAME='"nvidia"' -D__KBUILD_MODNAME=kmod_nvidia -c -o /var/lib/dkms/nvidia/510.68.02/bui

ld/nvidia/nv-cray.o /var/lib/dkms/nvidia/510.68.02/build/nvidia/nv-cray.c ; ./tools/objtool/objtool check --module

--retpoline --uaccess --sls /var/lib/dkms/nvidia/510.68.02/build/nvidia/nv-cray.o

./make.log:cc: error: unrecognized command-line option ‘-mharden-sls=all’

./make.log:cc: error: unrecognized command-line option ‘-mharden-sls=all’

./make.log:cc: error: unrecognized command-line option ‘-mharden-sls=all’

You installed a mainline kernel that was built for 22.04 on 20.04. The header files are incompatible so the driver doesn’t build.
If you want the latest driver on 20.04, please use the liquorix ppa. In general, the nvidia driver is compatible with kernel 5.17.

I’m getting the same error on Pop_OS! 22.04, trying to build the kernel module for 5.17.5.

cc: error: unrecognized command-line option ‘-mharden-sls=all’

I had upgraded to 22.04 from 22.10, and gcc-11 wasn’t installed / default. Updating to gcc11 fixed this error, for me.

1 Like