Compiling newer GCC with old OS

Hello,

Just a quick question: I have been trying to manage some old clusters with CentOS-6, which only has GCC-4.8 (an extremely old version!). Because I would like to use newer GCC, I first tried Homebrew (Linuxbrew), but it failed because of the need for newer glibc. Now I am wondering whether I can compile GCC from source, but not very sure whether the new version really works correctly on such an old OS (with old system libc). Is such a build a viable option to perform reliable calculations with newer GCC…?

If you install centos-release-scl package, you willl have devtoolset-9 metapackage available containing gcc 9.1. As CentOS 6 is not supported anymore, you’ll probably need to use CentOS Vault repositories.

1 Like

Thanks very much for the info! Our old cluster (with CentOS-6) have only devtoolset-2 installed (which provides gcc-4.8). So we first tried to use newer devtoolsets some time ago, but all the links we found at that time were dead-links, so got stuck at that time… I will try searching again with CentOS Vault, as suggested.

But one concern is the compatibility (as mentioned in the above page):

Building an application with Red Hat Developer Toolset 9.0 on Red Hat Enterprise Linux (for example, Red Hat Enterprise Linux 7) and then executing that application on an earlier minor version (such as Red Hat Enterprise Linux 6.7.z) may result in runtime errors due to differences in non-toolchain components between Red Hat Enterprise Linux releases. Users are advised to check compatibility carefully. Red Hat supports only execution of an application built with Red Hat Developer Toolset on the same, or a later, supported release of Red Hat Enterprise Linux than the version used to build that application.

Building GCC from source + setting PATH and LD_LIBRARY_PATH properly (+ building MPI based on that build) may work also, so now trying that method also. Because the CUDA is also used on that cluster, it is not clear whether we can use newer GCC built in such a way with the CUDA driver already installed… (I am not familiar with CUDA, so just experimenting). (FYI, I am not using CUDA, but a co-worker wants to use it together with newer GCC.)

You should have /etc/yum.repos.d/Centos-Vault.repo file installed. AFAIR, originally it contained entries for all subversions up to 6.9, disabled by default. When C6 reached its EOL (at 6.10), we only needed, before upgrading to newer major version, to disable regular repos, create the config lines for 6.10 in Centos-Vault.repo (based on 6.9) and enable them.
I have never encountered any problems with running devtoolset-9-compiled executables on other C6 machines (they do not need the devtoolset-9 chain installed, BTW), although my experience with doing that on older minor versions is not big.

1 Like

That’s very nice to hear. Thanks! I will try setting up the repo also (+ devtoolset-9).

Been there a while ago, twice.

First time I solved this issue by using spack, which relies on your local Python version to start-up. Fortunately, spack is built with very old cluster environment support in mind. If you can setup spack you can install the compiler with just:

spack install gcc@11.2.0
spack load gcc@11.2.0

This will build everything from scratch with you GCC-4.8, starting with automake, finishing with GCC-11.2.0, which is nicely automated but time-consuming.

Second time I used the conda-forge distribution (they built against a CentOS-6 sysroot), just download a mambaforge installer, create the base environment and

mamba create -n gcc gcc gxx gfortran
mamba activate gcc

Turns out that most of the developers on the cluster are now relying on the gcc environment I deployed in a shared directory to compile their C++ projects.


That’s the environment I made the above work with

❯ ls /lib/libm-*.so
/lib/libm-2.19.so
❯ /usr/bin/gcc --version
gcc (SUSE Linux) 4.8.5
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

2 Likes

Haha :grin: I guess this combination might be typical for old clusters…

And thanks very much for the info about “spack” and “mamba”! I heard those names before, but no experience yet. So I will try them for this installation :technologist:

1 Like