I have finally gotten a Makefile that produces an install-able, working gcc package. You can get the package here
https://www.dropbox.com/s/gdgjpmz845o5xl2/gcc_4.6.2-1_ar71xx.ipk It is big, over 60mB and there are probably some issues that still need to be taken care of so please try it and let me know if it works for you.
@federico - one of the last things I found was that if you let openwrt strip the files compiling on the Yun chokes at the linking stage because it can't find symbols it needs.
To try it follow these steps:
1. Put an sd card in the Yun and run the diskSpaceExpander sketch
http://arduino.cc/en/Tutorial/ExpandingYunDiskSpace , I am using a 16 gig sdcard with 10000 Mb data partion leaving 6 gig for the system.
2. Install binutils
root@Arduino:~# opkg update
Downloading http://downloads.arduino.cc/openwrtyun/1/packages/Packages.gz.
Updated list of available packages in /var/opkg-lists/attitude_adjustment.
Downloading http://downloads.arduino.cc/openwrtyun/1/packages/Packages.sig.
opkg install Signature check passed.
root@Arduino:~# opkg install binutils
Installing binutils (2.22-5) to root...
Downloading http://downloads.arduino.cc/openwrtyun/1/packages/binutils_2.22-5_ar71xx.ipk.
Installing objdump (2.22-5) to root...
Downloading http://downloads.arduino.cc/openwrtyun/1/packages/objdump_2.22-5_ar71xx.ipk.
Configuring objdump.
Configuring binutils.
root@Arduino:~#
3. Copy the ipk to your data partition. On linux I use:
scp gcc_4.6.2-1_ar71xx.ipk arduino.local:/mnt/sda1
4. Install gcc, this takes a LONG time so be patient.
root@Arduino:~# opkg install /mnt/sda1/gcc_4.6.2-1_ar71xx.ipk
Installing gcc (4.6.2-1) to root...
Configuring gcc.
root@Arduino:~#
5. Give it a source file named hello.c to compile, this works:
#include <stdio.h>
void main(void)
{
printf("%s","hello world\n");
}
6. Compile it
root@Arduino:~# gcc -fno-use-linker-plugin -msoft-float hello.c -o hello
hello.c: In function 'main':
hello.c:5:5: warning: incompatible implicit declaration of built-in function 'printf' [enabled by default]
root@Arduino:~#
7. run the executable:
root@Arduino:~# ./hello
hello world
root@Arduino:~#
8. Yes it is slow:
time gcc -fno-use-linker-plugin -msoft-float hello.c -o hello
hello.c: In function 'main':
hello.c:5:5: warning: incompatible implicit declaration of built-in function 'printf' [enabled by default]
real 0m 0.53s
user 0m 0.34s
sys 0m 0.10s
I need to clean up the makefile and then I'll put in a pull request to the yun repository so it can be built by anyone who wants to.