Why i586-elf?

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Binero
Posts: 15
Joined: Mon Mar 03, 2014 1:00 pm

Why i586-elf?

Post by Binero »

On every cross compiler related page in the wiki I find that you are compiling for the i586 architecture / CPU model / whatever. Why is that? Why must it be that architecture?
User avatar
sortie
Member
Member
Posts: 931
Joined: Wed Mar 21, 2012 3:01 pm
Libera.chat IRC: sortie

Re: Why i586-elf?

Post by sortie »

Hi Binero,

The value of i586-elf isn't terribly important as such. The important part is that you are building a cross-compiler, that is, you get a compiler that pulls in nothing from the local system and the compiler understands it is doing something special. The i586 part means that you are targeting a Pentium CPU or newer and your compiler is allowed to emit instructions that doesn't execute on older processors. Since the Pentium is from 1993, that is 21 years ago, that seems very reasonable unless you are a hobbyist that wants his OS to run on ancient machines.

Indeed, I'm strongly considering upgrading the community recommendation to the i686 (Pentium Pro) from 1995 (19 years ago), as it has SSE (Edit: This is wrong, it was the Pentium 3 from 1999 that introduced SSE). It is very reasonable to assume your OS will run on a i686 or newer, and if you don't, it probably won't be too much trouble to back-port your OS. Hell, it's even a fine assumption that your OS will run on a x86-64 machine, though that is less straightforward with GRUB + multiboot unfortunately.

For more information, do a little googling and find a page like this that explains the differences.

The -elf part means that you get an System V ABI toolchain that uses the ELF executable format. This is a fairly well suited format for osdev and Unix systems and is very well supported by a lot of utilities and this community. In the Bare Bones tutorial you boot an ELF kernel with multiboot. You cannot reliably complete the tutorial without a ix86 toolchain.
User avatar
iansjack
Member
Member
Posts: 4711
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: Why i586-elf?

Post by iansjack »

It's a very common architecture, which most people have, so if you are building a 32-bit cross-compiler it's the most likely choice. Though why anyone bothers with 32-bit OSs is a mystery to me.
Binero
Posts: 15
Joined: Mon Mar 03, 2014 1:00 pm

Re: Why i586-elf?

Post by Binero »

I'm guessing from the comments, there isn't really any reason to not use x86_64 but backwards compatibility?
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: Why i586-elf?

Post by Combuster »

Other than the fact that you need non-64-bit code somewhere to get to 64-bit :wink:
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
Binero
Posts: 15
Joined: Mon Mar 03, 2014 1:00 pm

Re: Why i586-elf?

Post by Binero »

Do you still need that if you're developing for UEFI? I thought UEFI was able to load 64 bit 'applications' just like that?
Antti
Member
Member
Posts: 923
Joined: Thu Jul 05, 2012 5:12 am
Location: Finland

Re: Why i586-elf?

Post by Antti »

Today, supporting 32-bit CPUs would be a very good idea. It would significantly increase the range of supported computers that are still in use (or usable at least). However, it is not so simple because writing an OS takes time and by the time the OS is released, 32-bit CPUs are more obsolete (perhaps obsolete enough to justify not supporting them).

I have solved the problem so that if BIOS is supported at all, then the 32-bit CPUs are also supported. If I am about to cut the 32-bit support, then I will cut the BIOS support also.
User avatar
iansjack
Member
Member
Posts: 4711
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: Why i586-elf?

Post by iansjack »

Combuster wrote:Other than the fact that you need non-64-bit code somewhere to get to 64-bit :wink:
But you don't need a 32-bit cross compiler to produce 32-bit object files.
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: Why i586-elf?

Post by Combuster »

But you don't need a 32-bit cross compiler to produce 32-bit object files.
Of course not. You could use an assembler :mrgreen:

Ergo,
Pretty much all of the GCC templates I've seen use a pattern like "i[3-7]86", and i686 GCC instances can emit back to 386 code. The only difference seems that the default allowed instructions change. I'm personally still regularly using a P1-200 for testing and I even have older hardware, so I stick to a i386 compiler. If you want i686+, you can set -march and possibly a separate -mtune, but at least you know you did it on purpose :).
Indeed, I'm strongly considering upgrading the community recommendation to the i686 (Pentium Pro) from 1995 (19 years ago), as it has SSE.
The Pentium Pro is the first i686, but supports neither MMX nor SSE - SSE is a Pentium 3 invention. Hence a i686 gcc don't give you the defaults you're looking for either. Instead, you need to supply something like -mtune=generic -mmmx -msse -O3 to get the expected effect.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
Binero
Posts: 15
Joined: Mon Mar 03, 2014 1:00 pm

Re: Why i586-elf?

Post by Binero »

Antti wrote:Today, supporting 32-bit CPUs would be a very good idea. It would significantly increase the range of supported computers that are still in use.
I'm just messing around, I don't plan on actually writing something that'll be used outside from this machine. :P
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re: Why i586-elf?

Post by Solar »

Basically i586-elf was what I decided to use as lowest common denominator for Pro-POS, back in 2001. (Don't search for it, it never got anywhere and is long defunct.)

I tried to follow the then-available instructions (the Mega-Tokyo OSDev FAQ), found some fault with them, and did a general overhaul of the instructions.

I buggered Stu so insistently that he eventually installed a PhpWiki on his server, and we turned the (static) FAQ into Wiki pages, which took off quite well.

Later the OS part of Mega-Tokyo was merged with osdev.org, and the PhpWiki was migrated to MediaWiki.

Then someone added a spin-off on how to do a 64bit cross-compiler.

But no-one ever touched the bit that says "i586-elf", because it's as good a setting as any other. I'm actually a bit touched by that.

Enough so that I thought I'd write a reply, say "hi" to everybody, do an (unrelated) edit in the Wiki and then be gone again. Nice to see the old faces as well as the new ones. Have fun coding.
Every good solution is obvious once you've found it.
User avatar
Brynet-Inc
Member
Member
Posts: 2426
Joined: Tue Oct 17, 2006 9:29 pm
Libera.chat IRC: brynet
Location: Canada
Contact:

Re: Why i586-elf?

Post by Brynet-Inc »

Solar wrote:Enough so that I thought I'd write a reply, say "hi" to everybody, do an (unrelated) edit in the Wiki and then be gone again. Nice to see the old faces as well as the new ones. Have fun coding.
It hasn't even been two years yet, pfft.

Hi.
Image
Twitter: @canadianbryan. Award by smcerm, I stole it. Original was larger.
User avatar
Geri
Member
Member
Posts: 442
Joined: Sun Jul 14, 2013 6:01 pm

Re: Why i586-elf?

Post by Geri »

be aware of the fact that even some brand new cpu-s can do up to 5x86 instruction set only. for example, vortex86dx, which costs more than its weight in gold.
Operating system for SUBLEQ cpu architecture:
http://users.atw.hu/gerigeri/DawnOS/download.html
User avatar
bwat
Member
Member
Posts: 359
Joined: Fri Jul 03, 2009 6:21 am

Re: Why i586-elf?

Post by bwat »

Solar wrote:I buggered Stu so insistently ...
You did what????
Solar wrote:that he eventually installed a PhpWiki on his server and we turned the (static) FAQ into Wiki pages, which took off quite well.
It makes me wonder just what we'll have to do to get a compilers subforum here. Not sure I'm prepared to pay the price to be honest.
Every universe of discourse has its logical structure --- S. K. Langer.
gerryg400
Member
Member
Posts: 1801
Joined: Thu Mar 25, 2010 11:26 pm
Location: Melbourne, Australia

Re: Why i586-elf?

Post by gerryg400 »

Solar wrote:Basically i586-elf was what I decided to use as lowest common denominator for Pro-POS, back in 2001. (Don't search for it, it never got anywhere and is long defunct.)

I tried to follow the then-available instructions (the Mega-Tokyo OSDev FAQ), found some fault with them, and did a general overhaul of the instructions.

I buggered Stu so insistently that he eventually installed a PhpWiki on his server, and we turned the (static) FAQ into Wiki pages, which took off quite well.

Later the OS part of Mega-Tokyo was merged with osdev.org, and the PhpWiki was migrated to MediaWiki.

Then someone added a spin-off on how to do a 64bit cross-compiler.

But no-one ever touched the bit that says "i586-elf", because it's as good a setting as any other. I'm actually a bit touched by that.

Enough so that I thought I'd write a reply, say "hi" to everybody, do an (unrelated) edit in the Wiki and then be gone again. Nice to see the old faces as well as the new ones. Have fun coding.
Solar ? You're back ?
If a trainstation is where trains stop, what is a workstation ?
Post Reply