How to Build a (powerpc) Cross-Compiler in Ubuntu 12.04

Mar 26, 2012 19:20

This is a rough script of what I did to build a powerpc cross compiler in Ubuntu 12.04. In theory it should work for just about any other machine type, though I wouldn't bet money on that. (FYI: They have armel packages in the repos for some reason...)


$ mkdir packages

# binutils
$ apt-get source binutils
$ export DEB_PACKAGE_BUILD_OPTS=parallel=8
$ export TARGET=powerpc-linux-gnu
$ cd binutils*
$ dpkg-buildpackage -b -uc -us -rfakeroot 2>&1 | tee ../binutils.build
$ cd ..
$ mv binutils-powerpc-linux-gnu_*.deb packages
$ dpkg -i packages/binutils-powerpc-linux-gnu_*.deb

# libc6/libgcc cross insanity
$ cd fakepackages
* Download the following *POWERPC* packages:libc6-ppc64 libc6-dev-ppc64 linux-libc-dev libc6 libc6-dev libgcc1
$ apt-get install dpkg-cross
$ dpkg-cross -M -a powerpc -b *.deb -X tzdata -X libc-dev-bin -X libc-bin -X multiarch-support -X gcc-4.6-base
$ dpkg -i libgcc1-powerpc-cross_*.deb libc6-dev-powerpc-cross_*.deb libc6-dev-ppc64-powerpc-cross_*.deb libc6-powerpc-cross_*.deb linux-libc-dev-powerpc-cross_*.deb libc6-ppc64-powerpc-cross_*.deb
* Fix up the paths in /usr/powerpc-linux-gnu/lib/libpthread.so /usr/powerpc-linux-gnu/lib/libc.so /usr/powerpc-linux-gnu/lib64/libpthread.so /usr/powerpc-linux-gnu/lib64/libc.so
$ cp libc6-dev-powerpc-cross_*.deb libc6-dev-ppc64-powerpc-cross_*.deb libc6-powerpc-cross_*.deb linux-libc-dev-powerpc-cross_*.deb libc6-ppc64-powerpc-cross_*.deb ../packages/
$ cd ..

# gcc
$ apt-get source gcc-4.6
$ #export DEB_CROSS=yes # Not needed, picked up automatically (I guess)
$ #export DEB_CROSS_NO_BIARCH=yes # NO! this disables ppc64 compiler!
$ export GCC_TARGET=powerpc
$ export LD_LIBRARY_PATH=/lib/x86_64-linux-gnu # Fixes dh script error at the end of build
$ cd gcc-4.6*
$ fakeroot debian/rules control
$ dpkg-buildpackage -b -uc -us -rfakeroot 2>&1 | tee ../gcc.build
$ cd ..
$ mv *.deb packages/
$ dpkg -i packages/cpp-4.6-powerpc-linux-gnu_*.deb packages/gcc-4.6-multilib-powerpc-linux-gnu_*.deb packages/gcc-4.6-powerpc-linux-gnu_*.deb packages/gcc-4.6-powerpc-linux-gnu-base_*.deb packages/lib64gcc1-powerpc-cross_*.deb packages/lib64gomp1-powerpc-cross_*.deb packages/libgcc1-powerpc-cross_*.deb packages/libgomp1-powerpc-cross_*.deb

# eglibc (you can skip this part)
$ apt-get source eglibc
$ cd eglibc-*
$ dpkg-buildpackage -b -uc -us -rfakeroot -B -apowerpc 2>&1 | tee ../eglibc.build
$ cd ..
$ mv *.deb fakepackages/
* FIXME: Somehow produce libc6-ppc64 packages?
* Rerun the libc6/libgcc cross insanity step above.

# Now you should have cross compiler packages in packages/
Previous post Next post
Up