dkms 失败,因为 gcc 版本比用于编译内核的版本新

Wan*_*gic 6 upgrade package-management dkms

我有一个用 dkms 注册的内核模块。当最近的升级使我的内核升级到 4.15.0-50 时,我开始从 dkms 收到以下错误。显然内核 4.15.0-50 是用 gcc 7.3.0 版编译的,但升级的一部分涉及安装新版本的 gcc (7.4.0),这导致 dkms 失败。gcc 7.3 在我的系统上不再可用。除了7.4之外,如何安装gcc 7.3,甚至将7.4降级到7.3?

DKMS make.log for nvidia-430.14 for kernel 4.15.0-50-generic (x86_64)
Tue May 14 17:08:12 CDT 2019
make[1]: Entering directory '/usr/src/linux-headers-4.15.0-50-generic'
Makefile:976: "Cannot use CONFIG_STACK_VALIDATION=y, please install libelf-dev, libelf-devel or elfutils-libelf-devel"
  SYMLINK /var/lib/dkms/nvidia/430.14/build/nvidia/nv-kernel.o
  SYMLINK /var/lib/dkms/nvidia/430.14/build/nvidia-modeset/nv-modeset-kernel.o

Compiler version check failed:

The major and minor number of the compiler used to
compile the kernel:

gcc version 7.3.0 (Ubuntu 7.3.0-16ubuntu3)

does not match the compiler used here:

cc (Ubuntu 7.4.0-1ubuntu1~18.04) 7.4.0
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.


It is recommended to set the CC environment variable
to the compiler that was used to compile the kernel.

The compiler version check can be disabled by setting
the IGNORE_CC_MISMATCH environment variable to "1".
However, mixing compiler versions between the kernel
and kernel modules can result in subtle bugs that are
difficult to diagnose.

*** Failed CC version check. Bailing out! ***

/var/lib/dkms/nvidia/430.14/build/Kbuild:182: recipe for target 'cc_version_check' failed
make[2]: *** [cc_version_check] Error 1
make[2]: *** Waiting for unfinished jobs....
Makefile:1552: recipe for target '_module_/var/lib/dkms/nvidia/430.14/build' failed
make[1]: *** [_module_/var/lib/dkms/nvidia/430.14/build] Error 2
make[1]: Leaving directory '/usr/src/linux-headers-4.15.0-50-generic'
Makefile:81: recipe for target 'modules' failed
make: *** [modules] Error 2
Run Code Online (Sandbox Code Playgroud)

小智 6

您可以将以下选项传递给 nvidia 安装程序,而不是安装多个版本的 gcc:

--no-cc-version-check
Run Code Online (Sandbox Code Playgroud)

在 Ubuntu 18.04.2、内核 4.18.0-20 和 nvidia 430.14 上为我工作。