Cross compiler with Distcc (in Gentoo/Funtoo)
It's Wednesday!!, it's time for a friki post :D. As every average Gentoo user knows. Build a new System for personal use could be a task for two or three days and most of the time the PC is building the packages. I have a powerfull processor (core i7 860) and a crappy processor (celeron M). The last year my main PC was a pentium 4 desktop pc and it has the same architecture as the celeron M (intel prescott i686). But now that desktop It's a personal server in the living room with xubuntu. Later I installed Debian testing (Squeeze) in my laptop because I needed a stable distro. Actually I don't need it and it's time to go back to Funtoo flexibility (thanks for all Debian). I look a bit in Google and I found crossdev. When you need build packages for an architecture different from yours you need to crosscompile. In other words you need the complete toolchain ready to run in your system and ready to build packages for another architecture. Crossdev it's a tool that simplify the process off build that toolchain and have the right compilers. Gentoo also have an excelent wiki about using crossdev but I found a series of issues that the documentation doesn't mention. So let's see the experiment. The Scenario: Laptop: architecture: i686, Funtoo i686 unstable, ip: 192.168.2.1 Desktop: architecture amd64, Funtoo amd64 unstable, ip: 192.168.2.2 I will compile packages from and for the laptop using the laptop only as a build host. Step 1: Install crossdev I need crossdev in the amd64 host because the final destination is the laptop with the i686 architecture. So . .
emerge crossdevAnd thats all. Step 2: Build the toolchain Now the wiki suggest the basic crossdev command:
# crossdev -t i686-pc-linux-gnuBut the issues starts. In funtoo unstable, as the name suggest all is instaled in his last and less tested version. So in the first (and second, and third) attempt *sigh* the build fails. The problem was an incorrect combination of libc, gcc and binutils. So after one more attempt I found the right shell command:
# crossdev --l 2.10.1-r1 --g 4.3.3-r2 -s4 --ex-gcc -t i686In the i7 this step was completed in 5 five minutes. The parameters would be different for you. And you can check all the options with:
# crossdev --helpThe --ex-gcc parameter it's necesarry beause builds the extra tools for gcc (and the important g++). Without this the distributed compilation will not work (because you will not have an i686-pc-linux-gnu-g++ executable). Step 3: Check the configuration If the toolchain is ready check the gcc configuration in Gentoo you have gcc-config
gcc-config -lIf you see something similar to this. Hey it's ready!!:
 i686-pc-linux-gnu-4.3.3 *  x86_64-pc-linux-gnu-4.3.3  x86_64-pc-linux-gnu-4.4.3 *Step 4: Distcc The steps are the same that the Gentoo Handbook Distcc Crosscompile guide. Here. So that's all, be happy building 🙂