How to compile 32bit applications on FreeBSD-amd64?

Mark Diekhans markd at kermodei.com
Wed Nov 28 14:29:22 PST 2007


W.B. Kloke <wb at arb-phys.uni-dortmund.de> writes:
> Is there an easy way to build a 32bit application on an amd64 system?

With sufficient disk space, its straight forward.  I set up a fake root
directory, extract a minimal i386 FreeBSD system into it.  The attached
script is used to start a 32bit chroot-ed environment, either to run
a command or start a shell.  I have successfully built a large number
of 32-bit ports on a amd64 bit server this way.

Let me know if you have more questions.
Mark

-------------- next part --------------
#!/bin/sh -e

# start-i386 [cmd ..]
# from http://www.nabble.com/i386-package-building-on-an-amd64-system-t4441068.html

ROOT=/b/jails/i386
REVISION="6.2"
BRANCH="stable"
OSVERSION=602112

UNAME_s="FreeBSD"
UNAME_m="i386"
UNAME_p="i386"
UNAME_r=$REVISION-$BRANCH
UNAME_v="$UNAME_s $UNAME_r #6: Sun Sep 23 11:41:48 PDT 2007     root at osprey.kermodei.com:/usr/src/sys/i386/compile/OSPREY"

export UNAME_s UNAME_r UNAME_v UNAME_m UNAME_p OSVERSION ROOT

if [ -r $ROOT/dev/zero ]
then
        echo dev already mounted
else
        mount -t devfs dev $ROOT/dev
fi
ln -sf ld-elf.so.1 $ROOT/libexec/ld-elf32.so.1
echo "libpthread.so.2 libthr.so.2
libpthread.so libthr.so" > ${ROOT}/etc/libmap.conf
cp ${ROOT}/etc/libmap.conf ${ROOT}/etc/libmap32.conf
mkdir -p ${ROOT}/usr/local/bin

cp /usr/local/bin/bsdmake ${ROOT}/usr/local/bin
cp /etc/make.conf ${ROOT}/etc/
cp /etc/resolv.conf ${ROOT}/etc/
cp /etc/hosts ${ROOT}/etc/

HOME=/root
export HOME

if [ $# = 0 ] ; then 
    exec chroot $ROOT /bin/csh
else
    echo "$@" | exec chroot $ROOT /bin/sh
fi


More information about the freebsd-amd64 mailing list