3

It looks like gcc-5 was recently removed from Debian's unstable repository. I need gcc-5 to compile an older Linux kernel (3.19) and so I am looking to build it from source, through this is causing me a great deal of trouble. I have been following the instructions found here, but I find myself wondering what settings I need to set and more. Thus far, I have done the following.

  1. Downloaded and unpacked the source code.
  2. Configured gcc-5 by doing the following:
% mkdir objdir
% cd objdir
% ../gcc-5.4.0/configure (I included neither options nor target flags)
  1. Attempted to build using the following in my objdir directory:
% make BOOT_CFLAGS='-O' bootstrap

However, bootstrapping raised errors that prevented me from moving onto the install. After running for about 5 minutes, I encounter the following errors:

In file included from ../../../../gcc-5.4.0/libgcc/unwind-dw2.c:401:0:
./md-unwind-support.h: In function 'x86_fallback_frame_state':
./md-unwind-support.h:141:18: error: field 'uc' has incomplete type
struct ucontext uc;
                ^
make[5]: *** [../../../../gcc-5.4.0/libgcc/shared-object.mk:14: unwind-dw2.o] Error 1
make[5]: Leaving directory '/home/me/objdir/x86_64-unknown-linux-gnu/32/libgcc'
make[4]: *** [Makefile:1154: multi-do] Error 1
make[4]: Leaving directory '/home/me/objdir/x86_64-unknown-linux-gnu/libgcc'
make[3]: *** [Makefile:119: multi-do] Error 2
make[3]: Leaving directory '/home/me/objdir/x86_64-unknown-linux-gnu/libgcc'
make[2]: *** [Makefile:16510: all-stage1-target-libgcc] Error 2
make[2]: Leaving directory '/home/me/objdir'
make[1]: *** [Makefile:22461: stage1-bubble] Error 2
make[1]: Leaving directory '/home/me/objdir'
make: *** [Makefile:22798: bootstrap] Error 2

I am running Debian 10 (Buster) and have the necessary prerequisites installed as listed here.

Any help or guidance either in fixing the errors I have during bootstrapping or with building from source in general would be much appreciated! Thank you.

peachykeen
  • 149
  • 3
  • 7
  • Build gcc-5.4.0 https://drive.google.com/file/d/18QF-83jzDLfA9jSMn4KvvuTkKiY2nm9u/view?usp=sharing .... Not tested with gcc-8 as the "build compiler" : You may have to use gcc-4.8? .... .... Please note that "no options" will fail. – Knud Larsen Feb 09 '20 at 21:00
  • @KnudLarsen and how do we install gcc-4.8? – ctrl-alt-delor Feb 09 '20 at 22:30
  • 2
    Consider using gcc in docker. It has versions going back to 6.5 I don't see version 5 in there though. (but maybe you can build from 6.5, @KnudLarsen did not reference what version we can use). Unofficial gcc-5 docker image at https://hub.docker.com/r/purplekarrot/gcc-5/ – ctrl-alt-delor Feb 09 '20 at 22:34
  • 1
    Gcc-4.8 : You can use the package gcc48-c++_4.8.4-2ubuntu14_amd64.deb ... Also usable with Debian : No dependencies (except libc6 >= 2.14) Provides /usr/local/bin/{gcc48, g++48} ... Link to extra "Debian compilers" https://drive.google.com/drive/folders/1xVEATaYAwqvseBzYxKDzJoZ4-Hc_XOJm?usp=sharing ... ( gcc-5.4.0 is also available.) – Knud Larsen Feb 09 '20 at 23:03
  • You can't compiler newer versions of GCC with older versions of GCC without patches. – S.S. Anne Feb 09 '20 at 23:23
  • 1
    Thanks @KnudLarsen, your gcc-4.8 package worked for me! – peachykeen Feb 11 '20 at 14:33

1 Answers1

4

The reason is that there were changes in glibc, which broke compatibility with old compilers. There exists a patch for those compilers. The patch replaces struct ucontext with ucontext_t in libgcc/config/<arch>/linux-unwind.h files, where <arch> is i386, aarch64, alpha etc.

There is a similar question on stackoverflow.

I addition to these fixes, I also needed to apply fixes for sanitizers code from here (some of them were enough) and here.

After that the GCC has been finally built.

Alex Che
  • 261
  • Its curious why they release a version that doesn't compile? – jersey bean Apr 09 '21 at 21:59
  • 1
    @jerseybean The GCC version did compile at the time of release. But later glibc broke compatibility at some point and after that time old versions of GCC stopped compiling with newer versions of glibc. I'm not exactly sure as to why glibc did that. Probably it had something to do with POSIX compliance. You can try to google it yourself, e.g. starting here. – Alex Che Apr 12 '21 at 06:54