Cross-compiling NetBSD

grab-binary | grab-source | kernel | cross | world | tweaks

Requirements

Grab the source and go where it got downloaded and depending on the build system

# build netbsd on netbsd
cd /usr/src/

# build netbsd-current on slackware
cd /var/tmp/usr/src/

Building current from a stable release

We want to keep the tools there – no need to rebuild them each time

find sys/arch/amd64/conf/
time ./build.sh -T ../tools -O ../obj -j 16 tools
time ./build.sh -T ../tools -O ../obj -j 16 kernel=XEN3_DOMU

Building i386 from NetBSD/amd64

time sh build.sh -m i386 -j16 tools > ../make.tools.i386.log && echo TOOLS READY

then

time sh build.sh -m i386 kernel=LESSPLUS
#-T /usr/src/tooldir.NetBSD-8.0-i386/
#-u
#rm -rf /usr/src/sys/arch/i386/compile/obj/LESSPLUS
#rm -rf /usr/src/sys/arch/i386/compile/LESSPLUS

gzip -9 -c < /usr/src/sys/arch/i386/compile/obj/LESSPLUS/netbsd > ~/netbsd.LESSPLUS.gz

Building NetBSD from GNU/Linux

even though you do not need a destdir yet, it gets defined somewhere already

vi /etc/mk.conf # new file

COPTS+=-D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64

grep ^proc /proc/cpuinfo
time ./build.sh -m amd64 -T ../tools -O ../obj -D ../destdir -j 32 tools \
    > ../tools.log && echo TOOLS ARE READY
# -u don't rebuild everything
# -n for dummy mode
ls -lF /var/tmp/usr/tools/bin/nbmakefs

eventually share it with other systems where you might need it

cd /var/tmp/usr/
tar czf tools.tar.gz tools/

TODO

build with moar options to handle 2G+ http://mail-index.netbsd.org/tech-toolchain/2020/08/09/msg003832.html

Resources

current

http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/arch/amd64/conf/XEN3_DOMU

http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/arch/amd64/conf/XEN3_DOMU?rev=HEAD

i386

https://www.netbsd.org/docs/guide/en/chap-build.html

https://www.netbsd.org/docs/guide/en/chap-build.html#chap-boot-cross-compiling-kernel

http://www.ki.nu/~makoto/diary/2003/01/11/

https://wiki.netbsd.org/bsd_make/

ftp://ftp.netbsd.org/pub/NetBSD/NetBSD-current/src/share/mk/bsd.README


HOME | GUIDES | LECTURES | LAB | SMTP HEALTH | HTML5 | CONTACT
Copyright © 2024 Pierre-Philipp Braun