2

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

  • To start with, you need mpc as well. To go along with it, you also need the correct versions of mpfr and gmp that go with GCC 4.8.5. Those would be, for gmp, mpfr, and mpc, respectively, 4.3.2, 2.4.2, and 0.8.1. You need to first compile the above in that order and mpfr needs the correct flags for gmp and mpc needs the correct flags for gmp and mpfr. Might I ask why you need such an old version of GCC? If you have software that just won't compile with GCC 8.4, then it's far easier to just spin up a CentOS 7 VM that uses GCC 4.8.5 by default. – Nasir Riley Oct 19 '21 at 22:52
  • Thanks for your detailed response! I try to take care of the prerequisites using ./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
  • Crazy that a question this good with 2k views could get 0 upvotes. – Nike Dattani Dec 28 '22 at 20:54

1 Answers1

1

From the appropriate bug report:

Jakub Jelinek 2017-05-13 06:52:08 UTC

The bug is on the GCC 4.8 side, so either you need to patch it, or build with -std=gnu++98 - then __GNUC_STDC_INLINE__ will not be defined and it ought to compile fine.

Please check this answer as well: https://unix.stackexchange.com/a/472713/260833

  • Thank you! Your answer has helped me to move forward a lot with the compilation: my previous mistake was that, while patching cfns.h, I only edited the function's declaration and not its definition. A few more errors down the line, identified and fixed, I have bumped into something I cannot fix or find how to fix:

    /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/gcc-4.8.5/BUILD/./gcc/cc1plus)

    What do I do now? Thanks in advance

    – Sergey Shuvaev Oct 20 '21 at 06:02
  • Please edit your question and show exactly what you did, as well as the errors you got. – Artem S. Tashkinov Oct 20 '21 at 08:43
  • @ArtemSTashkinov thanks for your replies! I have updated the question to reflect the recent progress and to describe the new errors – Sergey Shuvaev Oct 20 '21 at 15:03