Crosstool Toolchains on scratchbox 1.0.2

Notice: These instructions depreceated on Scratchbox Apophis and newer.

The rest of the page is also a terrible mess.. please split out to separate document if there is something worth saving.

{{{ a livecd scratchbox-multiCpu is available at

Most binaries for the toolchains described below can be downloaded from

{{{ snapshot

This page describes how to build a scratchbox toolchain using [http://kegel.com/crosstool Dan Kegel's crosstool] This example will take you through the building of a toolchain to target an xscale processor in big-endian mode.

Preparing scratchbox

Change the group ownership of /scratchbox/compilers to sbox. This will give your scratchbox user write access to this directory.

vesuvius@pompeii:~$ sudo chgrp sbox /scratchbox/compilers

Enter scratchbox and make sure you have scratchbox configured to use the HOST target:

vesuvius@pompeii:~$ sb-conf se HOST
vesuvius@pompeii:~$ scratchbox
[sbox-HOST: ~] >

Preparing crosstool

Download [http://kegel.com/crosstool crosstool]

[sbox-HOST: ~] > wget http://kegel.com/crosstool/crosstool-0.38.tar.gz
[sbox-HOST: ~] > tar xzf crosstool-0.38.tar.gz
[sbox-HOST: ~] > cd crosstool-0.38

Crosstool 0.38 didn't have support for gcc-3.4.5 yet, but I found that my toolchain worked by copying gcc-3.4.4 patches. YMMV:

[sbox-HOST: ~/crosstool-0.38] > cd patches
[sbox-HOST: ~/crosstool-0.38/patches] > cp -a gcc-3.4.{4,5}
[sbox-HOST: ~/crosstool-0.38/patches] > cd ..

I created a gcc-3.4.5-glibc-2.3.5-hdrs-2.6.11.2.dat file:

[sbox-HOST: ~/crosstool-0.38] > cat gcc-3.4.5-glibc-2.3.5-hdrs-2.6.11.2.dat
BINUTILS_DIR=binutils-2.15
GCC_DIR=gcc-3.4.5
GLIBC_DIR=glibc-2.3.5
LINUX_DIR=linux-2.6.15
LINUX_SANITIZED_HEADER_DIR=linux-libc-headers-2.6.11.2
GLIBCTHREADS_FILENAME=glibc-linuxthreads-2.3.5

And I created a demo-sbox-armv5b-softfloat.sh script:

[sbox-HOST: ~/crosstool-0.38] > cat demo-sbox-armv5b-softfloat.sh
#!/bin/sh
set -ex
TARBALLS_DIR=$HOME/downloads
RESULT_TOP=/scratchbox/compilers
PREFIX=$RESULT_TOP/armv5b-gcc-3.4.5-glibc-2.3.5
export TARBALLS_DIR RESULT_TOP PREFIX
GCC_LANGUAGES="c,c++"
export GCC_LANGUAGES

mkdir -p $RESULT_TOP
unset LD_LIBRARY_PATH
# Build the toolchain.  Takes a couple hours and a couple gigabytes.

eval `cat armv5b-softfloat.dat gcc-3.4.5-glibc-2.3.5-hdrs-2.6.11.2.dat` sh all.sh --notest

echo Done.

A couple of things to note in the above script is that $RESULT_TOP must point to /scratchbox/compilers and that the $PREFIX directory must be only one more directory deep under $RESULT_TOP. By default crosstool puts $PREFIX as $RESULT_TOP/$TOOL_COMBO/$TARGET which is two directories down from $RESULT_TOP. The other thing is that crosstool doesn't like having LD_LIBRARY_PATH set during the build, so we unset it before the build starts.

Build the toolchain

Start up the script and wait a couple of hours. The script will take care of downloading needed files if they are not already in $HOME/downloads.

[sbox-HOST: ~/crosstool-0.38] > ./demo-sbox-armv5b-softfloat.sh

Scratchbox post configuration

Once the script has successfully finished, we need to create some additional files to let scratchbox know about the new toolchain.

We need to create some symbolic link files in your compiler's bin directory that scratchbox expects:

[sbox-HOST: ~/crosstool-0.38] > cd /scratchbox/compilers/armv5b-gcc-3.4.5-glibc-2.3.5/bin/
[sbox-HOST: /scratchbox/compilers/armv5b-gcc-3.4.5-glibc-2.3.5/bin] > for f in `ls`; do ln -s $f sbox-$f; done

compiler-name

Create a file compiler-name in your compiler's top directory. Mine looks like this:

[sbox-HOST: /scratchbox/compilers/armv5b-gcc-3.4.5-glibc-2.3.5] > cat compiler-name
armv5b-gcc-3.4.5-glibc-2.3.5:/scratchbox/compilers/armv5b-gcc-3.4.5-glibc-2.3.5:armv5b:softfloat-linux:glibc:armeb

This file is a : delimited file. The fields are as follows as far as I could tell:

  1. Name of the compiler. This name must be exactly the same as the name of directory where this compiler-name file is.
  2. Full path to the compiler directory.
  3. Toolchain's target architecture.
  4. Toolchain's target sub-arch.
  5. glibc or uclibc
  6. qemu emulation

target_setup.sh

Create a target_setup.sh script in your compiler's top directory. Mine looks like this. Replace source appropriately for your setup:

[sbox-HOST: /scratchbox/compilers/armv5b-gcc-3.4.5-glibc-2.3.5] > cat target_setup.sh
#!/bin/sh

target=$1
source=/scratchbox/compilers/armv5b-gcc-3.4.5-glibc-2.3.5/armv5b-softfloat-linux

mkdir -p $target/lib
mkdir -p $target/usr/lib
mkdir -p $target/usr/include
mkdir -p $target/usr/bin

cp -af $source/lib/*                 $target/lib/
cp -af $source/lib/* $target/usr/lib/

cp -af $source/include/* $target/usr/include/

ln -sf /bin/cpp $target/lib/
ln -sf /bin/cc  $target/usr/bin/

chmod +x $target/lib/ld-*.so

gcc.specs

We need to copy the toolchains specs file to where scratchbox expects to see it:

[sbox-HOST: /scratchbox/compilers/armv5b-gcc-3.4.5-glibc-2.3.5] > cp `find . -name specs` gcc.specs

qemu emulation

This part is only needed if scratchbox doesn't have qemu emulation for your arch already but qemu does have support for your arch available. This was the case for me since I needed qemu-armeb.

First of all you'll need write access to get temporary ownership of /scratchbox/tools. Since all directories and files under there are owned by root, it will be easy to revert the ownership back to root when we're done.

vesuvius@pompeii:~$ sudo chown -R vesuvius /scratchbox/tools

Download and build qemu for the needed emulation:

[sbox-HOST: ~] > wget http://www.qemu.com/qemu-0.8.0.tar.gz
[sbox-HOST: ~] > tar xzf qemu-0.8.0.tar.gz
[sbox-HOST: ~] > cd qemu-0.8.0
[sbox-HOST: ~/qemu-0.8.0] > ./configure --prefix=/scratchbox/tools --target-list=armeb-user --static
[sbox-HOST: ~/qemu-0.8.0] > make
[sbox-HOST: ~/qemu-0.8.0] > make install

vesuvius@pompeii:~$ sudo chown -R root /scratchbox/tools

Edit /scratchbox/etc/cputransp-methods to add qemu-armeb to the list.

Issues

One needs to build device_tools namely sbrshd and fakeroot to communicate thru CPU_Transparency with the device and gdbserver for debugging.An example of a realdevice,nslu2_ixp425 with kanotix_debian_scratchbox-1.0 is described at


BuildScratchboxNslu2


0. Intro.

1. install scratchbox :core,lib ,toolchains

Base (required):

Development kits (optional):

Toolchains (optional):

  1. Build device_tools for armeb_target

(needs to communicate/debug thru CPU_transparency with nslu2)

gdbserver,gdb (DDD) Download those src files into /scratchbox/packagesBR Login scratchbox,select HOST then untar src ,select target armeb BRBR



and a "#include "asm/ptrace.h" to signal.c and syscall.cBR

root@laixa:/scratchbox/users/wangji/home/wangji/strace-4.5.11# patch -p0 < patches/arm-syscallent.patchBR patching file strace-4.5.4/linux/arm/syscallent.hBR root@laixa:/scratchbox/users/wangji/home/wangji/strace-4.5.11# patch -p1 < patches/quota.patchBR patching file resource.cBR root@laixa:/scratchbox/users/wangji/home/wangji/strace-4.5.11# patch -p1 < patches/arm-syscall.patchBR patching file linux/arm/syscall.hBR patching file linux/arm/dummy.hBR root@laixa:/scratchbox/users/wangji/home/wangji/strace-4.5.11# patch -p1 < patches/arm-compilation.patchBR patching file syscall.cBR Hunk #1 succeeded at 747 (offset 51 lines).BR root@laixa:/scratchbox/users/wangji/home/wangji/strace-4.5.11# cat patches/arm-syscall.patchBRBR

 [sbox-nslu2: ~/build_strace] > ../strace-4.5.11/configure --build=i386-pc-linux-gnu --host=armv5b-softfloat-linux --target=armv5b-softfloat-linux  

[sbox-nslu2: ~/build_strace] > makeBR [sbox-nslu2: ~/build_strace] > file straceBR strace: ELF 32-bit MSB executable, ARM, version 1 (ARM), for GNU/Linux 2.4.3, dynamically linked (uses shared libs), strippedBRBRBR

Since this strace runs on the nslu2-armeb target ,copy it to TARGET/nslu2/usr/sbin BRBRBR

and daemon sbrshd within target ,say here "nslu2" }}} BRBR


compilation_of_sbrsh


rm -f sbrsh sbrshd sb-exportfs *.oBR [sbox-HOST: ~/sbrsh-7.0] > make sbrshBR [sbox-HOST: ~/sbrsh-7.0] > file sbrshBR sbrsh: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), for GNU/Linux 2.2.0, dynamically linked (uses shared libs), not strippedBRBR


compilation_of_daemon_sbrshd


[sbox-HOST: ~/sbrsh-7.0] > sb-conf se nslu2 BR Shell restarting...BR [sbox-nslu2: ~] >BR [sbox-nslu2: ~] > cd sbrsh-7.0/BR [sbox-nslu2: ~/sbrsh-7.0] > make cleanBR rm -f sbrsh sbrshd sb-exportfs *.oBR

[sbox-nslu2: ~/sbrsh-7.0] > make sbrshd CPPFLAGS="-I/scratchbox/device_tools/fakeroot-1.4.2/armv5b-gcc-3.4.4-glibc-2.3.5/include/
"   

[sbox-nslu2: ~/sbrsh-7.0] > file sbrshd sbrshd: ELF 32-bit MSB executable, ARM, version 1 (ARM), for GNU/Linux 2.4.3, dynamically linked (uses shared libs), not stripped

The daemon sbrshd will be copied to /scratchbox/device_tools/sbrsh-7.0/etc/init.d/sbrshdBR This sbrsh will be copied to /scratchbox/device_tools/sbrsh-7.0/armv5b-gcc-3.4.4-glibc-2.3.5/sbin/BR and sbrshd.init as /scratchbox/device_tools/sbrsh-7.0/armv5b-gcc-3.4.4-glibc-2.3.5/etc/sbrshdBR Those etc and sbin containing sbrshd must be transfered by some way-serial connection,scp ..- to the rootfilesystem of target nslu2 .BR There is however a remark : let's check the lib dependencies BR [sbox-nslu2: ~/sbrsh-7.0] > ldd sbrshdBR

If it happens that our target does not have the same libraries,then we need to put on the target not only sbrshd binary,but also the libc .BR

 [sbox-nslu2: ~/sbrsh-7.0] > make sbrshd CPPFLAGS="-I/scratchbox/device_tools/fakeroot-1.4.2/armv5b-gcc-3.4.4-glibc-2.3.5/include" LDFLAGS="-static"    

sbrshd: ELF 32-bit MSB executable, ARM, version 1 (ARM), for GNU/Linux 2.4.3, statically linked, not strippedBR [sbox-nslu2: ~/sbrsh-7.0] >BRBR

fakeroot-1.4.2

to build this daemon. BR

fakemon needs to be patched with BR

<a href="http://scratchbox.org/repos/1.2/sb-toolchains/device_tools/fakeroot/files/communication.patch"><img src="crosstooltoolchain_files/moin-www.png" alt="[WWW]" height="11" width="11"> http://scratchbox.org/repos/1.2/sb-toolchains/device_tools/fakeroot/files/communication.patch</a> and compile with BR

communicate.c -fPIC -DPIC -shared -lpthread -ldl -Wl,-soname -Wl,libfakeroot-tcp.so.0 BR

for the rest about fakeroot,follow BR

<a href="http://scratchbox.org/documentation/docbook/fakeroot.html"><img src="crosstooltoolchain_files/moin-www.png" alt="[WWW]" height="11" width="11"> http://scratchbox.org/documentation/docbook/fakeroot.html</a> BR BRBR



BRBR

~$ scratchboxBR

Welcome to Scratchbox, the cross-compilation toolkit!BR Use 'sb-menu' to change your compilation target.BR See /scratchbox/doc/ for documentation.BR download from the net,untargz and patchBRBR

[sbox-nslu2: ~] >tar xzf /scratchbox/packages/gdb-6.3.tar.gzBR [sbox-nslu2: ~] > cd gdb-6.3BR

patching file bfd/config.bfdBR patching file bfd/configure.inBR patching file bfd/configureBR

[sbox-nslu2: ~/gdb-6.3] > patch -p1 < ../gdb_patch/gdbserver-cflags-last.diffBR can't find file to patch at input line 3BR Perhaps you used the wrong -p or --strip option?BR The text leading up to this was:BR


BR |--- gdb/gdbserver/Makefile.in.orig 2004-10-05 18:52:56.298419032 +0200BR |+++ gdb/gdbserver/Makefile.in 2004-10-05 18:53:10.442268840 +0200BR


BR File to patch:BR

BR patching file gdb/gdbserver/Makefile.inBRBR [sbox-nslu2: ~/gdb-6.3] > cd ..BR [sbox-nslu2: ~] > mkdir build_gdbarmebBR [sbox-nslu2: ~] > cd build_gdbarmeb/BR [sbox-nslu2: ~/build_gdbarmeb] >BR

[sbox-nslu2: ~/build_gdbarmeb] > ../gdb-6.3/gdb/gdbserver/configure --host=armv5b-softfloat-linux  

[sbox-nslu2: ~/build_gdbarmeb] > makeBRBR

[sbox-nslu2: ~/build_gdbarmeb] > file gdbserverBR gdbserver: ELF 32-bit MSB executable, ARM, version 1 (ARM), for GNU/Linux 2.4.3, dynamically linked (uses shared libs), not strippedBR [sbox-nslu2: ~/build_gdbarmeb] > strip gdbserverBR [sbox-nslu2: ~/build_gdbarmeb] > file gdbserverBR gdbserver: ELF 32-bit MSB executable, ARM, version 1 (ARM), for GNU/Linux 2.4.3, dynamically linked (uses shared libs), strippedBR [sbox-nslu2: ~/build_gdbarmeb] > ls gdb*BR gdbreplay gdbreplay.o gdbserverBR [sbox-nslu2: ~/build_gdbarmeb] > file gdbreplayBR gdbreplay: ELF 32-bit MSB executable, ARM, version 1 (ARM), for GNU/Linux 2.4.3, dynamically linked (uses shared libs), not strippedBR [sbox-nslu2: ~/build_gdbarmeb] > strip gdbreplay && file gdbreplayBR gdbreplay: ELF 32-bit MSB executable, ARM, version 1 (ARM), for GNU/Linux 2.4.3, dynamically linked (uses shared libs), strippedBR [sbox-nslu2: ~/build_gdbarmeb] > BRBR

These armeb-gdbserver armeb-gdbreplay have to be put on somewhere /usr/bin or /usr/sbin of the armeb-nslu2-target !BR that's it !BR


cross gdb


After building armeb-gdbserver (patches done) let's build our cross-gdb running on host-i386 aiming at target armeb-nslu2 for ex.BR Since this a tool in sbox point of view,let switch to HOST targetBR [sbox-nslu2: ~/build_gdbarmeb] > sb-conf se HOST BR Shell restarting...BR

[sbox-HOST: ~/gdb-6.3] > patch -p1 &#060; ../gdb_patch/sim-install.patch  

[sbox-HOST: ~] > mkdir build-crossgdbarmebBR [sbox-HOST: ~] > cd build-crossgdbarmeb/BR

[sbox-HOST: ~/build-crossgdbarmeb] > ../gdb-6.3/configure --host=i386-pc-linux-gnu --target=armv5b-softfloat-linux

[sbox-HOST: ~/build-crossgdbarmeb] >makeBRBR After a while :BR [sbox-HOST: ~/build-crossgdbarmeb] > file gdb/gdb gdb/gdb: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), for GNU/Linux 2.2.0, dynamically linked (uses shared libs), not stripped

ramfs on /var/sbrshd/wangji@192.168.1.5/armeb/dev type ramfs (rw) devpts on /var/sbrshd/wangji@192.168.1.5/armeb/dev/pts type devpts (rw) laixa:/scratchbox/users/wangji/home on /var/sbrshd/wangji@192.168.1.5/armeb/home type nfs (rw,sync,v3,rsize=32768,wsize=32768,acregmin=0,acregmax=0,acdirmin=0,acdirmax=0,hard,udp,noac,nolock,addr=laixa) proc on /var/sbrshd/wangji@192.168.1.5/armeb/proc type proc (rw,nodiratime) tmpfs on /var/sbrshd/wangji@192.168.1.5/armeb/tmp type tmpfs (rw) }}} Instead of mounting,you can login the devel_target_partition with sb-armeb> sh /login_target.sh ;this results in a login to a virtual_nslu2 with a true IXP425_cpu operating on the devel_target_dir as root_fs (nfsmount).Although jailed here,you can ssh to outside world so that a cross compile in an env_HOST could be tested immediately by tranfering with scp to the jailed_target.

.(this nslu2 part edited by nnhoan_acong_yahoo_cham_com)


BuildScratchboxMipselWgt634u



mipsel-toolchain: sbox-demo-mipsel.sh


#!/bin/sh set -ex BR # Little-endian MIPSBR # BR # To create a toolchain for the Linksys wrt54g, select glibc-2.2.3 BR # See http://seattlewireless.net/index.cgi/LinksysWrt54g BR # http://www.batbox.org/wrt54g-linux.html BR # Note: recent wrt54g firmware uses uclibc, which behaves like a subsetted glibc. BR # There are patches to build uclibc toolchains in the contrib directory, BR # but they're not integrated yet. However, you can still use a glibc BR # toolchain; you'll either have to BR # a) not call the missing functions, BR # b) use a stub library like http://www.xse.com/leres/tivo/downloads/libtivohack/ BR # or c) link your programs statically if you want them to run onBR # the wrt54g.BR

TARBALLS_DIR=$HOME/downloadsBR RESULT_TOP=/scratchbox/compilersBR PREFIX=$RESULT_TOP/mipsel-gcc-3.3.6-glibc-2.3.2BR export TARBALLS_DIR RESULT_TOP PREFIXBR GCC_LANGUAGES="c,c++"BR export GCC_LANGUAGESBR

unset LD_LIBRARY_PATHBR mkdir -p $RESULT_TOPBR

# Build the toolchain. Takes a couple hours and a couple gigabytes.BR

echo Done.BR


select HOST ,gcc-host with sb-menu. To build toolchain,from inside crosstool-0.38 typeBR

[sbox-HOST:~/crosstool-0.38] > sh sbox-demo-mipsel.sh 

Once the toolchain is built,finish up the symlinks at two places

[sbox-HOST:/scratchbox/compilers/mipsel-gcc-3.4.4-glibc-2.3.2/bin]> for f in `ls`; do ln -s $f sbox-$f; done 

and in

[sbox-HOST:/scratchbox/compilers/bin/] modify the file wrapper_links to reflect this:
PREFICES="host- arm-linux- i386-linux- i686-linux- powerpc-linux- mips-linux- armv5b-softfloat-linux- armeb-linux- mipsel-unknown-linux-gnu-" 

then do

[sbox-HOST:/scratchbox/compilers/bin/] > ./wrapper_links create

Create three following files,to render the toolchain readable by sboxBR

[sbox-HOST:/scratchbox/compilers/mipsel-gcc-3.4.4-glibc-2.3.2/[compiler-name  gcc.specs target_setup.sh ]


compiler-name:
mipsel-gcc-3.4.4-glibc-2.3.2:/scratchbox/compilers/mipsel-gcc-3.4.4-glibc-2.3.2:mipsel:unknown-linux-gnu:glibc:mipsel

gcc.specs:
 *cross_compile:
0
%rename cpp old_cpp
*cpp:
-isystem /usr/local/include -isystem /usr/include %(old_cpp)


target_setup.sh :
#!/bin/sh

target=$1

mkdir -p $target/lib
mkdir -p $target/usr/lib
mkdir -p $target/usr/include
mkdir -p $target/usr/bin

cp -af /scratchbox/compilers/mipsel-gcc-3.4.4-glibc-2.3.2/lib/*                 $target/lib/
cp -af /scratchbox/compilers/mipsel-gcc-3.4.4-glibc-2.3.2/mipsel-unknown-linux-gnu/lib/*  $target/lib/
cp -af /scratchbox/compilers/mipsel-gcc-3.4.4-glibc-2.3.2/mipsel-unknown-linux-gnu/lib/libstdc++* $target/usr/lib/

find /scratchbox/compilers/mipsel-gcc-3.4.4-glibc-2.3.2/usr/ -mindepth 1 -maxdepth 1 -not -name libexec -exec cp -af {} $target/usr/ \;

cp -af /scratchbox/compilers/mipsel-gcc-3.4.4-glibc-2.3.2/include/* $target/usr/include/

ln -sf /bin/cpp $target/lib/
ln -sf /bin/cc  $target/usr/bin/

chmod +x $target/lib/ld-*.so


Use sb-menu to create a target : mips_le (little endian ) with cross compiler :mipsel-gcc-3.4.4-glibc-2.3.2BR The target rootstrap will be created later in another part of this tutorial !!!BR Now,we need to build the device tools for message passing between sbox and the deviceBR


device_tools


build libfakeroot-tcp.so.0.0.1 get fakeroot-1.4.2.tar.gz fromBR

ftp://ftp.debian.org/debian/pool/main/f/fakeroot/fakeroot_1.4.2.tar.gz

patch communicate.patch from BR

http://scratchbox.org/repos/1.2/sb-toolchains/device_tools/fakeroot/files/communication.patch

install -d $(WORKDIR)/lib/libfakeroot

$(CC) -o ../lib/libfakeroot/libfakeroot-tcp.so.0.0.1 libfakeroot.c communicate.c -fPIC -DPIC -shared -lpthread -ldl -Wl,-soname -Wl,libfakeroot-tcp.so.0

BR

        ln -s libfakeroot-tcp.so.0.0.1 $(WORKDIR)/lib/libfakeroot/libfakeroot-tcp.so.0

        [sbox-mips_le:~/sbrsh-7.0] > make sbrshd   

Copy then sbrshd to

 /scratchbox/device_tools/sbrsh-7.0/mipsel-gcc-3.4.4-glibc-2.3.2/sbin/sbrshd 

and to the target board and setup the /etc/sbrshd.conf file.


Just play with sb-menu and your wgt634u ! (1st edited by wangji_nnhoan_acong_yahoo_cham_com)


HowtoBuildMipseluClibcToolchainScratchbox


get the src_tree_openwrt:  svn co -r 3246 https://svn.openwrt.org/openwrt/branches/whiterussian/openwrt/  BR mine was svn_checkout_3246_16feb2006 BR build it in the host_pc just to verify it works (and also to get the rootfs for mipsel-uClibc-0.9.28) BR Try to build the same openwrt_tree inside scratchbox ,under HOST_host-gcc we rapidly get stopped after compiling binutils ! BR But the good new is all the unpack,patching are supplied inside the toolchain_build_mipsel directory !BR The cross toolchain openwrt just built on our host_pc is good enough to crosscompile everything,but we cannot just move it inside scratchbox.BR Most part can be just copied ,ie rootfs,but we need to compile the binutil,gcc,uClibc from the jailed sbox. BR So here is a hack :manual build it BR Create /scratchbox/compilers/openwrt/[include,sysroot,sysroot/usr/include] ;Copy the include from the rootfs_mipsel-uClibc-0.9.28 built at the beginning !!!!so as to have the right include files

Configured with:BR ../gcc-3.4.5/configure --prefix=/scratchbox/compilers/openwrt/ --build=i386-pc-linux-gnu --host=i386-pc-linux-gnu --target=mipsel-linux-uclibc --enable-languages=c,c++ --enable-shared --enable-target-optspace --disable-nls --disable-__cxa_atexit --with-sysroot=/scratchbox/compilers/openwrt/sysroot/ BR "make" does compile well cpp,gcc g++,libgcc,but gets blocked at libstdc++-v3 ;BR Let's do make install even without this libstdc++-v3 (but we can copy from our rootfs_on_pc)BR Modify as needed at the compilers/openwrt rootdir gcc.specs,compiler-name,target-setup.shBR and the sbox-mipsel-linux-uclibc-* links in openwrt/bin_dir.Put the rootfs_mipsel into wrt_target as rootstrap_stuff !BR Now checking and the rest.BR compile hello-world :BR [sbox-wrt: ~] > cd hello-world/BR [sbox-wrt: ~/hello-world] > makeBR make all-amBR make[1]: Entering directory `/home/wangji/hello-world'BR if gcc -DHAVE_CONFIG_H -I. -I. -I. -g -O2 -MT main.o -MD -MP -MF ".deps/main.Tpo" -c -o main.o main.c; \ then mv -f ".deps/main.Tpo" ".deps/main.Po"; else rm -f ".deps/main.Tpo"; exit 1; fiBR gcc -g -O2 -o hello main.oBR make[1]: Leaving directory `/home/wangji/hello-world'BR [sbox-wrt: ~/hello-world] > ./helloBR bash: ./hello: cannot execute binary fileBR [sbox-wrt: ~/hello-world] > file hello hello: ELF 32-bit LSB executable, MIPS, version 1 (SYSV), dynamically linked (uses shared libs), not strippedBR [sbox-wrt: ~/hello-world] > qemu-mipsel helloBR Hello World!BR [sbox-wrt: ~/hello-world] > BR


Note

The reason why ./hello did not run is due to a typo in register_misc_runner of scratchbox-base_1.0.2.deb package.One has to correct the /scratchbox/sbin/register_misc_runner with the foolowing : BR #register mipsel little '\x0a' BR register mipsel little '\x08' BR then everything will be in order !!!!! BR(added by wangji thursday april 20 2006 )


BR cross-compile sbrshdBR [sbox-wrt: ~/sbrsh-7.0] > make cleanBR rm -f sbrsh sbrshd sb-exportfs *.oBR [sbox-wrt: ~/sbrsh-7.0] > make sbrshdBR cc -Wall -Wmissing-prototypes -Wformat=2 -Wshadow -pipe -DREVISION=0 -O2 -fomit-frame-pointer -DNDEBUG -c -o daemon.o daemon.cBR In file included from daemon.c:16:BR fakeroot.h:13:29: fakeroot/config.h: No such file or directoryBR fakeroot.h:14:30: fakeroot/message.h: No such file or directoryBR make: *** [daemon.o] Error 1BR BR in order to see where to put the fakeroot/headers ,doBR [sbox-wrt: ~/sbrsh-7.0] > cpp -vBR Reading specs from /scratchbox/compilers/openwrt/bin/../lib/gcc/mipsel-linux-uclibc/3.4.5/specsBR Reading specs from /scratchbox/compilers/openwrt/gcc.specsBR Configured with: ../gcc-3.4.5/configure --prefix=/scratchbox/compilers/openwrt/ --build=i386-pc-linux-gnu --host=i386-pc-linux-gnu --target=mipsel-linux-uclibc --enable-languages=c,c++ --enable-shared --enable-target-optspace --disable-nls --disable-cxa_atexit --with-sysroot=/scratchbox/compilers/openwrt/sysroot/BR Thread model: posixBR gcc version 3.4.5 (OpenWrt-2.0)BR

ignoring nonexistent directoryBR "/scratchbox/compilers/openwrt/bin/../lib/gcc/mipsel-linux-uclibc/3.4.5/../../../../mipsel-linux-uclibc/include"BR ignoring nonexistent directory "/scratchbox/compilers/openwrt/sysroot//usr/local/include"BR ignoring duplicate directory "/scratchbox/compilers/openwrt//lib/gcc/mipsel-linux-uclibc/3.4.5/include"BR ignoring nonexistent directoryBR "/scratchbox/compilers/openwrt//lib/gcc/mipsel-linux-uclibc/3.4.5/../../../../mipsel-linux-uclibc/include"BR #include "..." search starts here:BR #include <...> search starts here:BR

End of search list.BR

so we copy the fakeroot/headers to the right include_dirBR

[sbox-wrt: ~/sbrsh-7.0] >cp -r fakeroot /scratchbox/compilers/openwrt/sysroot/usr/includeBRBR [sbox-wrt: ~/sbrsh-7.0] > make sbrshdBR cc -Wall -Wmissing-prototypes -Wformat=2 -Wshadow -pipe -DREVISION=0 -O2 -fomit-frame-pointer -DNDEBUG -c -o daemon.o daemon.cBR cc -Wall -Wmissing-prototypes -Wformat=2 -Wshadow -pipe -DREVISION=0 -O2 -fomit-frame-pointer -DNDEBUG -c -o fakeroot.o fakeroot.cBR cc -Wall -Wmissing-prototypes -Wformat=2 -Wshadow -pipe -DREVISION=0 -O2 -fomit-frame-pointer -DNDEBUG -c -o ident.o ident.cBR cc -Wall -Wmissing-prototypes -Wformat=2 -Wshadow -pipe -DREVISION=0 -O2 -fomit-frame-pointer -DNDEBUG -c -o buffer.o buffer.cBR cc -Wall -Wmissing-prototypes -Wformat=2 -Wshadow -pipe -DREVISION=0 -O2 -fomit-frame-pointer -DNDEBUG -c -o common.o common.cBR cc -Wall -Wmissing-prototypes -Wformat=2 -Wshadow -pipe -DREVISION=0 -O2 -fomit-frame-pointer -DNDEBUG -c -o mount.o mount.cBR cc -Wall -Wmissing-prototypes -Wformat=2 -Wshadow -pipe -DREVISION=0 -O2 -fomit-frame-pointer -DNDEBUG -c -o protocol.o protocol.cBR cc -o sbrshd daemon.o fakeroot.o ident.o buffer.o common.o mount.o protocol.o -Wall -Wmissing-prototypes -Wformat=2 -Wshadow -pipe -DREVISION=0 -O2 -fomit-frame-pointer -DNDEBUG -lutilBR [sbox-wrt: ~/sbrsh-7.0] >BR the compilation is fine;let's verifyBR [sbox-wrt: ~/sbrsh-7.0] > file sbrshdBR sbrshd: ELF 32-bit LSB executable, MIPS, version 1 (SYSV), dynamically linked (uses shared libs), not strippedBR [sbox-wrt: ~/sbrsh-7.0] > BR

to build libfakeroot-tcp.so.0.0.1 and put in doc_directory.Compile fakeroot in host_pc first,then copy [wrap*.h ] into our fakeroot_topdir-remember to patch with communicate.c-BR This is necessary because we don't have wrapawk from inside scratchbox !BR [sbox-wrt: ~/fakeroot-1.4.2] > ./configure \

&& make &&make install

[sbox-wrt: ~/fakeroot-1.4.2/fake] > ./configure --prefix=/usr --mandir=/usr/share/man --program-suffix=-tcp --host=mipsel-linux-uclibc --build=i686-pc-none &&make && make install

 [sbox-wrt: ~/gdb-6.3/gdb/gdbserver] > ./configure --host=mipsel-linux-uclibc  && makeBR


BuildPowerpcToolchainScratchbox


>sb-conf sh Compiler: host-gcc Devkits: none CPU-transparency: none


make sure you choose this gcc-glibc configuration


{{{demo-ppc405.sh :

create /scratchbox/compilers/ppc-405 then execute "sh demo-ppc405.sh"}}} BR create your links to sbox for gcc_wrapper stuffsBR >ls /scratchbox/compilers/ppc-405/bin/sbox*BR /scratchbox/compilers/ppc-405/bin/sbox-powerpc-405-linux-gnu-c++filtBR /scratchbox/compilers/ppc-405/bin/sbox-powerpc-405-linux-gnu-ccBR /scratchbox/compilers/ppc-405/bin/sbox-powerpc-linux-addr2lineBR /scratchbox/compilers/ppc-405/bin/sbox-powerpc-linux-arBR /scratchbox/compilers/ppc-405/bin/sbox-powerpc-linux-asBR /scratchbox/compilers/ppc-405/bin/sbox-powerpc-linux-cppBR /scratchbox/compilers/ppc-405/bin/sbox-powerpc-linux-g++BR /scratchbox/compilers/ppc-405/bin/sbox-powerpc-linux-gccBR /scratchbox/compilers/ppc-405/bin/sbox-powerpc-linux-gccbugBR /scratchbox/compilers/ppc-405/bin/sbox-powerpc-linux-gcovBR /scratchbox/compilers/ppc-405/bin/sbox-powerpc-linux-ld /scratchbox/compilers/ppc-405/bin/sbox-powerpc-linux-nm /scratchbox/compilers/ppc-405/bin/sbox-powerpc-linux-objcopy /scratchbox/compilers/ppc-405/bin/sbox-powerpc-linux-objdump /scratchbox/compilers/ppc-405/bin/sbox-powerpc-linux-ranlib /scratchbox/compilers/ppc-405/bin/sbox-powerpc-linux-readelf /scratchbox/compilers/ppc-405/bin/sbox-powerpc-linux-size /scratchbox/compilers/ppc-405/bin/sbox-powerpc-linux-strings /scratchbox/compilers/ppc-405/bin/sbox-powerpc-linux-stripBR

>cat /scratchbox/compilers/ppc-405/compiler-nameBR ppc-405:/scratchbox/compilers/ppc-405:powerpc:linux:glibc:ppcBR BR >cat /scratchbox/compilers/ppc-405/target_setup.shBR {{{#!/bin/sh

target=$1

mkdir -p $target/lib mkdir -p $target/usr/lib mkdir -p $target/usr/include mkdir -p $target/usr/bin

cp -af /scratchbox/compilers/ppc-405/lib/* $target/lib/ cp -af /scratchbox/compilers/ppc-405/powerpc-405-linux-gnu/lib/* $target/lib/ cp -af /scratchbox/compilers/ppc-405/powerpc-405-linux-gnu/lib/libstdc++* $target/usr/lib/

find /scratchbox/compilers/ppc-405/usr/ -mindepth 1 -maxdepth 1 -not -name libexec -exec cp -af {} $target/usr/ \;

cp -af /scratchbox/compilers/ppc-405/include/* $target/usr/include/

ln -sf /bin/cpp $target/lib/ ln -sf /bin/cc $target/usr/bin/

chmod +x $target/lib/ld-*.so }}} BR >cp /scratchbox/compilers/ppc-405/lib/gcc/powerpc-405-linux-gnu/3.4.4/specs /scratchbox/compilers/ppc-405/gcc.specsBR


[sbox-HOST:~]> sb-conf se powerpcBR sb-conf shBR Compiler: ppc-405 Devkits: none CPU-transparency: qemu-ppc


Reading specs from /scratchbox/compilers/ppc-405/lib/gcc/powerpc-405-linux-gnu/3.4.4/specsBR Reading specs from /scratchbox/compilers/ppc-405/gcc.specsBR {{{Configured with: /home/wangji/crosstool-0.38/build/powerpc-405-linux-gnu/gcc-3.4.4-glibc-2.3.5/gcc-3.4.4/configure --target=powerpc-405-linux-gnu --host=i386-host_pc-linux-gnu --prefix=/scratchbox/compilers/ppc-405 --with-cpu=405 --enable-cxx-flags=-mcpu=405 --with-headers=/scratchbox/compilers/ppc-405/powerpc-405-linux-gnu/include --with-local-prefix=/scratchbox/compilers/ppc-405/powerpc-405-linux-gnu --disable-nls --enable-threads=posix --enable-symvers=gnu --enable-cxa_atexit --enable-languages=c,c++ --enable-shared --enable-c99 --enable-long-long Thread model: posix gcc version 3.4.4}}}


make all-am make[1]: Entering directory `/home/wangji/hello-world' if gcc -DHAVE_CONFIG_H -I. -I. -I. -g -O2 -MT main.o -MD -MP -MF ".deps/main.Tpo" -c -o main.o main.c; \ then mv -f ".deps/main.Tpo" ".deps/main.Po"; else rm -f ".deps/main.Tpo"; exit 1; fi gcc -g -O2 -o hello main.o make[1]: Leaving directory `/home/wangji/hello-world'


hello: ELF 32-bit MSB executable, PowerPC or cisco 4500, version 1 (SYSV), for GNU/Linux 2.4.3, dynamically linked (uses shared libs), not stripped


[sbox-powerpc: ~/hello-world]>qemu-ppc helloBR /lib/ld.so.1: No such file or directory


[sbox-powerpc: ~/hello-world] > qemu-ppc hello BR Hello World!


buld tools for cputransparency and rootfs


cp -r fakeroot /scratchbox/compilers/ppc-405/lib/gcc/powerpc-405-linux-gnu/3.4.4/include/ BR make sbrshdBR

sbrshd: ELF 32-bit MSB executable, PowerPC or cisco 4500, version 1 (SYSV), for GNU/Linux 2.4.3, dynamically linked (uses shared libs), not strippedBR copy sbrshd to TARGET/usr/sbinBR


 ./configure --prefix=/usr --mandir=/usr/share/man --libdir=/usr/lib/libfakeroot --program-suffix=-tcp --with-ipc=tcp --with-dbformat=path --build=i686-linux  &&make install
  ../configure --prefix=/usr --mandir=/usr/share/man --program-suffix=-tcp 
 cd fake  && ../configure --prefix=/usr --mandir=/usr/share/man --program-suffix=-tcp --build=i686-linux  && make install




/scratchbox/users/wangji/home/wangji/busybox-1.01/archival/libipkg/args.c:63: warning: passing arg 1 of `bb_xasprintf' from incompatible pointer type /scratchbox/users/wangji/home/wangji/busybox-1.01/archival/libipkg/args.c:63: error: void value not ignored as it ought to be make: *** [/scratchbox/users/wangji/home/wangji/busybox-1.01/archival/libipkg/args.o] Erreur 1 wangji@laixa:/scratchbox/users/wangji/home/wangji/busybox-1.01$ BR

have fun wangji 03-03-2006


/!\ End of edit conflict


CrossToolToolchainPreApophis (last edited 2006-09-08 12:17:25 by IlkkaPoutanen)