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

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

我有一个在 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

答案1

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

--no-cc-version-check

适用于 Ubuntu 18.04.2、内核 4.18.0-20 和 nvidia 430.14。

答案2

根据此冗长的 Debian 报告错误进入:

IGNORE_CC_MISMATCH=1

升级之前。

答案3

在我的情况下,我可以选择无论如何都要编译,但安装失败了。我想我需要 gcc 7.3。我想知道 gcc 7.4 编译器是否有一个选项可以在 v. 7.3 上进行编译。

其他人说你需要有头文件,但是当我尝试添加它们时我收到了一条错误消息。

目前,我更愿意使用 gcc 7.3 编译器,因为我不太需要 gcc 7.4 编译器。我不确定如何解决这个问题。

相关内容