Revision [17146]

This is an old revision of DevBootstrap made by DkLwikki on 2014-08-05 10:23:39.


Bootstrapping fbc on a new system

fbc is written in FB itself, so you need a working fbc to build a new fbc. How to do this on a system where no working fbc exists yet? There are two options: pre-compiling (by cross-compiling) the fbc sources on a system where you have a working fbc and then taking the results to the target system, or full cross-compiling using a gcc cross-compiler toolchain.

Bootstrapping by precompiling the compiler sources
  1. On the target system, compile FB's rtlib/gfxlib2 using the native C compiler as usual:
make rtlib gfxlib2

  1. On Linux or Win32 (or another system where you have a working fbc), use the existing fbc to cross-compile src/compiler/*.bas into *.asm (-gen gas, x86 only) or *.c (-gen gcc, works for every target) files compatible to the target system:
fbc -e -m fbc src/compiler/*.bas -r -target <mytargetos> -arch <mytargetarch>
Some random examples:
x86 Win32 -> x86 OpenBSD: -target openbsd [-arch 486]
x86 Win32 -> x86_64 FreeBSD: -target freebsd -arch x86_64
x86 Linux -> ARM Linux: -target arm-linux-gnueabihf, or just -arch armv6

  1. Take the produced .asm or .c files to the target system, and use the target system's native tools build the final fbc executable:

  • If you produced .asm files, take them to the target system, and assemble them into *.o object files using the target system's native assembler, and then link everything into a new fbc executable:
for i in src/compiler/*.asm; do
as $i -o `echo $i | sed -e 's/asm$/o/g'`

gcc -o fbc lib/freebasic/fbrt0.o src/compiler/*.o -Llib/freebasic -lfb -lncurses -pthread

  • If you produced .c files, take them to the target system, and compile them into a new fbc executable:
gcc -o fbc lib/freebasic/fbrt0.o src/compiler/*.c -Llib/freebasic -lfb -lncurses -pthread

Additional notes & tips
Bootstrapping by cross-compiling everything

If you're on Linux or Win32 or another system where you already have a working fbc, and you have a gcc cross-compiler toolchain for the target system, and the libraries needed to link an fbc for the target system (libc, libpthread, etc. and libncurses/libtinfo), then you can directly cross-compile an FB setup like so:
  1. Build a native FB setup with additional libraries for cross-compiling to the target system:
# Get a directory with the fbc sources, e.g. "fbc"
cd fbc
make rtlib gfxlib2 TARGET=<gcc-target-id>

# Optionally, you can install everything into /usr/local:
make install
make install-rtlib install-gfxlib2 TARGET=<gcc-target-id>

  1. Use the native FB setup built above to cross-compile the new FB setup for the target system:
mkdir crosscompiled-fbc
make ../fbc/makefile FBC=../fbc/bin/fbc TARGET=<gcc-target-id>
# (Specifying FBC=... is only needed if you did not install it globally)

Valid XHTML :: Valid CSS: :: Powered by WikkaWiki phatcode