Kernel 4.19 and GCC 4.8.5-16

I ran into an issue trying to compile my own kernel, as you may remember.  The error suggested that I didn’t meet the minimum requirements to compile a kernel.  Well, as it turns out, the programs that I *do* have installed meet the minimum requirements.  The error message says my compiler is a non-retpoline compiler.  retpoline is:

The kernel can protect itself against consuming poisoned branch target buffer entries by using return trampolines (also known as “retpoline”) [3] [9] for all indirect branches. Return trampolines trap speculative execution paths to prevent jumping to gadget code during speculative execution. x86 CPUs with Enhanced Indirect Branch Restricted Speculation (Enhanced IBRS) available in hardware should use the feature to mitigate Spectre variant 2 instead of retpoline. Enhanced IBRS is more efficient than retpoline[1].

We’ll save the spectre discussion for another day (or, just google it, there are plenty of resources to explain what it is).  Back to the issue at hand, I beg to differ that my compiler is a non-retpoline compiler.  Well, at least according to the minimum specs, my version meets the requirements.

Or, does it?  According to Marek Polacek, I need gcc-4.8.5-28.el7 or newer.

I’m running 4.8.5-16.el7

[root@cleveland linux-4.19.87]# yum info gcc
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Installed Packages
Name : gcc
Arch : x86_64
Version : 4.8.5
Release : 16.el7
Size : 37 M
Repo : installed
From repo : anaconda
Summary : Various compilers (C, C++, Objective-C, Java, ...)
URL : http://gcc.gnu.org
License : GPLv3+ and GPLv3+ with exceptions and GPLv2+ with exceptions and LGPLv2+ and BSD
Description : The gcc package contains the GNU Compiler Collection version 4.8.
: You'll need this package in order to compile C code.

Let’s download and install a newer version.  I found one here: http://mirror.centos.org/centos/7/os/x86_64/Packages/

List its dependencies:

# rpm -qpR gcc-4.8.5-39.el7.x86_64.rpm
warning: gcc-4.8.5-39.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
/bin/sh
/bin/sh
/bin/sh
/sbin/install-info
/sbin/install-info
binutils >= 2.20.51.0.2-12
cpp = 4.8.5-39.el7
glibc-devel >= 2.2.90-12
ld-linux-x86-64.so.2()(64bit)
ld-linux-x86-64.so.2(GLIBC_2.3)(64bit)
libc.so.6()(64bit)
libc.so.6(GLIBC_2.11)(64bit)
libc.so.6(GLIBC_2.14)(64bit)
libc.so.6(GLIBC_2.2.5)(64bit)
libc.so.6(GLIBC_2.3)(64bit)
libc.so.6(GLIBC_2.3.2)(64bit)
libc.so.6(GLIBC_2.3.4)(64bit)
libc.so.6(GLIBC_2.4)(64bit)
libc.so.6(GLIBC_2.7)(64bit)
libdl.so.2()(64bit)
libdl.so.2(GLIBC_2.2.5)(64bit)
libgcc >= 4.8.5-39.el7
libgcc_s.so.1()(64bit)
libgmp.so.10()(64bit)
libgomp = 4.8.5-39.el7
libgomp.so.1()(64bit)
liblto_plugin.so.0()(64bit)
libm.so.6()(64bit)
libmpc.so.3()(64bit)
libmpfr.so.4()(64bit)
libz.so.1()(64bit)
rpmlib(CompressedFileNames) <= 3.0.4-1
rpmlib(FileDigests) <= 4.6.0-1
rpmlib(PartialHardlinkSets) <= 4.0.4-1
rpmlib(PayloadFilesHavePrefix) <= 4.0-1
rtld(GNU_HASH)
rpmlib(PayloadIsXz) <= 5.2-1

Or, get a more useful list by trying to install the rpm:

# rpm -Uvh gcc-4.8.5-39.el7.x86_64.rpm
warning: gcc-4.8.5-39.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
error: Failed dependencies:
cpp = 4.8.5-39.el7 is needed by gcc-4.8.5-39.el7.x86_64
libgcc >= 4.8.5-39.el7 is needed by gcc-4.8.5-39.el7.x86_64
libgomp = 4.8.5-39.el7 is needed by gcc-4.8.5-39.el7.x86_64

A quick note on our options for solving this riddle.

Option 1: yum localinstall is for one package.  Dependencies will be downloaded from the enabled repositories only.

yum install /home/drd/Downloads/libgomp-0.2.5-1.el7_x86_64.rpm

This still maintains the integrity of the rpm and yum databases.

Option 2: For local dependencies use rpm -Uvh *  (when the package + all dependencies are in the same directory)

Option 3: rpm -ivh is used when you want to have two versions of the same library installed (or, if you are absolutely sure that no package by the same name is installed)

Lastly, yum always uses rpm -Uvh for install.

So, keep working through the list of dependencies until all rpms are found in the local directory:

# rpm -Uvh *.rpm
warning: cpp-4.8.5-39.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
error: Failed dependencies:
libstdc++ = 4.8.5-39.el7 is needed by gcc-c++-4.8.5-39.el7.x86_64
libstdc++-devel = 4.8.5-39.el7 is needed by gcc-c++-4.8.5-39.el7.x86_64

And finally…

# rpm -Uvh *.rpm
warning: cpp-4.8.5-39.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
Preparing... ################################# [100%]
Updating / installing...
1:libquadmath-4.8.5-39.el7 ################################# [ 5%]
2:libgcc-4.8.5-39.el7 ################################# [ 9%]
3:libstdc++-4.8.5-39.el7 ################################# [ 14%]
4:libstdc++-devel-4.8.5-39.el7 ################################# [ 18%]
5:libgfortran-4.8.5-39.el7 ################################# [ 23%]
6:libgomp-4.8.5-39.el7 ################################# [ 27%]
7:cpp-4.8.5-39.el7 ################################# [ 32%]
8:gcc-4.8.5-39.el7 ################################# [ 36%]
9:libquadmath-devel-4.8.5-39.el7 ################################# [ 41%]
10:gcc-gfortran-4.8.5-39.el7 ################################# [ 45%]
11:gcc-c++-4.8.5-39.el7 ################################# [ 50%]
Cleaning up / removing...
12:gcc-gfortran-4.8.5-16.el7 ################################# [ 55%]
13:gcc-c++-4.8.5-16.el7 ################################# [ 59%]
14:libquadmath-devel-4.8.5-16.el7 ################################# [ 64%]
15:gcc-4.8.5-16.el7 ################################# [ 68%]
16:libgfortran-4.8.5-16.el7 ################################# [ 73%]
17:libstdc++-devel-4.8.5-16.el7 ################################# [ 77%]
18:libstdc++-4.8.5-16.el7 ################################# [ 82%]
19:libgcc-4.8.5-16.el7 ################################# [ 86%]
20:libquadmath-4.8.5-16.el7 ################################# [ 91%]
21:cpp-4.8.5-16.el7 ################################# [ 95%]
22:libgomp-4.8.5-16.el7 ################################# [100%]

And, we’re in business!  My make rpm-pkg works for compiling my kernel.