Cross Compiler w/ Multiple Target Support

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.
Post Reply
Jeffrey
Posts: 20
Joined: Fri Jul 27, 2007 1:35 pm
Location: Virginia, USA

Cross Compiler w/ Multiple Target Support

Post by Jeffrey »

Alright, I have already built a i586-elf binutils and GCC cross compiler, but I want to be able to cross compile with the option of multiple targets, and not just one. My question is this, when I rebuild the cross compiler, am I able to pass comma separated targets in the --targets= variable, or is there another way I must do this?

I think I am right on this one, but I just wanted to check and make sure before I start the build, so here is an example of what I am talking about.

Code: Select all

export TARGET=i586-elf,ia64-elf,arm-elf
User avatar
JamesM
Member
Member
Posts: 2935
Joined: Tue Jul 10, 2007 5:27 am
Location: York, United Kingdom
Contact:

Post by JamesM »

I didn't believe (correct me on this one guys) that a compilation of gcc could support multiply-architectured backends. I do believe that is the entire reason you build a cross compiler in the first place - your current one wasn't built for $TARGET.
Craze Frog
Member
Member
Posts: 368
Joined: Sun Sep 23, 2007 4:52 am

Post by Craze Frog »

You need to build several toolchains, one for each target. Then you can use TARGET= and gcc will find the toolchain built for that target. You can't build for several targets at once, you need to build them after each other.

If I'm not wrong, the Amsterdam Compiler Kit supports something like that (one front-end, multiple code generators in the same toolchain), but you'd probably still have to build for each target separately.
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Post by Solar »

Actually, it's a bit of everything.

Theoretically, the GCC toolchain could target many different architectures. The basics are all there - the target-specific subdirectories, the -b command line flag...

Actually the whole thing (multiple targets) is pretty darn well untested, and certainly undocumented. I've been running around for ages asking people all over the internet how to make the cross-compiler setup I described in the Wiki in a way that it resides alongside the system compiler in the proper subdirectories, instead of the ugly /cross kludge I've been using. The answer ranged from thunderous silence over "why the f*** should anyone care for that" to "figure it out yourself".

The closest I've seen so far in terms of "true" multiple-target support is Gentoo Linux with the sys-devel/crossdev solution, but even there you have to set your toolchain with a seperate command (gcc-config / binutils-config).
Every good solution is obvious once you've found it.
Craze Frog
Member
Member
Posts: 368
Joined: Sun Sep 23, 2007 4:52 am

Post by Craze Frog »

Solar wrote:Actually, it's a bit of everything.

Theoretically, the GCC toolchain could target many different architectures. The basics are all there - the target-specific subdirectories, the -b command line flag...
But sadly it doesn't work like that. The -b switch only makes gcc look for the other toolchain, which it uses instead of itself. Each toolchain can't be multi-target.

"gcc -b mytarget-elf options" just means gcc executes "mytarget-elf-gcc options" for you. It's actually just a string operation if I understood it correctly. The target is concat'ed in front of all invoked executables.
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Post by Solar »

Yep, and nowhere (at least where I looked) is it said what you have to tell configure or make to make your custom toolchain sit alongside your system toolchain for even -b to work (without the two overwriting each other upon installation etc.).
Every good solution is obvious once you've found it.
Craze Frog
Member
Member
Posts: 368
Joined: Sun Sep 23, 2007 4:52 am

Post by Craze Frog »

If you install the system toolchain first, and then compile a cross-compiling toolchain by following a tutorial they won't overwrite each other. But I don't know how to use it with make.
Post Reply