piyo's computer tips
2004/03/21
Using distcc and Windows Cygwin cross-compiling with gentoo 2004.0
Linux, Windows

I've installed gentoo linux 2004.0 from stage 1 on my VIA EPIA computer and compiling sure is dog-slow. Enter distcc which should be able to use the spare cycles on my other computers. Trouble is that those other computers use windows. What we need is to install a cross-compiler on the windows machines.

This page seems to be the most relevant information. However, you have to read all of it to optimize for your environment. I rather create something right now that targets my Gentoo 2004.0 box, so I wrote this. Gentoo 2004.0 doesn't use the same versions for binutils and gcc, though, so adjustments are necessary.

bintools-2.14
gcc-3.2.3
glibc-2.3.2

Why should you need to build glibc when it should already be built correctly on your target system? Because it will have the wrong paths when you put in on your cygwin system, that's why. Nevertheless, the correct paths inserted without recompilation (crosses fingers). Begin by extracting your gentoo linux glibc.


linux% mkdir ${HOME}/build && cd ${HOME}/build
linux% equery -q files glibc | sed 's/ -> .*$//g' | while read line ; do if [[ ! -d "$line" ]] ;then echo $line ; fi ; done | tee glibc.equery-files-only
linux% tar cf - --files-from=./glibc.equery-files-only | tar xf -
linux% ( cd lib ; tar cf - . ) | ( cd usr/lib ; tar xvf - )
linux% cd usr/include
linux% (cd /usr/include ; tar cf - linux) | tar xf -
linux% (cd /usr/include ; tar cf - asm) | tar xf -


We're done with the gentoo linux computer for now. Next start working on the windows computer.


cygwin% cat > envvars
host=i686-pc-cygwin
build=i686-pc-cygwin
target=i686-pc-linux-gnu
prefix=/usr/local/linux
srcdir=${HOME}/src/
builddir=${HOME}/build/
^D
cygwin% source envars



cygwin% # next copy over the linux libs
cygwin% mkdir -p $prefix/$target
cygwin% cd $prefix/$target
cygwin% ssh root@linuxbox '( cd ${HOME}/build/usr ; tar cf - . )' | tar xf -


You need to edit your libc.so file to reference the cross compile lib directory ($prefix/$target/lib). In other words, if your libc.so looks like this:
/* GNU ld script
Use the shared library, but some functions are only in
the static library, so try that secondarily. */
OUTPUT_FORMAT(elf32-i386)
GROUP ( /lib/libc.so.6 /usr/lib/libc_nonshared.a )


make it look like this
/* GNU ld script
Use the shared library, but some functions are only in
the static library, so try that secondarily. */
OUTPUT_FORMAT(elf32-i386)
GROUP ( /usr/local/linux/i686-pc-linux-gnu/lib/libc.so.6 /usr/local/linux/i686-p
c-linux-gnu/
lib/libc_nonshared.a )



cygwin% # you need to edit your libc.so file to reference the cross compile lib directory
cygwin% vim $prefix/$target/lib/libc.so


cygwin% # make your binutils
cygwin% mkdir -p $builddir/binutils
cygwin% cd $builddir/binutils
cygwin% $srcdir/binutils-2.14/configure --with-included-gettext --target=$target --host=$host --build=$build --prefix=$prefix -v
cygwin% make 2>&1 | tee make.log
cygwin% make install 2>&1 | tee install.log
cygwin% export PATH=$PATH:$prefix/bin

cygwin% # make your gcc
cygwin% mkdir -p $builddir/gcc
cygwin% cd $builddir/gcc
cygwin% $srcdir/gcc-3.3.2/configure --enable-languages=c,c++ --with-included-gettext --enable-shared --enable-threads=posix --with-headers=${prefix}/i686-pc-linux-gnu/include/ --target=$target --host=$host --build=$build --prefix=$prefix -v
cygwin% make 2>&1 | tee make.log
cygwin% make install 2>&1 | tee install.log
cygwin%


If gcc compiles correctly, you're home free.

It works as of now. I tried installing a sample package such as vi (emerge vi) and it was using the Cygwin host like a charm. But there are some packages that don't work. I tried installing a sample package like screen, but it failed at linking. This is using just localhost. Heh. If you set your /etc/make.conf FEATURES variable to include distcc, you can disable it one time like this:

FEATURES="-distcc" emerge screen

There is also the promise of crosstool 0.28. Maybe it will make using distcc on cygwin easy.

src: http://distcc.samba.org/faq.html#cross-compile
src: http://www.xraylith.wisc.edu/~khan/software/gnu-win32/cygwin-to-linux-cross-howto.txt
 
How I keep remembering new ways of using computers. My (computer-centric) new-optimization learning blog.

Name:
Location: Kobe, Hyogo, Japan
September 2003 / October 2003 / December 2003 / March 2004 / April 2004 / May 2004 / June 2004 / July 2004 / August 2004 / September 2004 / February 2005 / March 2005 / April 2005 / May 2005 / June 2005 / July 2005 / August 2005 / September 2005 / December 2005 / January 2006 / February 2006 / March 2006 / April 2006 /


Powered by Blogger