【发布时间】:2021-08-24 18:34:34
【问题描述】:
注意:我已经解决了这个问题,它与 Stack Overflow 上的所有其他类似问题都非常不同。我发布了这个问题和答案,希望它能帮助遇到同样问题的其他人(或者这样,当我在 3 年后再次遇到这个问题时,我会找到这个答案)。
我在 macOS Catalina 10.15.7 上运行 VirtualBox 6.1.26。我正在模拟centOS 7:
$ uname -r
3.10.0-1160.36.2.el7.x86_64
我“插入”了 VirtualBox Guest Additions CD 并按照自动运行提示安装了 Guest Additions。中途,它中止了,说:
This system is currently not set up to build kernel modules.
Please install the gcc make perl packages from your distribution.
请注意,我已经安装了 gcc、make、perl、kernel-devel 和 kernel-headers。它还提示我检查文件 /var/log/vboxadd-setup.log 以获取更多详细信息。该日志的内容很有趣:
Building the main Guest Additions 6.1.26 module for kernel 3.10.0-1160.36.2.el7.x86_64.
Error building the module. Build output follows.
make V=1 CONFIG_MODULE_SIG= CONFIG_MODULE_SIG_ALL= -C /lib/modules/3.10.0-1160.36.2.el7.x86_64/build M=/tmp/vbox.0 SRCROOT=/tmp/vbox.0 -j4 modules
arch/x86/Makefile:96: stack-protector enabled but compiler support broken
arch/x86/Makefile:166: *** CONFIG_RETPOLINE=y, but not supported by the compiler. Compiler update recommended.. Stop.
make: *** [vboxguest] Error 2
modprobe vboxguest failed
对这些错误的广泛搜索会产生多个论坛帖子和 Stack Overflow 问题,其回复和接受的答案表明我缺少其中一个已安装的软件包(我没有)或者我的 GCC 版本低于 7.3(当添加了对CONFIG_RETPOLINE=y 的支持)。然而:
$ gcc --version
gcc (GCC) 8.3.1 20190311 (Red Hat 8.3.1-3)
这是> 7.3,所以它确实支持此功能。我应该注意,我使用 Yum devtoolset 软件包安装了 GCC,以便使用这个更新的编译器:
$ sudo yum list installed|grep devtoolset
...
devtoolset-8-gcc.x86_64 8.3.1-3.2-el7 @centos-sclo-rh
devtoolset-8-gcc-c++.x86_64 8.3.1-3.2-el7 @centos-sclo-rh
devtoolset-8-gcc-gdb-plugin.x86_64 8.3.1-3.2-el7 @centos-sclo-rh
...
devtoolset-8-make.x86_64 1:4.2.1-4.el7 @centos-sclo-rh
...
而且我没有安装任何其他 GCC 版本:
$ sudo yum list installed|grep gcc
devtoolset-8-gcc.x86_64 8.3.1-3.2-el7 @centos-sclo-rh
devtoolset-8-gcc-c++.x86_64 8.3.1-3.2-el7 @centos-sclo-rh
devtoolset-8-gcc-gdb-plugin.x86_64 8.3.1-3.2-el7 @centos-sclo-rh
libgcc.x86_64 4.8.5-44.el7 @anaconda
我在~/.bashrc 中有这个,以便在登录时启用devtoolset:
...
source scl_source enable devtoolset-8
...
我做错了什么?
【问题讨论】:
标签: centos virtualbox centos7 devtoolset virtualbox-guest-additions