Wednesday, February 25, 2009

mips64el-unknown-linux-gnu cross toolchain building

NOTE: I just updated the command at the bottom, again. No big change. Now all should be good to go, including building on PS3, which is big endian.

Crossdev is a great tool. Thanks to vapier.
However, it may not work in all circumstances, although the problems may not lie in crossdev itself. For example, when creating mips64el-unknown-linux-gnu cross toolchain.
The problems happen when building glibc headers. Because at that time, we don't have cross gcc yet. So some gcc options only cross gcc supports or some macros only cross gcc defines can't be used.
Also happen when building gcc on big endian machines. Because of the erroneous LD_LIBRARY_PATH setting, cc1 generated in stage 1 will try to load libgcc_s.so.1 generated in stage 1, which is little endian.
So I made some work-arounds. These are the three patches needed:
one patch to src_compile.eblit
a second patch to src_install.eblit
a third patch to gcc ebuild
These are all small changes, but took me a lot of time to investigate.

To use it, just run the following commands:
cd
git clone git://www.gentoo-cn.org/var/git/loongson.git
mkdir cross-overlay
cd cross-overlay
mkdir profiles
echo 'cross-overlay' > profiles/repo_name
ln -sf ../loongson/sys-libs
sed -i -e '/PORTDIR_OVERLAY/ s/"$/ ${HOME}\/cross-overlay"/' /etc/make.conf
crossdev -t mips64el-unknown-linux-gnu --b 9999 --g 4.4.0_pre9999 --l 2.9_p20081201-r2 --k 2.6.27-r2 -v

Labels: ,