world leader in high performance signal processing
Trace: » canadian-cross

Canadian Cross-Compiling

This topic covers how to cross-compile the Blackfin toolchain to run on a different system. The process involves cross-compiling the cross-compiler so that it is built on one architecture to run on a different architecture while targeting yet another architecture. This is the Canadian aspect (three different parties).

For example, you may want to cross-compile the toolchain on a Linux machine so that it will run in Windows:

  • Build machine: Linux running on a fast PowerPC machine
  • Host machine: Windows running on a fast Intel machine
  • Target machine: Linux running on a fast Blackfin board

While the example here covers Windows as the target operating system, the methodology is the same regardless. So you could apply these steps to cross-compile the Blackfin toolchain to run under AIX, Solaris, BeOS, or whatever operating system happens to catch your fancy.


This process can be broken down into the following steps:

  • Get working toolchain that targets the desired host system
  • Build Blackfin toolchain
  • Cross-compile the Blackfin toolchain using the above two toolchains in conjunction

Obtaining The Hosted Cross-Compiler

The first thing you need is a cross-compiler to target the architecture you wish to run on. For Windows, this is a toolchain that is probably from the MinGW guys. Note that this step is left as an exercise for the user (aka you) due to the fact that none of this software is managed by the Blackfin Linux Team. Often times, distros will include packages so you can easily install it.

Once you've acquired the necessary toolchain, let's move on to the next step.

Building Current Blackfin Toolchain

We have to build up the current sources to get a current Blackfin toolchain which will be used to cross-compile the final toolchain. We have more articles that cover this in depth, so please refer to them:

Once you have the new Blackfin toolchain, let's move on to the next step.

Canadian Cross-Compiling The Blackfin Toolchain

The last step here is much like the previous step. First make sure the two cross-compilers discussed above are in your PATH environment variable. Then just invoke the BuildToolChain script with the same arguments as previously, except give it different output paths so as to not overwrite your previous build. The final key is the -H option. This is how you inform the build system to cross-compile the Blackfin toolchain to run on a different system.

If you fetched the default MinGW toolchain for Windows, you probably want to give it the host value of mingw:

$ ./BuildToolChain ... -H mingw ...

Basically you replace this value with the leading prefix of your cross-compiler. For example, if you invoke mingw-gcc, then you want mingw. If you invoke i386-pc-mingw-gcc, then you want i386-pc-mingw.

If all goes well, you should be left with toolchains that you can package up and distribute.

Extra Package Checklist

Depending on your cross target, you may want to make sure you have these packages available:

Current Caveats

Case Insensitive Filesystems

Many common filesystems are case-preserving but case-insensitive. That means the filesystem remembers when you name something foo versus Foo, but it considers the names to refer to the same file. Some of the kernel headers install different files that differ merely in case and so when installing onto such systems, these files will clobber each other. For example, much of the include/linux/netfilter/ files use the convention ipt_FOO.h and ipt_foo.h. Generally this shouldn't cause too much trouble as these headers are not used by most applications, but it is something to keep in mind.

No Win64 GCC-4.1

We have no plans to get a 64-bit build of gcc-4.1 working. All of the required changes are merged in gcc-4.3 and while it would be possible to backport everything to gcc-4.1, the inordinate amount of time/effort required would not justify the means; especially since we have moved to gcc-4.3+ as our stable toolchain base and the 32-bit build of gcc-4.1 works fine.

So, just to be clear, this issue applies only to building a 64-bit version of gcc-4.1 to work on 64-bit Windows. A 32-bit version works just fine on both 32-bit and 64-bit Windows.

Insight Bombs

The mainline Insight project has not fully integrated all required MinGW code. Until that happens, Insight for Windows will probably remain broken.


A common cross target is Windows. If cross-compiling the dependencies is a hassle for you, you can try this simple script: Build Win32 Dependencies