(barebones tutorial)build cross compiler to target i386 or i
(barebones tutorial)build cross compiler to target i386 or i
I just recently started the barebones tutorial and have built the cross compiler following the steps described here:
http://wiki.osdev.org/GCC_Cross-Compiler#Preparation
In the preparation section of that guide, it suggests to do the following: 'export TARGET=i686-elf'.
I was wondering why they did not say 'export TARGET=i386-elf' if we will be using qemu-system-i386 to test the kernel?
http://wiki.osdev.org/GCC_Cross-Compiler#Preparation
In the preparation section of that guide, it suggests to do the following: 'export TARGET=i686-elf'.
I was wondering why they did not say 'export TARGET=i386-elf' if we will be using qemu-system-i386 to test the kernel?
- Love4Boobies
- Member
- Posts: 2111
- Joined: Fri Mar 07, 2008 5:36 pm
- Location: Bucharest, Romania
Re: (barebones tutorial)build cross compiler to target i386
GCC's i686 target uses a generic instruction set, which the GCC developers considered to be a reasonable common denominator for a particular version of the compiler, and can also be instructed to also generate P6-specific instructions using the -march option. QEMU's i386 target actually supports emulation for many 32-bit x86 CPU's. You can find out what these are with -cpu help.
The tutorial was simply designed to use things that are as generic as possible. You will likely want to figure out what your OS' requirements are and change your targets accordingly.
The tutorial was simply designed to use things that are as generic as possible. You will likely want to figure out what your OS' requirements are and change your targets accordingly.
"Computers in the future may weigh no more than 1.5 tons.", Popular Mechanics (1949)
[ Project UDI ]
[ Project UDI ]
Re: (barebones tutorial)build cross compiler to target i386
Both refer to 32-bit code (as opposed to "x86_64" for 64-bit code). "i386" is generic, whereas "i686" refers to a newer model. Unless your computer is very old "i686" is the correct choice as it will produce the most efficient code. The 32-bit version of qemu is called "qemu-system-i386"; whether that means it will run on all processors since, and including, the 80836 I don't know.
- Love4Boobies
- Member
- Posts: 2111
- Joined: Fri Mar 07, 2008 5:36 pm
- Location: Bucharest, Romania
Re: (barebones tutorial)build cross compiler to target i386
Did you really have to repeat what I said and add inaccuracies while you were at it? There is "generic", "i386", and "i686". The latter is identical to the former unless P6-specific instructions are explicitly enabled on the command line. And unless his CPU is ancient, he can likely afford other instruction sets as well, such as MMX, SSE's, etc.
"Computers in the future may weigh no more than 1.5 tons.", Popular Mechanics (1949)
[ Project UDI ]
[ Project UDI ]
- xenos
- Member
- Posts: 1121
- Joined: Thu Aug 11, 2005 11:00 pm
- Libera.chat IRC: xenos1984
- Location: Tartu, Estonia
- Contact:
Re: (barebones tutorial)build cross compiler to target i386
Looking at GCC's source code, it seems that also i786 is supported as a target architecture, but I couldn't figure out whether it adds anything, or has any effect that would distinguish it from i686. Also it's not listed in the documentation. Nevertheless, it seems to work fine (but I haven't actually compared with i686).
Re: (barebones tutorial)build cross compiler to target i386
nkp, I'm one of the people behind the switch to i686-elf as the default. The previous posters are accurate. You can use whatever you want for bare bones; this is a case where there's one name for an architecture (i386) and there's several generations within that architecture (i686 for instance). These are the names used by the GNU config project that maintain a huge set of these target triplets, and they don't really correspond to official names by Intel / AMD. Namng is one of the hardest things in computer science.
i786-elf is not a supported or existing target. The config.sub file just happens to accept it because it probably parses any digit in that place. I looked into this issue carefully once and I can state with certainty that i786-* is not a legitimate target triplet. (Somebody thought it was i7 processors and I took the time to debunk that thoroughly).
i786-elf is not a supported or existing target. The config.sub file just happens to accept it because it probably parses any digit in that place. I looked into this issue carefully once and I can state with certainty that i786-* is not a legitimate target triplet. (Somebody thought it was i7 processors and I took the time to debunk that thoroughly).
- xenos
- Member
- Posts: 1121
- Joined: Thu Aug 11, 2005 11:00 pm
- Libera.chat IRC: xenos1984
- Location: Tartu, Estonia
- Contact:
Re: (barebones tutorial)build cross compiler to target i386
Thanks sortie for explaining!
Re: (barebones tutorial)build cross compiler to target i386
Do you really want to know?nkp wrote:I was wondering why they did not say 'export TARGET=i386-elf' if we will be using qemu-system-i386 to test the kernel?
Back then (and the tutorial is actually much older even, somewhat around 2001 if memory serves), I looked at the Intel manuals, at what features were introduced with what CPU generation, and considered the i586 (yes, i586...) to be a good trade-off between backward compatibility and feature set. That was my decision, for my project (Pro-POS), but since I was the one maintaining the tutorial back then, I just copy-and-pasted my decision to the Wiki.
Don't ask me what those i586 features were, specifically. Something concerning the MMU, I think. But I intended to use those features in my OS, so it wouldn't run on anything older than i586, so I saw no sense in having the compiler toolchain support anything older.
Somewhere down the line (in 2014...), the recommendation was "upgraded" to i686, because no-one really needed i586 compatibility anymore. (Virtually all Linux distributions use i686 as the baseline for their 32bit distributions, for example.)
Every good solution is obvious once you've found it.
- Love4Boobies
- Member
- Posts: 2111
- Joined: Fri Mar 07, 2008 5:36 pm
- Location: Bucharest, Romania
Re: (barebones tutorial)build cross compiler to target i386
Historical notes aside, I think the OP was really confused about the i686 vs i386, which looked to him like they were targeting different things. i586 was what Solar considered to be a suitable minimum requirement for his OS, i686 is what the GCC developers consider to be a suitable default requirement in general (since i686 is the same as generic, unless used with -march, which can change from version to version).
"Computers in the future may weigh no more than 1.5 tons.", Popular Mechanics (1949)
[ Project UDI ]
[ Project UDI ]
- xenos
- Member
- Posts: 1121
- Joined: Thu Aug 11, 2005 11:00 pm
- Libera.chat IRC: xenos1984
- Location: Tartu, Estonia
- Contact:
Re: (barebones tutorial)build cross compiler to target i386
Sorry for coming back to this once more. Just for fun, I compiled gcc / binutils / newlib / gdb for both i686-elf and i786-elf, and I expected that they would be identical (apart from having i686 / i786 somewhere hard coded in the binaries). This expectation came from grepping the gcc source for i686 vs. i786, which showed no difference, and indeed the gcc binaries are identical. However, the binutils binaries are not, and grepping through the source shows that most of it accepts only i686, but no i786. So I can confirm that i786 is not a supported target.sortie wrote:i786-elf is not a supported or existing target. The config.sub file just happens to accept it because it probably parses any digit in that place. I looked into this issue carefully once and I can state with certainty that i786-* is not a legitimate target triplet. (Somebody thought it was i7 processors and I took the time to debunk that thoroughly).
@sortie: Just out of curiosity, do you happen to have any reference to your original debunking, or recall how you debunked it? No problem if not, I'm already convinced, but I wonder whether there are more ways to debunk it
Re: (barebones tutorial)build cross compiler to target i386
XenOS, check the #osdev logs for 2014-02-07. They are no longer available through the regular logs mechanism as they have been archived, but you can download the archive for 2014 at http://tunes.org/~nef/logs/old/osdev-14.zip. I was using the username sortiecat at the time. Grep for i786.
- xenos
- Member
- Posts: 1121
- Joined: Thu Aug 11, 2005 11:00 pm
- Libera.chat IRC: xenos1984
- Location: Tartu, Estonia
- Contact:
Re: (barebones tutorial)build cross compiler to target i386
Thanks, that really clarifies everything And this is what I thought, too.