LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 06-21-2020, 04:48 AM   #1
PepperLegs
LQ Newbie
 
Registered: Oct 2019
Posts: 15

Rep: Reputation: Disabled
Question How should I go about compiling ancient GCC?


And when I say ancient, I really mean it. Think 2.95, possibly older if I figure out the former.
I'm feeling quite adventurous, and I'd really like to compile some old stuff. No real reason, I just want to do it for the satisfaction.

Now, here's the question: What would be the best way to go about doing it? I was thinking about going with the (Cross) Linux From Scratch way, and making an entire toolchain on a separate partition.

I'd probably compile GCC 5.1.0 first (maybe a slightly higher version if this doesn't work out of the box), then try to compile older binutils and glibc with the ready compiler (to minimize the chances for any errors).
I'd most likely have to make GCC in 2 passes though, like in the book, right? First a simple compiler without glibc, then one with it. Assuming this would do the trick, I would make an older toolchain, and go lower and lower, until I reach 2.95.

Would something like this work? Would such a toolchain have access to my system's libraries while at the same time using the older glibc installed on the separate partition?
I mean, it probably would if I configured it correctly, but it's always better to ask.

I find it all really fascinating, and I definitely wouldn't mind if this actually worked!
 
Old 06-21-2020, 06:29 AM   #2
business_kid
LQ Guru
 
Registered: Jan 2006
Location: Ireland
Distribution: Slackware & Android
Posts: 11,642

Rep: Reputation: 1360Reputation: 1360Reputation: 1360Reputation: 1360Reputation: 1360Reputation: 1360Reputation: 1360Reputation: 1360Reputation: 1360Reputation: 1360
Why not grab an old OS?

Seeing as you sound like you have thought about it, get a 2.2 or better. IIRC, gcc-2.95 was held onto into the early 3.x kernels because Linus recommended it. There was some kernel revision (maybe 3.0, otherwise 4.0) where we went from libc5 -->libc6), we lost mainstream support for isa bus, serial ports & floppy, but we got a sane memory structure. ISA & co were tolerated for a year or 2 through some software bodge. Gcc-2.95 was libc5 based.

There is a floppy based software distro based on busybox using libc5. It also features a 2.88MB El Torito option for cdrom at http://www.toms.net/rb

Finding old source, patches or an OS will be the issue. I'd advise a VM for this, unless you have an antique box. I would strongly advise wired networking, but you'd want to check if your pci bus goes as slow as 33 Mhz. You won't have any firmware back then either.
 
Old 06-21-2020, 06:51 AM   #3
PepperLegs
LQ Newbie
 
Registered: Oct 2019
Posts: 15

Original Poster
Rep: Reputation: Disabled
I certainly could use an old OS, there are some old Debian ISOs floating around their archives. Seems like a pretty solid choice.

I'd like to do it all on a modern (virtual) machine though, for the extra challenge. I want to see just how far I can go.
Thank you for the link, I'll keep that distro in mind.
 
Old 06-21-2020, 12:17 PM   #4
business_kid
LQ Guru
 
Registered: Jan 2006
Location: Ireland
Distribution: Slackware & Android
Posts: 11,642

Rep: Reputation: 1360Reputation: 1360Reputation: 1360Reputation: 1360Reputation: 1360Reputation: 1360Reputation: 1360Reputation: 1360Reputation: 1360Reputation: 1360
Slackware-8.1 is up on ftp://ftp.slackware.com:/pub/slackwa...-8.1/slackware

and probably also ftp.heanet.ie That offers kernel 2.4.18, gcc-2.95-3 and glibc-2.2.5, all dating from 2002. Slackware also had a good source collection.

Once you understand you are teetotally on your own, you'll be ok. The slackware setup doesn't have dependency management or updates. An old '486 or pentium board would be ideal. It's compiled i386. At a pinch, you can do
Code:
cd /
tar -xvf /path/to package.tgz
and everything will set up. You are seriously vulnerable with that kit online if anyone gets it that you have an old box.
 
Old 06-21-2020, 01:30 PM   #5
dugan
LQ Guru
 
Registered: Nov 2003
Location: Canada
Distribution: distro hopper
Posts: 9,666

Rep: Reputation: 4316Reputation: 4316Reputation: 4316Reputation: 4316Reputation: 4316Reputation: 4316Reputation: 4316Reputation: 4316Reputation: 4316Reputation: 4316Reputation: 4316
Can you build GCC 2.95? I'd try that first.
 
Old 06-22-2020, 04:42 AM   #6
business_kid
LQ Guru
 
Registered: Jan 2006
Location: Ireland
Distribution: Slackware & Android
Posts: 11,642

Rep: Reputation: 1360Reputation: 1360Reputation: 1360Reputation: 1360Reputation: 1360Reputation: 1360Reputation: 1360Reputation: 1360Reputation: 1360Reputation: 1360
With what is an old system, you can build a 32 bit system, LFS-style. But that was the time when You could be hacked by getting a buffer overflow in sendmail or inetd,and your extra code would get run where you could have a well-judged 'go to' and that gave you root access! That door has been shut since, Further, You could directly address i/o as the interrupts and addresses were fixed & known. ISA bus was in, pci was a novelty. Usb-1.0 was a novelty. Dialup internet was common.

If you use anything modern, compiling this old crap will be a nightmare. I suggest you save these old OSes. and sell them as antiques some day.
 
Old 06-22-2020, 06:31 AM   #7
PepperLegs
LQ Newbie
 
Registered: Oct 2019
Posts: 15

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by business_kid View Post
Slackware-8.1 is up on ftp://ftp.slackware.com:/pub/slackwa...-8.1/slackware

and probably also ftp.heanet.ie That offers kernel 2.4.18, gcc-2.95-3 and glibc-2.2.5, all dating from 2002. Slackware also had a good source collection.

Once you understand you are teetotally on your own, you'll be ok. The slackware setup doesn't have dependency management or updates. An old '486 or pentium board would be ideal. It's compiled i386. At a pinch, you can do
Code:
cd /
tar -xvf /path/to package.tgz
and everything will set up. You are seriously vulnerable with that kit online if anyone gets it that you have an old box.
Good God, that is some antique stuff, I love it! Although I do have a slightly out-of-date box lying in the basement somewhere, I'd definitely do it on a virtual machine, to minimize the risks.

Quote:
Originally Posted by dugan View Post
Can you build GCC 2.95? I'd try that first.
I gave it a go, actually! That didn't turn out too well though, unfortunately. I looked around the internet and found this, and it was going fairly well until that frame.c file.
I applied the listed workarounds, but I was still running into a similar error like the one on the page. I may have been doing something wrong though, I never exclude such an option.

Quote:
Originally Posted by business_kid View Post
With what is an old system, you can build a 32 bit system, LFS-style. But that was the time when You could be hacked by getting a buffer overflow in sendmail or inetd,and your extra code would get run where you could have a well-judged 'go to' and that gave you root access! That door has been shut since, Further, You could directly address i/o as the interrupts and addresses were fixed & known. ISA bus was in, pci was a novelty. Usb-1.0 was a novelty. Dialup internet was common.

If you use anything modern, compiling this old crap will be a nightmare. I suggest you save these old OSes. and sell them as antiques some day.
Oh dear, that does sound pretty hellish. It's amazing just how much technology has changed over the last years, isn't it?
 
Old 06-22-2020, 07:28 AM   #8
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 14,809

Rep: Reputation: 4870Reputation: 4870Reputation: 4870Reputation: 4870Reputation: 4870Reputation: 4870Reputation: 4870Reputation: 4870Reputation: 4870Reputation: 4870Reputation: 4870
Quote:
Originally Posted by PepperLegs View Post
Oh dear, that does sound pretty hellish. It's amazing just how much technology has changed over the last years, isn't it?
Actually the compiler (gcc) itself does not really depend on the hardware, so probably you will be able to rebuild it somewhere.
I would probably try to rebuild it using an existing compiler - ignoring all the warnings, and finally I would try to rebuild it with the compiler built in the previous step. The final result could be a compiler similar to 2.95, but will be able to run on your current host. But I have no idea if you could make any use of it. Eventually you will be able to recompile/rebuild tools like less.
 
Old 06-22-2020, 08:02 AM   #9
PepperLegs
LQ Newbie
 
Registered: Oct 2019
Posts: 15

Original Poster
Rep: Reputation: Disabled
Right! That's actually what I'd like to do, for example: compile GCC7 with GCC9 -> compile GCC4 with GCC7, etc. Something like that, until I reach GCC 2.95.

I'm having my doubts though, because I'm fairly sure those old versions of GCC would certainly fight with newer glibc. I was thinking about compiling older glibc with the older compiler, like GCC7, and then use it in the configuration process of even older GCC. Assuming glibc 2.24 would get installed in /opt/glibc-2.24, perhaps I could do something like this...?

Code:
cd gcc-(some version here)
mkdir build
cd build
CFLAGS="-L /opt/glibc-2.24/lib -I /opt/glibc-2.24/include" LDFLAGS="-Wl,--rpath=/opt/glibc-2.24/lib -Wl,--dynamic-linker=/opt/glibc-2.24/lib/ld-linux-x86-64.so.2" ../configure...
make
Would something like this work, by any chance? Last time I was messing around with linking apps against glibc other than the one on the system, I got a bunch of segmentation faults when trying to run the program. Not all the time though, some stuff I was able to make work.

I'm by no means expert, or even advanced, and I'm still in the process of figuring all this stuff out, but it's all so fascinating! Even when I fail miserably, heh.
 
Old 06-23-2020, 03:09 AM   #10
business_kid
LQ Guru
 
Registered: Jan 2006
Location: Ireland
Distribution: Slackware & Android
Posts: 11,642

Rep: Reputation: 1360Reputation: 1360Reputation: 1360Reputation: 1360Reputation: 1360Reputation: 1360Reputation: 1360Reputation: 1360Reputation: 1360Reputation: 1360
They'd love someone with your spirit & energy in the Arm world, e.g. the Slackware Arm forum or slarm64 (also on slackware arm). There, they're looking to compile something that will work for people, not the relics of old decency.

That said, we're trying to save you a major PITA with incompatible libraries. I even pointed you to a distro where you wouldn't run into that stuff, using gcc-2.95-3. If you're going to get high on failed compiles, knock yourself out and find out what will work, or put that energy into Arm development. There's people there describing themselves as 'porter' because they port source code from X86 to Arm. Get yourself a RazPi and an OS, and you're off. I'd like to hear the results of your X86 efforts, not more talking.
Code:
./configure --help |less
works on everything of that vintage.
 
Old 06-23-2020, 04:43 AM   #11
PepperLegs
LQ Newbie
 
Registered: Oct 2019
Posts: 15

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by business_kid View Post
They'd love someone with your spirit & energy in the Arm world, e.g. the Slackware Arm forum or slarm64 (also on slackware arm). There, they're looking to compile something that will work for people, not the relics of old decency.
...
If you're going to get high on failed compiles, knock yourself out and find out what will work, or put that energy into Arm development. There's people there describing themselves as 'porter' because they port source code from X86 to Arm. Get yourself a RazPi and an OS, and you're off.
I'll be sure to take a look there. Maybe I'll get a Pi one day and pitch in as well!

Quote:
That said, we're trying to save you a major PITA with incompatible libraries. I even pointed you to a distro where you wouldn't run into that stuff, using gcc-2.95-3.
I know, and I really appreciate the fact that you want to keep my sanity intact! It's only a matter of time before I boot up the old Slackware, so don't worry, your efforts are not in vain.

Quote:
I'd like to hear the results of your X86 efforts, not more talking.
Sorry, haha, I tend to brainstorm and talk about things instead of doing something! I'll be sure to jump right into it once I find enough time!
 
Old 06-24-2020, 03:20 AM   #12
business_kid
LQ Guru
 
Registered: Jan 2006
Location: Ireland
Distribution: Slackware & Android
Posts: 11,642

Rep: Reputation: 1360Reputation: 1360Reputation: 1360Reputation: 1360Reputation: 1360Reputation: 1360Reputation: 1360Reputation: 1360Reputation: 1360Reputation: 1360
Quote:
Originally Posted by PepperLegs View Post
I'll be sure to take a look there. Maybe I'll get a Pi one day and pitch in as well!

I know, and I really appreciate the fact that you want to keep my sanity intact! It's only a matter of time before I boot up the old Slackware, so don't worry, your efforts are not in vain.

Sorry, haha, I tend to brainstorm and talk about things instead of doing something! I'll be sure to jump right into it once I find enough time!
There's RazPi 4s now w/8GB ram. I use mine as a multimedia streamer and it's fine with 4GB.

I'm not particularly worried about your sanity - those effects wear off. I was thinking productivity.

We have a saying here about guys who will discuss what should be done at great length, but are awol when the work is scheduled. We say "He talks a good job." whereas he might prefer 'He does a good job.'
 
Old 06-24-2020, 10:01 AM   #13
rnturn
Senior Member
 
Registered: Jan 2003
Location: Illinois (SW Chicago 'burbs)
Distribution: Currently: openSUSE, Raspbian, Slackware. Formerly: CentOS, MacOS, Red Hat. Other: Solaris, Tru64
Posts: 1,977

Rep: Reputation: 325Reputation: 325Reputation: 325Reputation: 325
Quote:
Originally Posted by business_kid View Post
They'd love someone with your spirit & energy in the Arm world, e.g. the Slackware Arm forum or slarm64 (also on slackware arm). There, they're looking to compile something that will work for people, not the relics of old decency.

That said, we're trying to save you a major PITA with incompatible libraries. I even pointed you to a distro where you wouldn't run into that stuff, using gcc-2.95-3. If you're going to get high on failed compiles, knock yourself out and find out what will work, or put that energy into Arm development.
The OP will gain a transferable skill while getting software compiled, even if it is a relic they're bringing back to life. Of course, you could get that experience compiling modern software from sources as well (or install Gentoo).

As for incompatible libraries: Many years ago, before commercial support of open source software started becoming a thing, I had a need to compile gcc from sources on a DEC UNIX system. If memory serves, the first pass involved using the native C compiler to get a basic gcc working and then compiling gcc again with itself. It was an interesting process (all because I needed a recent version of Perl on the system) but not something I'd want to spend any time doing nowadays, especially since there has been at least one serious update to libc/glibc that would likely make compilation a nightmare. Would anyone ever trust the output of a C compiler after manually making changes to resolve library incompatibilities? (I wouldn't.)

Anyone wanting to mess with an old C compiler ought to check out the archives at https://archive.org/details/linux_distributions. They go back all the way to 1994 (Slackware 2.10 ... from the days when just getting X up and running was a significant problem) The gcc sources may be available in some of the archived distributions if you want to compile one from scratch. Gnu.org has archived versions going back to egcc 1.0.

Cheers...
 
Old 06-25-2020, 03:11 AM   #14
business_kid
LQ Guru
 
Registered: Jan 2006
Location: Ireland
Distribution: Slackware & Android
Posts: 11,642

Rep: Reputation: 1360Reputation: 1360Reputation: 1360Reputation: 1360Reputation: 1360Reputation: 1360Reputation: 1360Reputation: 1360Reputation: 1360Reputation: 1360
You're right, of course. The skill is transferable.
LFS do it by getting your current system to compile a static gcc, binutils & glibc & a few utilities in a /lfs/tools directory. Then chroot to /lfs and build dynamic versions in /lfs, so at a certain point you can remove /tools. But you needed a sound system to start on. I remember using something from the Red Hat stable (Fedora?) and going down in a tailspin because of their extensive patching.

From getting that kind of experience, you develop the 'eternal pessimist' kind of attitude. I was trying to save the OP from blunting his enthusiasm by driving full throttle up a cul-de-sac.
 
  


Reply

Tags
ancient, gcc


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
step 5.10 gcc/limitx.h gcc/glimits.h gcc/limity.h no such file or directory iambrj Linux From Scratch 7 08-07-2018 11:22 AM
Is it possible to compile an ancient GCC 4.1.2 compiler to Centos 7.2? tommilaiho Linux - Software 4 04-13-2016 05:10 PM
LXer: GCC 4.9 vs. GCC 5.1 vs. GCC 6.0 SVN Compiler Benchmarks LXer Syndicated Linux News 0 06-08-2015 01:00 PM
[SOLVED] SEGMENTATION FAULT using gcc 4.4.4 -O2 , works with gcc 4.1.0 -O2 or gcc 4.4.4 -O1 amir1981 Programming 36 07-26-2010 06:07 PM
Kernel compiling: gcc-3.3 is 586, should be gcc-3.3 386 Erik Plaggenmar Linux - Software 0 10-01-2004 11:38 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 01:56 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration