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.

  • Build gcc-5.4.0 drive.google.com/file/d/18QF-83jzDLfA9jSMn4KvvuTkKiY2nm9u/… .... 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 9 '20 at 21:00
  • @KnudLarsen and how do we install gcc-4.8? – ctrl-alt-delor Feb 9 '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 hub.docker.com/r/purplekarrot/gcc-5 – ctrl-alt-delor Feb 9 '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" drive.google.com/drive/folders/… ... ( gcc-5.4.0 is also available.) – Knud Larsen Feb 9 '20 at 23:03
  • 1
    Thanks @KnudLarsen, your gcc-4.8 package worked for me! – peachykeen Feb 11 '20 at 14:33

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.