How to build, test and use CROCOS

1. First, middle and last phases
2. Makefile targets
3. Options
4. System configuration

CROCOS can be built on Linux x86/x86_64 systems with traditional compilation tools (GNU gcc, make...). Here is the list of plateforms on which it has been built and tested successfully:
• x86 with gcc 4.3.2
• x86_64 with gcc 4.4.1

To build CROCOS, from the root source directory, go to the phase directory you’re interested in and use the local Makefile (targets are defined below).

1. First, middle and last phases

Development phases in CROCOS can be divided into 3 main types:

• "first phases":

phases of the development when user programs and the kernel are linked together and when the kernel is run inside a Linux process.

• "middle phases":

phases of the development when user programs and the kernel are linked together and when the kernel is run on a "naked" box (either on real hardware or inside an emulator).

• "last phases":

phases of the development when user programs and the kernel are different binaries and run on a "naked" box.

Development phases implemented in CROCOS as of today (phases 2.1 to 3.5) are "first phases".

2. Makefile targets

Here are the useful targets of the main CROCOS Makefile:

• klibc:

build the kernel libc (phase 1) in klibc/klibc.a.

• klibc-check:

run the klibc test suite.

• crocos:

build the CROCOS kernel. In "first/middle phases", only build kernel object files. In "last phases", build the crocos binary in the root source directory.

• libcrocos:

build the CROCOS library in usr/lib/libcrocos.a. User programs are linked with libcrocos.a to make system calls.

• usr:

only available in "last phases". Build useful user programs (init, sh).

• all:

run klibc, crocos, libcrocos and usr targets.

• check:

build test programs. In "first phases", also run the CROCOS test suite.

• install:

only available in "middle/later phases". In "middle phases", create a disk image with the booloader and a specified user program binary. In "later phases", create a disk image with the booloader, the crocos binary and the user programs.

• clean:

clean all object files, libraries and binaries.

3. Options

3 variables can be used to control the compilation:


Setting the DBG variable to yes activate the debugging option of gcc (-g). Use this option if you need to run CROCOS with gdb for example.
By default, the option is set to no.


The OPT option sets the optimization level used by gcc. On the supported plateforms (see above), any of these values should generate valid code. Note that CROCOS code is very sensitive to optimizations done by gcc. Indeed, gcc doesn’t expect a program to modify the stack pointers (which is done in several locations by CROCOS), and therefore, can break CROCOS code by performing optimizations related to stack registers. Some gcc options are used to prevent gcc from doing "bad" optimizations (see CFLAGS_OPT in However, these options may not be sufficient on other plateforms than the supported ones or with different gcc releases.
By default, this option is set to -O0.


The ARCH option controls the destination architecture on which CROCOS will be run. It is set by default to the architecture of the machine used for compilation (see the "uname -m" command in, but can be overriden for cross-compilation.

4. System configuration

Some macros defining the system configuration can be modified so that CROCOS can be adapted to different environments. These macros mainly have influence on the amount of memory used by CROCOS when running. The descriptions and definitions of these macros are located in the file crocos/include/config/config.h.