Skip to content
This repository has been archived by the owner on Jul 3, 2020. It is now read-only.
Serge edited this page Jul 19, 2015 · 5 revisions

BUILD

Note: there are prebuilt versions of runtime.js kernel available https://github.com/runtimejs/builds. You can also use runtime-tools NPM package that can download prebuilt kernel automatically and run it in QEMU VM.

If you'd like to build runtime.js from source or hack on C++ parts of it, you will need to use a GCC cross-compiler. Here are the following dependencies that you will need for the following systems and the steps required to build.

BUILD REQUIREMENTS

First, download the following tools

  • FASM for Linux or OSX and add to your PATH.
  • scons and add to your PATH.

You will also need the following libs which can be installed various ways on different platforms.

You'll need a copy of the GCC source.

LINUX

apt-get install binutils gmp mpfr libmpc gcc-4.8

DARWIN (OSX, >= 10.9.4)

First you'll likely need to update libiconv. Then you can use either brew or port to get compatible versions of the libraries you need.

brew install binutils gmp mpfr libmpc gcc48

or

sudo port install binutils gmp mpfr libmpc gcc48

BUILD STEPS

Do the following steps in bash and add the following to your path, perhaps even in your .bashrc.

export PATH="$HOME/opt/cross/bin:$PATH"

LINUX

DARWIN

Create the following environment variables that point to your actual GCC installation.

bash
export CC=/usr/bin/gcc-4.8
export CXX=/usr/bin/g++-4.8
export CPP=/usr/bin/cpp-4.8
export LD=/usr/bin/gcc-4.8

Set the destination for where your compiler will live, which architecture you're targeting and the path so that it can be run in your environment.

export PREFIX="$HOME/opt/cross"
export TARGET=x86_64-elf
export PATH="$PREFIX/bin:$PATH"

You'll need to create a version of binutils that targets your architecture.

cd $HOME/src                 # go into your working directory
mkdir build-binutils         # make a place to build 
cd build-binutils            # go into the directory
../binutils-4.24/configure \ # run the configure script
  --target=$TARGET \         # specify your target architecture
  --prefix="$PREFIX" \       # specify the build path
  --disable-nls \            # don't include native language support
  --disable-werror           # disable warnings as errors
make
make install

Then actually create your new version of gcc.

cd $HOME/src                 # go into your working directory 
mkdir build-gcc              # make a place to build
cd build-gcc                 # go into your gcc build directory
../gcc-4.8.3/configure \     # run the configure script
  --target=$TARGET \         # the architecture to target
  --prefix="$PREFIX" \       # where to put the build
  --disable-nls \            # don't include native language support
  --enable-languages=c,c++   # only compile C and C++ front ends
  --without-headers          # don't rely on any C library
make all-gcc
make all-target-libgcc
make install-gcc
make install-target-libgcc

If all goes well you should find a bunch of files in $HOME/opt/cross/bin that are prefixed with x86_64, these are your new cross compiler tools.

RUN

Now that you have a cross compiler, you can compile the runtimejs project and run it. Clone it into a directory (if you haven't already) using git. Then run the scons command.

QEMU

To run the kernel, you will need the qemu machine emulator/virtualizer (recommended version >= 2.0.0). The commands for running qemu have been added to the qemu.sh script here.

./qemu.sh

Or using runtime-tools with --kernel=<path> to point it to newly built kernel binary (located at disk/boot/runtime).

###KVM If you're on Linux and your processor supports virtualization, you can run system in KVM.

./qemu-kvm.sh

Or manually add this QEMU flags:

  • -enable-kvm
  • -no-kvm-irqchip

DOCKER

Easiest way to setup developer environment is to use Docker https://www.docker.io/

Prepare:

./docker-prepare.sh

Build kernel:

./docker-build.sh