DeforaOS libc
About DeforaOS libc
This implementation of the standard C library has a number of goals:
* remain simple while supporting as much of POSIX as possible;
* getting rid of as much historical weight as likely;
* support any combination of kernel, compiler or hardware architecture;
* ease cross-compilation (including cross-OS) thanks to these portable headers;
* ensure code compiling with this libc will build everywhere supported as-is;
* provide a broad range of declarations for Reverse Engineering;
* generally, let headers and code be more readable to humans or programs.
Some of the most immediate benefits include faster compilation times, while
also reducing the storage footprint. It is also useful during the development of
programs intended to be portable across Operating Systems.
DeforaOS libc is part of the DeforaOS Project, and distributed under the terms
of the BSD 2-clause license.
Compiling DeforaOS libc
Simply running `make` with no argument should be enough to build DeforaOS libc
on your platform:
$ make
The build process uses the default compiler available on the system (through
the `CC` variable). The compiler used can therefore be defined as follows:
$ make CC="/path/to/the/compiler"
DeforaOS libc is developed with GCC as the main compiler.
To install DeforaOS libc in a dedicated directory, like `/path/to/libc`:
$ make PREFIX="/path/to/libc" install
_Warning_: unless you know what you are doing, do not install DeforaOS libc in a
directory where it might conflict with the system headers and
libraries, like `/usr` or even the default `/usr/local`.
Generating Makefiles
Official releases of DeforaOS libc ship with Makefiles fitting BSD- and
Linux-based platforms by default. The Makefiles are generated with
`configure(1)` from the DeforaOS configure project, found at
This tool is necessary to generate Makefiles for other platforms (including
macOS), or when working with development versions of DeforaOS libc.
The following command should be enough to re-generate the Makefiles:
$ configure
Please refer to the documentation of DeforaOS configure for further
Compiling programs against DeforaOS libc
The following instructions assume that DeforaOS libc is installed in the
`/path/to/libc` directory.
With GCC:
$ make CPPFLAGS="-nostdinc -isystem /path/to/libc/include" \
LDFLAGS="-nostdlib -L/path/to/libc/src -Wl,-rpath,/path/to/libc/src -lc /path/to/libc/src/start.o" \
A specs file for GCC is also provided by DeforaOS libc, in
`tools/deforaos-gcc.specs`. It is installed in the `$PREFIX/lib/gcc` directory
by default. A shell wrapper for GCC using this specs file, `deforaos-gcc`, is
also provided and installed by default.
This specs file is experimental, with some known issues remaining.
Alternatively, a pkg-config file is provided. The corresponding compilation
flags can be generated as follows:
$ pkg-config --cflags DeforaOS-libc
$ pkg-config --libs DeforaOS-libc
Cross-compiling with DeforaOS libc
DeforaOS libc supports cross-compiling without any specific configuration.
Simply refer to the right compiler while building, as follows:
$ make CC="/path/to/the/cross/compiler"
Compatibility with GCC's command-line syntax is assumed by default (for both
building and linking).
In some cases, it is possible to build binaries cross-OS without requiring a
cross-compiler in the first place. For instance, to build a Linux i386 binary
on NetBSD amd64, with GCC:
Build DeforaOS libc as follows:
$ make CC="gcc -m32 -Wl,--dynamic-linker,/lib/" \
CPPFLAGS="-U __NetBSD__ -D __linux__"
Build the target binary as follows:
$ make CC="gcc -m32 -Wl,--dynamic-linker,/lib/" \
CPPFLAGS="-U __NetBSD__ -D __linux__ -nostdinc -isystem /path/to/libc/include" \
LDFLAGS="-nostdlib -L/path/to/libc/src -Wl,-rpath,/path/to/libc/src -lc /path/to/libc/src/start.o" \
This should provide a functional Linux/i386 binary.