注意:这个问题,我已经解决了,是一个非常不同的问题,从其他类似的问题堆栈溢出。我已经张贴了这个问题和答案,希望它会帮助其他人经历同样的问题(或者,当我有这个问题再次在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,所以它 * 确实 * 支持这个特性。我应该注意到,我安装GCC使用Yum devtoolset
包,以便使用这个较新的编译器:
$ 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
...
我做错了什么?
1条答案
按热度按时间vql8enpb1#
事实证明,问题并不是我使用了错误的GCC版本(不可能),也不是我丢失了任何已安装的软件包(我没有)。相反,这是VirtualBox Guest Additions“自动运行”工作方式的结果。它运行的方式导致了一个没有正确来源的
devtoolset-8
的“新鲜”环境。结果,它找不到已安装的GCC 8.3。解决方案很简单:当自动运行提示出现时,我关闭了它,没有运行自动运行,而是打开了一个新的终端窗口,将目录更改为
/run/media/[username]/VBox_GAs_6.1.26
(YMMV位于已安装磁盘的确切位置),然后运行以下命令:该命令已成功完成,内核模块已编译,Guest Additions已安装,它们现在可以正常工作。