无法创建“Hello World”模块(以及 NVIDIA 和 VirtualBox)

dim*_*rvp 6 drivers kernel debian nvidia

首先,细节。

之前:内核:3.2.0-2-amd64,nvidia 驱动程序:295.59

之后:内核:3.2.0-3-amd64,nvidia 驱动程序:302.17-3

我的 Debian wheezy 始终保持最新。实际上,每天做一apt-get upgrade -s开始就让我陷入了这个麻烦。

显然,apt-get upgrade在我的 Debian 上发生了一些“坏事”——与构建生态系统和/或 DKMS 本身有关的东西。

NVIDIA 驱动程序无法通过官方 Wiki 中推荐的任何方法构建。包括 NVIDIA 官方二进制文件(其中一项更新中的日志片段)。

这是输出dpkg-reconfigure nvidia-kernel-dkms

# dpkg-reconfigure nvidia-kernel-dkms

------------------------------
Deleting module version: 302.17
completely from the DKMS tree.
------------------------------
Done.
Loading new nvidia-302.17 DKMS files...
Building only for 3.2.0-3-amd64
Building initial module for 3.2.0-3-amd64
Error!  Build of nvidia.ko failed for: 3.2.0-3-amd64 (x86_64)
Consult the make.log in the build directory
/var/lib/dkms/nvidia/302.17/build/ for more information.
Run Code Online (Sandbox Code Playgroud)

来自/var/lib/dkms/nvidia/302.17/build/make.log以下的相关片段。问题在于编译,我可以保证。

  LD [M]  /var/lib/dkms/nvidia/302.17/build/nvidia.o
  Building modules, stage 2.
  MODPOST 0 modules
make[1]: Leaving directory `/usr/src/linux-headers-3.2.0-3-amd64'
make: Leaving directory `/var/lib/dkms/nvidia/302.17/build'
Run Code Online (Sandbox Code Playgroud)

就是这样。在同一目录中的任何其他文件中没有任何类型的解释(至少就我检查而言)。

在我提问之前:我现在正在使用 nouveau 驱动程序(反正我也没有任何选择),但它对我来说不太好用。我有 3 台台式机,其中 1 台一直在播放电影,另外 2 台上的开发人员非常忙碌。 nouveau 驱动程序在那里有点失败(第二个屏幕上的电影一直出现横条纹,XFCE 控制台滞后有点在滚动等)

问题:

  • 我应该更改我的内核版本吗?试图3.2.0-2-amd643.2.0-3-amd64,无济于事。尝试3.2.0-3-rt-amd64使我的机器在运行几分钟后冻结,因此我不敢再安装它。
  • 我应该在我的构建环境中更改某个版本吗?(正如更新中所指出的,事实证明,这不仅仅是 NVIDIA 的问题)。
  • 我是否应该假设我的链接器有问题(我没有使用gold,我正在ldbinutils包中使用),如果是这样,我该怎么做才能使 DKMS 方法最终起作用?由于问题似乎确实在链接阶段表现出来(并且 MODPOST 显示 0 个模块)。

就个人而言,这让我在更深层次上感到不安,我通常愿意承认。我非常尊重 Debian,它现在已经破碎了。来吧,一个简单的方法apt-get upgrade会破坏所有开源内核驱动程序的编译/链接吗?

非常令人失望。

更新#1:

我确实尝试安装官方的 304.22 NVIDIA 驱动程序,这是日志文件。看起来链接确实失败了,是吗?

此外,如果我还尝试启用 DKMS 集成,我会收到一条消息,提示脚本无法确定当前内核版本(第三次更新中的文本)。

nvidia-installer 日志文件“/var/log/nvidia-installer.log”
创建时间:2012年7月21日星期六22:59:30
安装程序版本:304.22

路径:/usr/local/rvm/gems/ruby-1.9.3-p194/bin:/usr/local/rvm/gems/ruby-1.9.3-p194@global/bin:/usr/local/rvm/rubies /ruby-1.9.3-p194/bin:/usr/local/rvm/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

nvidia-installer 命令行:
    ./nvidia-安装程序

使用:nvidia-installer ncurses 用户界面
-> 接受许可。
-> 安装 NVIDIA 驱动程序版本 304.22。
-> 您的系统上似乎已经安装了驱动程序(版本:304.22)。作为安装此驱动程序(版本:304.22)的一部分,现有驱动程序将被卸载。你确定你要继续吗?(“否”将中止安装)(答案:是)
-> 你想用 DKMS 注册内核模块源吗?如果您稍后安装不同的内核,这将允许 DKMS 自动构建新模块。(答案:否)
-> 使用 CC="gcc-4.6" 执行 CC 健全性检查。
-> 使用 CC="gcc-4.6" 执行 CC 版本检查。
-> 内核源路径:'/lib/modules/3.2.0-3-amd64/source'
-> 内核输出路径:'/lib/modules/3.2.0-3-amd64/build'
-> 执行 rivafb 检查。
-> 执行 nvidiafb 检查。
-> 执行 Xen 检查。
-> 清理内核模块构建目录。
   执行:'cd ./kernel; 弄干净'...
-> 构建内核模块:
   执行:'cd ./kernel; 使模块 SYSSRC=/lib/modules/3.2.0-3-amd64/source SYSOUT=/lib/modules/3.2.0-3-amd64/build'...
   NVIDIA:调用 KBUILD...
   make -C /lib/modules/3.2.0-3-amd64/build \
    KBUILD_SRC=/usr/src/linux-headers-3.2.0-3-common \
    KBUILD_EXTMOD="/tmp/selfgz10141/NVIDIA-Linux-x86_64-304.22/kernel" -f /usr/src/linux-headers-3.2.0-3-common/Makefile \
    模块
   test -e include/generated/autoconf.h -a -e include/config/auto.conf || ( \
    回声; \
    回声“错误:内核配置无效。”; \
    echo " include/generated/autoconf.h 或 include/config/auto.conf 丢失。";\
    echo "在内核 src 上运行 'make oldconfig && make prepare' 来修复它。"; \
    回声; \
    /bin/假)
   mkdir -p /tmp/selfgz10141/NVIDIA-Linux-x86_64-304.22/kernel/.tmp_versions ; rm -f /tmp/selfgz10141/NVIDIA-Linux-x86_64-304.22/kernel/.tmp_versions/*
   make -f /usr/src/linux-headers-3.2.0-3-common/scripts/Makefile.build obj=/tmp/selfgz10141/NVIDIA-Linux-x86_64-304.22/kernel
     gcc-4.6 -Wp,-MD,/tmp/selfgz10141/NVIDIA-Linux-x86_64-304.22/kernel/.nv.od -nostdinc -isystem /usr/lib/gcc/x86_64-linux-gnu/4.6/include -I /usr/src/linux-headers-3.2.0-3-common/arch/x86/include -Iarch/x86/include/generated -Iinclude -I/usr/src/linux-headers-3.2.0-3-common /include -include /usr/src/linux-headers-3.2.0-3-common/include/linux/kconfig.h -I/tmp/selfgz10141/NVIDIA-Linux-x86_64-304。22/kernel -D__KERNEL__ -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -Werror-implicit-function-declaration -Wno-format-security -fno-delete-null-pointer-检查 -Os -m64 -mtune=generic -mno-red-zone -mcmodel=kernel -funit-at-a-time -maccumulate-outgoing-args -fstack-protector -DCONFIG_AS_CFI=1 -DCONFIG_AS_CFI_SIGNAL_FRAME=1 -DCONFIG_AS_CFI_SECTIONS DCONFIG_AS_FXSAVEQ=1 -pipe -Wno-sign-compare -fno-asynchronous-unwind-tables -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -Wframe-larger-than=2048 -Wno-unused-but-设置变量 -fomit-frame-pointer -g -Wdeclaration-after-statement -Wno-pointer-sign -fno-strict-overflow -fconserve-stack -DCC_HAVE_ASM_GOTO -I/tmp/selfgz10141/NVIDIA-Linux-x86_64-304.22/内核 -Wall -MD -Wsign-compare -Wno-cast-22/kernel -Wall -MD -Wsign-compare -Wno-cast-22/kernel -Wall -MD -Wsign-compare -Wno-cast-
   qual -Wno-error -D__KERNEL__ -DMODULE -DNVRM -DNV_VERSION_STRING=\"304.22\" -Wno-unused-function -Wuninitialized -mno-red-zone -mcmodel=kernel -UDEBUG -U_DEBUG -DNDEBUG -DMODULE -D"KBUILD s)=#s" -D"KBUILD_BASENAME=KBUILD_STR(nv)" -D"KBUILD_MODNAME=KBUILD_STR(nvidia)" -c -o /tmp/selfgz10141/NVIDIA-Linux-x86_64-304.22/kernel/.tmp_nv.o / tmp/selfgz10141/NVIDIA-Linux-x86_64-304.22/kernel/nv.c
   在 /usr/src/linux-headers-3.2.0-3-common/include/linux/kernel.h:17:0 包含的文件中,
                    来自 /usr/src/linux-headers-3.2.0-3-common/include/linux/sched.h:55,
                    来自 /usr/src/linux-headers-3.2.0-3-common/include/linux/utsname.h:35,
                    来自 /tmp/selfgz10141/NVIDIA-Linux-x86_64-304.22/kernel/nv-linux.h:38,
                    来自/tmp/selfgz10141/NVIDIA-Linux-x86_64-304.22/kernel/nv.c:13:
   /usr/src/linux-headers-3.2.0-3-common/include/linux/bitops.h:在函数“hweight_long”中:
   /usr/src/linux-headers-3.2.0-3-common/include/linux/bitops.h:49:41: 警告:条件表达式中的有符号和无符号类型 [-Wsign-compare]
   在 /usr/src/linux-headers-3.2.0-3-common/arch/x86/include/asm/uaccess.h:575:0 包含的文件中,
                    来自 /usr/src/linux-headers-3.2.0-3-common/include/linux/poll.h:14,
                    来自 /tmp/selfgz10141/NVIDIA-Linux-x86_64-304.22/kernel/nv-linux.h:97,
                    来自/tmp/selfgz10141/NVIDIA-Linux-x86_64-304.22/kernel/nv.c:13:
   /usr/src/linux-headers-3.2.0-3-common/arch/x86/include/asm/uaccess_64.h:在函数“copy_from_user”中:
   /usr/src/linux-headers-3.2.0-3-common/arch/x86/include/asm/uaccess_64.h:53:6: 警告:有符号和无符号整数表达式之间的比较 [-Wsign-compare]

...用相同的警告剪断了大量编译输出...

     ld -m elf_x86_64 -r -o /tmp/selfgz10141/NVIDIA-Linux-x86_64-304.22/kernel/nvidia.o /tmp/selfgz10141/NVIDIA-Linux-x86_64-304.22/kernel/nv-kernel/nv-kernel4self. /NVIDIA-Linux-x86_64-304.22/kernel/nv.o /tmp/selfgz10141/NVIDIA-Linux-x86_64-304.22/kernel/nv-acpi.o /tmp/selfgz10141/NVIDIA-Linux-x86_64-304/nv22 -chrdev.o /tmp/selfgz10141/NVIDIA-Linux-x86_64-304.22/kernel/nv-cray.o /tmp/selfgz10141/NVIDIA-Linux-x86_64-304.22/kernel/nv-gvi.o /tmp/selfgz10 -Linux-x86_64-304.22/kernel/nv-i2c.o /tmp/selfgz10141/NVIDIA-Linux-x86_64-304.22/kernel/nv-mempool.o /tmp/selfgz10141/NVI
   DIA-Linux-x86_64-304.22/kernel/nv-mlock.o /tmp/selfgz10141/NVIDIA-Linux-x86_64-304.22/kernel/nv-mmap.o /tmp/selfgz10141/NVIDIA-Linux-x86_62-304/304 nv-p2p.o /tmp/selfgz10141/NVIDIA-Linux-x86_64-304.22/kernel/nv-pat.o /tmp/selfgz10141/NVIDIA-Linux-x86_64-304.22/kernel/nv-procfs.o /tmp/selfgz NVIDIA-Linux-x86_64-304.22/kernel/nv-usermap.o /tmp/selfgz10141/NVIDIA-Linux-x86_64-304.22/kernel/nv-vm.o /tmp/selfgz10141/NVIDIA-Linux-x86_62-304.o nv-vtophys.o /tmp/selfgz10141/NVIDIA-Linux-x86_64-304.22/kernel/os-agp.o /tmp/selfgz10141/NVIDIA-Linux-x86_64-304.22/kernel/os-interface.o /tmp/selfgz10 NVIDIA-Linux-x86_64-304.22/kernel/os-mtrr.o /tmp/selfgz10141/NVIDIA-Linux-x86_64-304.22/kernel/os-registry.o /tmp/selfgz10141/NVIDIA-Linux-x86_62-304/304 os-smp.o /tmp/selfgz10141/NVIDIA-Linux-x86_64-304.22/kernel/os-usermap.o
   (cat /dev/null; echo kernel//tmp/selfgz10141/NVIDIA-Linux-x86_64-304.22/kernel/nvidia.ko;) > /tmp/selfgz10141/NVIDIA-Linux-x86_64-304.22/kernel/modules.order
   make -f /usr/src/linux-headers-3.2.0-3-common/scripts/Makefile.modpost
     脚本/mod/modpost -m -i /usr/src/linux-headers-3.2.0-3-amd64/Module.symvers -I /tmp/selfgz10141/NVIDIA-Linux-x86_64-304.22/kernel/Module.symvers - o /tmp/selfgz10141/NVIDIA-Linux-x86_64-304.22/kernel/Module.symvers -S -w -s
   英伟达:离开 KBUILD。
   nvidia.ko 构建失败!
   make[1]: *** [模块] 错误 1
   制作:*** [模块] 错误 2
-> 错误。
错误:无法构建 NVIDIA 内核模块。
错误:安装失败。有关详细信息,请参阅文件“/var/log/nvidia-installer.log”。您可以在 www.nvidia.com 上的 Linux 驱动程序下载页面上的自述文件中找到有关修复安装问题的建议。

更新#2:

根据StarNamer的建议,我确实重新安装了linux-headers-3.2.0-3-amd64. 完成后,DKMS 启动并再次尝试编译 NVIDIA 驱动程序。这是文件的内容/var/lib/dkms/nvidia/304.22/build/make.log

DKMS make.log for nvidia-304.22 for kernel 3.2.0-3-amd64 (x86_64)
2012 年 7 月 22 日星期日 14:50:58 EEST
如果您使用的是 Linux 2.4 内核,请确保
你要么配置了匹配你的内核源代码
内核或安装了正确的内核头文件集
在你的系统上。

如果您使用的是 Linux 2.6 内核,请确保
您已经配置了与您的内核相匹配的内核源代码
安装在您的系统上。如果您指定了单独的
使用“KBUILD_OUTPUT”或
"O" KBUILD 参数,确保指定此
目录与 SYSOUT 环境变量或
等效的 nvidia-installer 命令行选项。

取决于内核来源(或
内核头文件)已安装,您可能需要指定
它们的位置与 SYSSRC 环境变量或
等效的 nvidia-installer 命令行选项。

*** 无法确定目标内核版本。***

make: *** [select_makefile] 错误 1

更新 #3:

经过几天的谷歌搜索,我开始怀疑这是否是 NVIDIA 的错。事实证明,事实并非如此。我尝试安装 Virtual Box 4.1(来自testingrepo),我再次偶然发现:

# cat /var/lib/dkms/virtualbox/4.1.18/build/make.log 
DKMS make.log for virtualbox-4.1.18 for kernel 3.2.0-3-amd64 (x86_64)
2012 年 7 月 24 日星期二 17:58:57 EEST
make:进入目录`/usr/src/linux-headers-3.2.0-3-amd64'
  LD /var/lib/dkms/virtualbox/4.1.18/build/built-in.o
  LD /var/lib/dkms/virtualbox/4.1.18/build/vboxdrv/built-in.o
  CC [M] /var/lib/dkms/virtualbox/4.1.18/build/vboxdrv/linux/SUPDrv-linux.o
……剪断了……
  CC [M] /var/lib/dkms/virtualbox/4.1.18/build/vboxpci/SUPR0IdcClientComponent.o
  CC [M] /var/lib/dkms/virtualbox/4.1.18/build/vboxpci/linux/SUPR0IdcClient-linux.o
  LD [M] /var/lib/dkms/virtualbox/4.1.18/build/vboxpci/vboxpci.o
  构建模块,第 2 阶段。
  MODPOST 0 模块
make:离开目录`/usr/src/linux-headers-3.2.0-3-amd64'

当然,没有更多细节(正如已经说过的,它看起来确实是一个链接器问题,但我还不能确定)。所以这更像是 Debian / DKMS 问题或某种配置错误。但是,我发誓我没有碰任何东西。我只是每天都在做apt-get upgrade-s。然后事情就不太顺利了,很明显。

更新#4:

我确实尝试创建一个小模块,如下所述:https : //stackoverflow.com/questions/4715259/linux-modpost-does-not-build-anything。确实我还在看MODPOST 0 modules。这是我放入V=1Makefile时的输出:

# 制作
make -C /lib/modules/3.2.0-3-amd64/build M=/home/dimi/code/hello V=1 modules
make[1]: 进入目录`/usr/src/linux-headers-3.2.0-3-amd64'
make -C /usr/src/linux-headers-3.2.0-3-amd64 \
    KBUILD_SRC=/usr/src/linux-headers-3.2.0-3-common \
    KBUILD_EXTMOD="/home/dimi/code/hello" -f /usr/src/linux-headers-3.2.0-3-common/Makefile \
    模块
test -e include/generated/autoconf.h -a -e include/config/auto.conf || ( \
    回声; \
    回声“错误:内核配置无效。”; \
    echo " include/generated/autoconf.h 或 include/config/auto.conf 丢失。";\
    echo "在内核 src 上运行 'make oldconfig && make prepare' 来修复它。"; \
    回声; \
    /bin/假)
mkdir -p /home/dimi/code/hello/.tmp_versions ; rm -f /home/dimi/code/hello/.tmp_versions/*
make -f /usr/src/linux-headers-3.2.0-3-common/scripts/Makefile.build obj=/home/dimi/code/hello
   gcc-4.6 -Wp,-MD,/home/dimi/code/hello/.hello.od -nostdinc -isystem /usr/lib/gcc/x86_64-linux-gnu/4.6/include -I/usr/src/linux -headers-3.2.0-3-common/arch/x86/include -Iarch/x86/include/generated -Iinclude -I/usr/src/linux-headers-3.2.0-3-common/include -include /usr /src/linux-headers-3.2.0-3-common/include/linux/kconfig。h -I/home/dimi/code/hello -D__KERNEL__ -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -Werror-implicit-function-declaration -Wno-format-security - fno-delete-null-pointer-checks -Os -m64 -mtune=generic -mno-red-zone -mcmodel=kernel -funit-at-a-time -maccumulate-outgoing-args -fstack-protector -DCONFIG_AS_CFI=1 - DCONFIG_AS_CFI_SIGNAL_FRAME=1 -DCONFIG_AS_CFI_SECTIONS=1 -DCONFIG_AS_FXSAVEQ=1 -pipe -Wno-sign-compare -fno-asynchronous-unwind-tables -mno-sse -mno-mmx -mno-sse2 -mno-3drnow第 2048 章s)=#s" -D"KBUILD_BASENAME=KBUILD_STR(hello)" -D"KBUILD_MODNAME=KBUILD_STR(hello)"-c -o /home/dimi/code/hello/.tmp_hello.o /home/dimi/code/hello/hello.c
(cat /dev/null; echo kernel//home/dimi/code/hello/hello.ko;) > /home/dimi/code/hello/modules.order
make -f /usr/src/linux-headers-3.2.0-3-common/scripts/Makefile.modpost
  脚本/mod/modpost -m -i /usr/src/linux-headers-3.2.0-3-amd64/Module.symvers -I /home/dimi/code/hello/Module.symvers -o /home/dimi/代码/你好/Module.symvers -S -w -c -s
make[1]: 离开目录`/usr/src/linux-headers-3.2.0-3-amd64'

这是我删除时看到的内容V=1

# 制作
make -C /lib/modules/3.2.0-3-amd64/build M=/home/dimi/code/hello modules
make[1]: 进入目录`/usr/src/linux-headers-3.2.0-3-amd64'
  抄送 [M] /home/dimi/code/hello/hello.o
  构建模块,第 2 阶段。
  MODPOST 0 模块
make[1]: 离开目录`/usr/src/linux-headers-3.2.0-3-amd64'

dim*_*rvp 6

解决了!

/root/.bashrc就这么简单:里面有这个:

 export GREP_OPTIONS='--color=always'
Run Code Online (Sandbox Code Playgroud)

改为:

 export GREP_OPTIONS='--color=never'
Run Code Online (Sandbox Code Playgroud)

...并重新启动 root shell(当然;不要省略这一步)。一切又开始工作了。从第一次尝试构建的 NVIDIA 和 VirtualBox 内核模块。我非常高兴!:-)

不过话又说回来,我对内核构建工具有点失望。他们应该更了解并通过--color=never他们使用的任何地方grep;或者更确切地说,存储 的旧值GREP_OPTIONS,在构建过程的生命周期内覆盖它,然后恢复它。

我希望我与这个问题进行的为期一周的史诗般的战斗将证明对社区和内核构建工具开发人员都很有价值。

非常感谢与我在一起并试图提供帮助的人们。

(所有学分都在这里:http : //forums.gentoo.org/viewtopic-p-4156366.html#4156366

  • 恭喜您找到解决方案。我认为这是内核构建工具中的一个错误,因为它真的不应该仅仅因为有人喜欢 grep 的颜色输出而中断! (6认同)