Error! Bad return status for module build on kernel

While installing the nvidia-460 driver in Ubuntu 18.04, I get the following error.

Error! Bad return status for module build on kernel: 5.4.0-62-generic (x86_64)
Consult /var/lib/dkms/nvidia/460.32.03/build/make.log for more information

I’ve attached that file. It basically says that “the kernel configuration is invalid”.

make.log (25.6 KB)

The warning about the kernel config being invalid is always displayed, just ignore.
The build errors look like you’ve set the wrong system compiler. Please post the outputs of
cat /proc/version
gcc -v
cc -v

1 Like

Linux version 5.4.0-62-generic (buildd@lcy01-amd64-028) (gcc version 7.5.0 (Ubuntu 7.5.0-3ubuntu1~18.04)) #70~18.04.1-Ubuntu SMP Tue Jan 12 17:18:00 UTC 2021

Using built-in specs.
COLLECT_GCC=/usr/bin/gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/8/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: …/src/configure -v --with-pkgversion=‘Ubuntu 8.4.0-1ubuntu1~18.04’ --with-bugurl=file:///usr/share/doc/gcc-8/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++ --prefix=/usr --with-gcc-major-version-only --program-suffix=-8 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-plugin --enable-default-pie --with-system-zlib --with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 8.4.0 (Ubuntu 8.4.0-1ubuntu1~18.04)

clang version 6.0.0-1ubuntu2 (tags/RELEASE_600/final)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
Found candidate GCC installation: /usr/bin/…/lib/gcc/i686-linux-gnu/8
Found candidate GCC installation: /usr/bin/…/lib/gcc/x86_64-linux-gnu/6
Found candidate GCC installation: /usr/bin/…/lib/gcc/x86_64-linux-gnu/6.5.0
Found candidate GCC installation: /usr/bin/…/lib/gcc/x86_64-linux-gnu/7
Found candidate GCC installation: /usr/bin/…/lib/gcc/x86_64-linux-gnu/7.5.0
Found candidate GCC installation: /usr/bin/…/lib/gcc/x86_64-linux-gnu/8
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/8
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/6
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/6.5.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7.5.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/8
Selected GCC installation: /usr/bin/…/lib/gcc/x86_64-linux-gnu/8
Candidate multilib: .;@m64
Selected multilib: .;@m64

gcc 7.5.0 is needed to compile the kernel module. but you set the gcc to v 8.4.0 and the system compiler cc to clang/llvm. Please set both to the correct gcc version using update-alternatives.

1 Like

I did the following - not sure if it’s correct. I’m still getting an error for the last line.

sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-7 50
sudo update-alternatives --install /usr/bin/cc cc /usr/bin/gcc-7 50
sudo update-alternatives --remove-all llvm
sudo update-alternatives --remove-all clang
sudo update-alternatives --install /usr/lib/llvm llvm /usr/lib/llvm-5.0 20 --slave /usr/bin/llvm-config llvm-config /usr/bin/llvm-config-5.0
sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-5.0 20 --slave /usr/bin/clang++ clang++ /usr/bin/clang+±5.0
sudo apt-get autoremove --purge nvidia-driver-*
sudo apt-get autoremove --purge nvidia-*
sudo apt install --reinstall linux-headers-$(uname -r)
sudo apt install nvidia-driver-460

cc -v gives:

[…] Selected GCC installation: /usr/bin/…/lib/gcc/x86_64-linux-gnu/7.5.0

gcc -v gives:

[…] gcc version 7.5.0 (Ubuntu 7.5.0-3ubuntu1~18.04)

Please delete

reboot, then run
sudo dkms --force install nvidia/460.32.03
and post the output of
dkms status

1 Like

dkms status gives:

nvidia, 460.32.03: added

However, running sudo dkms --force install nvidia/460.32.03 gives an error:

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

Building module:
cleaning build area…
unset ARCH; [ ! -h /usr/bin/cc ] && export CC=/usr/bin/gcc; env NV_VERBOSE=1 ‘make’ -j8 NV_EXCLUDE_BUILD_MODULES=’’ KERNEL_UNAME=5.4.0-62-generic IGNORE_XEN_PRESENCE=1 IGNORE_CC_MISMATCH=1 SYSSRC=/lib/modules/5.4.0-62-generic/build LD=/usr/bin/ld.bfd modules…(bad exit status: 2)
Error! Bad return status for module build on kernel: 5.4.0-62-generic (x86_64)
Consult /var/lib/dkms/nvidia/460.32.03/build/make.log for more information.make.log (25.4 KB)

It’s still being built with clang/llvm, so you’ll have to make sure cc is set to gcc.

1 Like

In the end, I removed clang from the system with apt and then sudo dkms --force install nvidia/460.32.03. The driver is working again. Thanks for the help!