Downgrade GCC to older versions with apt-get

1

1

For specific reasons, I have to downgrade my GCC to version 2.x using apt-get (not downloading and compiling the source).

Is that possible? If yes, how can I find the repository address and install it via apt-get?

Thanks in advance.

Afshin Mehrabani

Posted 2014-05-27T19:51:24.273

Reputation: 113

This is going to be specific to the version of the distribution you are on due to library dependencies. As an aside, it's also best that you install older versions of gcc in parallel rather than actually downgrading, and use environment settings to force whatever you need gcc to compile to use the older gcc. Given the length of time gcc 2.x has been out of support for, this is going to be a challenge, and even if you succeed in getting it installed, replacing the system gcc will break other things. – Stephanie – 2014-05-27T21:00:13.923

Researching this a little more, and the 2.x series might not be usable at all in modern distributions. It hasn't been supported for a long time in the kernel (http://lwn.net/Articles/163881/) and whatever you are trying to compile with it probably has dependencies which won't be able to be satisfied either. IF the software you need to compile can't be updated to compile on a newer gcc and with newer libraries, then your best option might be to compile it statically in a chroot of whatever distribution last supported gcc 2.x

– Stephanie – 2014-05-27T21:09:36.207

@Stephanie So how can I install v2.x inside other versions? – Afshin Mehrabani – 2014-05-27T21:09:39.997

I think there are going to be issues of ABI compatibility and "de4pendency hell" that are going to make it all but impossible, that is, it will be far easier to update software to build on a modern version of gcc than it will be to get a version of gcc 2.x to install and produce usable binaries on a modern distribution. The issue is that you don't just need gcc 2.x here, you need all the dependencies it requires, and all the dependences the application you want to build requires, and these things haven't been maintained at all in more than 9 years. – Stephanie – 2014-05-27T23:22:58.007

Answers

1

For all practical intents and purposes, what you are asking is impossible, and in the next few paragraphs there is an explanation of why, and some potential workarounds.

While gcc, glibc, the Linux kernel, and other various system libraries are not as closely coupled as they would be in FreeBSD ir OpenBSD, they do have a parallel evolution. As the last holdouts of support for gcc 2.95 fell out of support in the kernel back in 2005, so also has support for it in the core system libraries.

Just getting a 2.x version of gcc to install on a modern system would be a significant hurdle because of all the dependencies involved - it depends on older versions of system libraries that the Linux community has long ago moved on from, creating a situation of "dependency hell" even to install from source, much less try to install from packages - the dependencies alone would probably force you to downgrade through a dozen generations or more of your Linux distribution, onto a version which not only is no longer supported, but also terribly insecure.

After getting gcc to install, you are still left with the problem of getting your application to compile - and the system libraries have changed just as much or more than gcc has, so you'd have to go all through this process again for dozens, perhaps hundreds of other dependencies. All of these dependencies of course, already being used elsewhere on the system, leaving no sane way of getting the right versions of them installed.

You are probably looking at thousands, possibly hundreds of thousands of hours of work before you'll have any chance of getting all the pieces working again, and along the way, you'd have transformed your system into something so unmaintainable and unstable that even rebooting the system would be an exercise in blind faith, and you'd have reintroduced more than a decade of serious security vulnerabilities into your system.

Workarounds

All hope however is not lost. The short term solutions are a chroot or virtualization. one of the answers from https://stackoverflow.com/questions/8176798/installing-gcc-2-95-3-in-ubuntu-10-04-3 mentions that Debian Etch was one of the last distributions to have supported gcc 2.95. Building a chroot of Debian Etch or a virtual machine should be possible. This distribution last received security support in 2010, so you'd still be looking at 4 years worth of accumulated security vulnerabilities.

The old versions of Debian that you would need for this are only found at https://archive.debian.org/debian as they are utterly unmaintained at this point.

debootstrap (https://wiki.debian.org/Debootstrap) appears to still be able to install etch, making it possible to build a working chroot, inside which you will be able to compile and run old software.

Given the security implications, the long term solution has to be to update the code to compile on a modern, currently supported distribution as soon as possible. Unless the software in question is being used for a one-off purpose, such as recovery of data from an older version of a program, this is absolutely critical.

A viable solution for making this porting process manageable may be to progressively move forward, moving forward and fixing the compilation issues for each intervening Debian release, before finally updating the code for the most recent Ubuntu release. As Debian has a much longer release cycle than Ubuntu and decent forward compatibility, this shouldn't be too insurmountable a task, and will almost certainly be more feasible than porting gcc 2.x to the latest Ubuntu.

Edit: Etch is actually perfect for a lot of the porting effort - it supports versions of gcc from 2.95 to 4.1, thereby making it possible to update your old code in small steps.

Stephanie

Posted 2014-05-27T19:51:24.273

Reputation: 1 778