GCC Cross-Compiler

All about the OSDev Wiki. Discussions about the organization and general structure of articles and how to use the wiki. Request changes here if you don't know how to use the wiki.
Post Reply
ecco
Posts: 19
Joined: Mon Nov 29, 2010 1:21 am
Location: Anchorage, AK

GCC Cross-Compiler

Post by ecco »

Am I missing something or should this:
export PATH=$PATH:$PREFIX/bin

be changed to
export PATH=$PREFIX/$TARGET/bin:$PATH

I'm pretty sure if the newly compiled binutils is to override the system version it needs to be before the rest of the current path and furthermore point to version of the files without the prefix...
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: GCC Cross-Compiler

Post by Combuster »

No, you shouldn't. Configure looks for both a host and target toolchain, so it wants specifically a i686-pc-cygwin-as, and a i586-elf-as when it looks for the GNU assembler. if you add prefix/bin, it can find i586-elf-as. if you add prefix/target/bin, there's only as, and it comes later in the path than the host assembler which also uses that name, so you will start to miss out on one. And worse: you will break everything that expects gcc/as/ld without prefix to be the host toolchain.

Also, that tutorial exists practically unchanged for over 5 years now, do you honestly believe it was broken all that time?
"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 ]
ecco
Posts: 19
Joined: Mon Nov 29, 2010 1:21 am
Location: Anchorage, AK

Re: GCC Cross-Compiler

Post by ecco »

No I know it works because I've done it many times, the tutorial just doesn't explain what you just did...
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: GCC Cross-Compiler

Post by Combuster »

the tutorial just doesn't explain what you just did...
Not in that wording, but you did draw a contradictory conclusion:
You wrote:(...) if the newly compiled binutils is to override the system version (...)
The wiki wrote:(...) so that gcc invokes your system compiler, and $TARGET-gcc invokes your cross-compiler. (...)
The section from which I got that last quote (briefly) explains why the tutorial does it that way, but you can't really expect a tutorial to cover for each possible deviation why they do not do it that other way: that's most often a reader's exercise or author's taste, if not both.
"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 ]
ecco
Posts: 19
Joined: Mon Nov 29, 2010 1:21 am
Location: Anchorage, AK

Re: GCC Cross-Compiler

Post by ecco »

Combuster wrote:that's most often a reader's exercise
I agree, consider this part of my "reader's exercise" to acquire further information.
Post Reply