centosvirtualboxcentos7devtoolsetvirtualbox-guest-additions

stack-protector enabled but compiler support broken while installing VirtualBox Guest Additions with devtoolset-8


Note: This problem, which I have already solved, is a very different problem from every other similar question on Stack Overflow. I have posted this question and answer in the hopes that it will help someone else experiencing the same issue (or so that, when I have this problem again in 3 years, I'll find this answer).

I am running VirtualBox 6.1.26 on macOS Catalina 10.15.7. I am emulating centOS 7:

$ uname -r
3.10.0-1160.36.2.el7.x86_64

I "inserted" the VirtualBox Guest Additions CD and followed the auto-run prompts to install the Guest Additions. Part way through, it aborted, saying:

This system is currently not set up to build kernel modules.
Please install the gcc make perl packages from your distribution.

Note that I have gcc, make, perl, kernel-devel, and kernel-headers all installed. It also prompted me to check the file /var/log/vboxadd-setup.log for more details. The contents of that log were interesting:

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

Extensive searching for these errors yields multiple forum posts and Stack Overflow questions whose replies and accepted answers reveal either that I'm missing one of those installed packages (I'm not) or that my GCC version is less than 7.3 (when support for CONFIG_RETPOLINE=y was added). However:

$ gcc --version
gcc (GCC) 8.3.1 20190311 (Red Hat 8.3.1-3)

This is > 7.3, so it does support this feature. I should note that I installed GCC using the Yum devtoolset packages in order to use this newer compiler:

$ 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
...

And I do not have any other GCC versions installed:

$ 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

And I have this in ~/.bashrc to enable devtoolset upon login:

...
source scl_source enable devtoolset-8
...

What am I doing wrong?


Solution

  • It turned out the problem wasn't that I was using the wrong GCC version (not possible) or that I was missing any installed packages (I wasn't). Instead, it was a consequence of how the VirtualBox Guest Additions "auto-run" works. Something about the way it runs results in a "fresh" environment without devtoolset-8 properly sourced. As a result, it cannot find the installed GCC 8.3.

    The solution was simple: When the auto-run prompt appeared, I dismissed it and did not run auto-run. Instead, I opened a fresh Terminal window and changed directories to /run/media/[username]/VBox_GAs_6.1.26 (YMMV on the exact location of the mounted disk), then ran this command:

    $ sudo ./VBoxLinuxAdditions.run
    

    That command completed successfully, the kernel module compiled, the Guest Additions installed, and they are working properly now.