【问题标题】:stack-protector enabled but compiler support broken while installing VirtualBox Guest Additions with devtoolset-8启用了堆栈保护器,但在使用 devtoolset-8 安装 VirtualBox Guest Additions 时编译器支持中断
【发布时间】: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


    【解决方案1】:

    事实证明,问题不在于我使用了错误的 GCC 版本(不可能),或者我缺少任何已安装的软件包(我没有)。相反,这是 VirtualBox Guest Additions “自动运行”工作方式的结果。它的运行方式会导致没有devtoolset-8 正确来源的“新鲜”环境。结果找不到安装的GCC 8.3。

    解决方法很简单:当出现自动运行提示时,我将其关闭,并没有运行自动运行。相反,我打开了一个新的终端窗口并将目录更改为/run/media/[username]/VBox_GAs_6.1.26(YMMV 在已安装磁盘的确切位置),然后运行以下命令:

    $ sudo ./VBoxLinuxAdditions.run
    

    该命令已成功完成,内核模块已编译,Guest Additions 已安装,它们现在可以正常工作。

    【讨论】:

      猜你喜欢
      • 2015-09-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-09-25
      • 1970-01-01
      • 2014-12-14
      • 1970-01-01
      相关资源
      最近更新 更多