Page 1 of 1

Cross Compiler w/ Multiple Target Support

Posted: Fri Sep 28, 2007 10:00 am
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

Posted: Fri Sep 28, 2007 10:24 am
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.

Posted: Fri Sep 28, 2007 10:36 am
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.

Posted: Fri Sep 28, 2007 11:32 am
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).

Posted: Fri Sep 28, 2007 1:56 pm
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.

Posted: Fri Sep 28, 2007 3:39 pm
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.).

Posted: Sat Sep 29, 2007 3:30 am
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.