[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Crossbuilding and testing klibc



This posting is purely for the/any list archives.

Using mksh and its testsuite for spotting compiler bugs is
nothing new, cf. https://bugzilla.redhat.com/show_bug.cgi?id=922974
for the latest example. I just wrote the below instructions for
someone wanting to port klibc to a new platform, as an example
of how to cross-build klibc then cross-build mksh with it, transfer
the stuff to the target platform and run the tests there.

Using debian-68k@ because I happened to have this at hand ☺ and
chose it to be my test platform. Substitute ARCH=m68k for whatever
you’d have in the debian/rules file (like ARCH=arm CONFIG_AEABI=y)
and the multiarch pathnames and CROSS_COMPILE as usual.

$ apt-get source klibc
 → ./klibc-2.0.1/
$ dget http://ftp.de.debian.org/debian/pool/main/m/mksh/mksh_44-1.dsc
 → ./mksh-44/

$ mkdir ~/klibc-prefix
$ cd klibc-2.0.1/
$ export CROSS_COMPILE=m68k-linux-gnu-
$ ln -sf /usr/m68k-linux-gnu/include/asm* linux/include
$ ls linux/include/
asm  asm-generic  linux
$ make prefix=~/klibc-prefix ARCH=m68k
$ make prefix=~/klibc-prefix ARCH=m68k install
$ ls ~/klibc-prefix/bin/
klcc
$ ln -s /usr/m68k-linux-gnu/include/asm ~/klibc-prefix/lib/klibc/include/
$ cd ../mksh-44/
$ CC=~/klibc-prefix/bin/klcc CPPFLAGS=-DMKSH_GCC55009 sh Build.sh -r
[… lots of output …]
size mksh
   text    data     bss     dec     hex filename
 206198     452   19404  226054   37306 mksh

Installing the shell:
[…]
$ ls -l mksh check.* test.*
-rw-r--r-- 1 root root  34338 Apr  6  2012 check.pl
-rw-r--r-- 1 root root 227055 Feb 24 15:23 check.t
-rwxr-xr-x 1 root root 231363 Mar 26 17:39 mksh
-rwxr-xr-x 1 root root   2106 Mar 26 17:39 test.sh

Now transfer these four files to the model.
Next steps are run on the model:

root@aranym:~/X # ./mksh test.sh -p $PWD/mksh

This runs test.sh but tells it to use the mksh binary in
the current directory, instead of the path from the build
system, which is normally hardcoded into test.sh when it
is generated. Also, test.sh itself is run with the mksh
just built, both as an additional test and because it
can use ksh features this way ;-)

[…]
pass ./check.t:command-shift
pass ./check.t:duffs-device
Total failed: 0
Total passed: 436

That was it ;)


Reply to: