Page 1 of 2

Why i586-elf?

Posted: Mon Mar 03, 2014 1:02 pm
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?

Re: Why i586-elf?

Posted: Mon Mar 03, 2014 1:47 pm
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.

Re: Why i586-elf?

Posted: Mon Mar 03, 2014 1:49 pm
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.

Re: Why i586-elf?

Posted: Mon Mar 03, 2014 1:52 pm
by Binero
I'm guessing from the comments, there isn't really any reason to not use x86_64 but backwards compatibility?

Re: Why i586-elf?

Posted: Mon Mar 03, 2014 3:02 pm
by Combuster
Other than the fact that you need non-64-bit code somewhere to get to 64-bit :wink:

Re: Why i586-elf?

Posted: Mon Mar 03, 2014 4:56 pm
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?

Re: Why i586-elf?

Posted: Tue Mar 04, 2014 1:25 am
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.

Re: Why i586-elf?

Posted: Tue Mar 04, 2014 1:32 am
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.

Re: Why i586-elf?

Posted: Tue Mar 04, 2014 3:58 am
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.

Re: Why i586-elf?

Posted: Tue Mar 04, 2014 5:48 am
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

Re: Why i586-elf?

Posted: Fri Mar 21, 2014 10:09 am
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.

Re: Why i586-elf?

Posted: Fri Mar 21, 2014 10:43 am
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.

Re: Why i586-elf?

Posted: Sat Mar 22, 2014 9:28 am
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.

Re: Why i586-elf?

Posted: Sat Mar 22, 2014 11:10 am
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.

Re: Why i586-elf?

Posted: Sat Mar 22, 2014 4:43 pm
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 ?