I am trying to install GCC 4.8.5 under CentOS 8 Classic using GCC 8.4.1. Here's what I did (the question has been updated to reflect the recent progress)
Get the prerequisites
yum install gcc make glibc-devel glibc-devel.i686 libstdc++-8.4.1-1.el8.i686
Get the compiler and its dependencies as described here:
https://bytefreaks.net/gnulinux/downgrade-gcc-on-centos-7-0-64bit-to-version-4-8-2
wget http://ftp.gnu.org/gnu/gcc/gcc-4.8.5/gcc-4.8.5.tar.gz
tar -xvf gcc-4.8.5.tar.gz;
cd gcc-4.8.5/
./contrib/download_prerequisites;
Patch the files to avoid the double definition of libc_name_p as described here:
https://unix.stackexchange.com/a/571800
in file cfns.h included in except.c
Edit cfns.h and change the function declaration
#ifdef __GNUC__
__inline
#endif
const char * libc_name_p (const char *, unsigned int);
...and the function's definition
#ifdef __GNUC__
__inline
#ifdef __GNUC_STDC_INLINE__
__attribute__ ((__gnu_inline__))
#endif
#endif
const char * libc_name_p (const char *, unsigned int);
to the following code, followed by the declaration / definition
#ifdef __GNUC__
#ifdef __GNUC_STDC_INLINE__
__attribute__ ((__gnu_inline__))
#else
__inline
#endif
#endif
Patch the files to rename ucontext_t as described here:
How do I compile gcc-5 from source?
https://gcc.gnu.org/git/gitweb.cgi?p=gcc.git;h=883312dc79806f513275b72502231c751c14ff72
Replaces struct ucontext
with ucontext_t
in libgcc/config/<arch>/linux-unwind.h
files, where <arch>
is i386
, aarch64
, alpha
etc.
Configure as described here:
Installing older package of gcc on Centos 8 via dnf
mkdir BUILD
cd BUILD
export CFLAGS="-O2 -march=native -pipe"
export CXXFLAGS=$CFLAGS
export LD_LIBRARY_PATH="/lib:/lib64:"$LD_LIBRARY_PATH
../configure --prefix=$HOME/local/gcc/4.8.5
Build
make
make install
The whole thing fails on the MAKE step with the following error:
/home/sergey/Desktop/gcc-4.8.5/BUILD/./gcc/cc1plus:
/home/sergey/Desktop/gcc-4.8.5/BUILD/x86_64-unknown-linux-gnu/
libstdc++-v3/src/.libs/libstdc++.so.6: version `CXXABI_1.3.9' not found
(required by /home/sergey/Desktop/gcc-4.8.5/BUILD/./gcc/cc1plus)
I've tried to fix it by LD_LIBRARY_PATH="/lib:/lib64:"$LD_LIBRARY_PATH
where libstdc++-8.4.1-1.el8.x86_64
and libstdc++-8.4.1-1.el8.x686
are installed, but it didn't help.
The necessary version of CXXABI
though seems to be there both for /lib
and /lib64
:
strings /lib64/libstdc++.so.6 | grep CXXABI
...
CXXABI_1.3.9
...
The alternatives I've tried (which have also failed)
If I configure with: export CXXFLAGS=$CFLAGS" -std=gnu++98"
I get:
make[6]: *** No rule to make target '../src/c++11
/libc++11convenience.la', needed by 'libstdc++.la'. Stop.
If I configure with --with-multilib-list=m64
I get:
configure: error: in `/home/sergey/Desktop/gcc-4.8.5/BUILD/
x86_64-unknown-linux-gnu/libsanitizer':
configure: error: C compiler cannot create executables
Could you please help me to figure how to overcome this issue? Thanks
./contrib/download_prerequisites
, which seems to work fine. As to your other question, I need this version of GCC to compile an older project, including its prerequisites. Although this script is an industry standard, it is only largely used by the developer and not maintained to be easily deployed by the others, as mentioned in the readme. Since the script is intended to be used on 32 cores, I thought that a virtual machine may not be the best option. – Sergey Shuvaev Oct 20 '21 at 15:00