top | item 7501110

(no title)

warsheep | 12 years ago

You probably already know this, but setting up a cross-compiler toolchain is a super annoying task, and is very dependent on the distro you're using. I'm sure the author knows about cross-compiling, but he probably preferred clear instructions that work for any RPi user.

There might be even stronger reasons to not use cross-compilers such as weird bugs or compiler version compatibility issues.

discuss

order

pjc50|12 years ago

Indeed. Either you give distro-specific instructions (long) or you make people build a gcc cross-compiler from scratch (also long) or you gloss over that bit (prone to failure).

Many Pi users' only linux system is the Pi.

joezydeco|12 years ago

Virtualbox is free. Debian is free. Code Sourcery ARM/GCC Lite is free. I've set up ARM crosscompile environments this way in under an hour. This isn't really a superhard thing to do.

[EDIT] Vendors do this too. I went to a workshop on the Freescale i.MX line and guess how everyone got the development system? A VMware image on a thumb drive. You don't have to be a hero when it comes to cross-compiling, just get the work done.

ihnorton|12 years ago

> cross-compiler from scratch (also long)

Building GCC shouldn't take more than a couple hours on a modern machine, and it's a one-time cost for a drastic speedup of every subsequent RPi build. So the aggregate time should still be considerably less than 12 hours.

captainmuon|12 years ago

I wonder why its so hard? I once built a modern gcc + glibc in my home directory on an older linux (to be able to run modern programs), and it was mostly "relocatable" or "portable" (what I mean is that you could copy it around and run it from other directories).

Couldn't somebody build a full cross-compiler toolchain as "relocatable" binaries, depending on an older kernel, and then just offer that as a binary download to run on most recent distributions? It's not a typical way to distribute a linux application, but it should work in principle.

sarnowski|12 years ago

I suggest looking at LinuxFromScratch[0], especially II.5. It's hard to do a "real" cross-platform compiler because your target system might not only be a different architecture but also has different libraries on the system with which the compiler has to work. All in all, doing it right and being able to ship binaries is a lot of work and constant maintenance as your target system, in this case Raspbian, also changes their libraries.

[0] http://www.linuxfromscratch.org/lfs/view/stable/

raverbashing|12 years ago

Some issues:

Your GCC build has to match the userspace C library (uclibc or other). If it doesn't you'll need to do all the path passing and usually link manually as well.

It has also to match the kernel somewhat (not so critical for userspace apps, but if you want to add a module or something it's critical)

So, basically what you "should do" is build the whole system together (cross-compiler + userspace + kernel), some tools do that, building first a "raw" cross-compiler, then the C library and kernel, then a full compiler with all the options applied.

jevinskie|12 years ago

I use crosstool-ng to do the heavy lifting for me. [0] But lately I've been trying out musl-cross to get nice, self-contained static binaries. [1]

[0]: http://crosstool-ng.org/

[1]: https://bitbucket.org/GregorR/musl-cross

Crito|12 years ago

Crosstool-ng is nice, but if you have even a mildly out of the ordinary arch/libc/kernel version/etc combination it is still a massive pain in the ass. Typically I'd rather build the kernel on device overnight instead of spend manhours getting crosstool-ng to work as I want so that I can build on beefy hardware.

It tends to only be worth it if you are going to be using it more than a few times.

astrodust|12 years ago

Wouldn't an emulator actually be faster on high-end hardware? Then you can run native tools at much faster than Pi execution speed, right?

raverbashing|12 years ago

"You probably already know this, but setting up a cross-compiler toolchain is a super annoying task"

Yes, I agree 100%, building a cross-compiler is a very complicated task.

But I think with the weight of the Raspberry Pi projects this should have been easier. This is a good project http://buildroot.uclibc.org but unfortunately it's very unstable.