relibc is a portable POSIX C standard library written in Rust and is under heavy development.
The motivation for this project is twofold: Reduce issues that the Redox developers were having with newlib, and create a safer alternative to a C standard library written in C. It is mainly designed to be used under Redox, as an alternative to newlib, but it also supports Linux system calls via the sc crate.
Currently Redox and Linux are supported.
redox-rt is a runtime library that provides much of the code that enables POSIX on Redox, like fork, exec, signal handling, etc.
Relibc uses it as backend in src/platform/redox, and it's intended to eventually be usable independently, without relibc.
include- Header files (mostly macros and variadic functionscbindgencan't generate)src- Source filessrc/c- C codesrc/crt0- Runtime codesrc/crti- Runtime codesrc/crtn- Runtime codesrc/header- Header files implementationsrc/header/*- Each folder has acbindgen.tomlfile, it generates a C-to-Rust interface and header filessrc/ld_so- Dynamic loader codesrc/platform- Platform-specific and common codesrc/platform/redox- Redox-specific codesrc/platform/linux- Linux-specific codesrc/pthread- pthread implementationsrc/sync- Synchronization primitivestests- C tests (each MR needs to give success in all of them)
To download the relibc sources run the following command:
git clone --recursive https://gitlab.redox-os.org/redox-os/relibcTo build relibc out of the Redox build system, do the following steps:
- Install
cbindgen
cargo install cbindgen- Debian, Ubuntu and PopOS:
sudo apt install expect- Fedora:
sudo dnf install expect- Arch Linux:
sudo pacman -S expectTo build the relibc library objects, run the following command:
make all- Clean old library objects and tests
make cleanInside of your Redox build system, run:
make prefixIf you need to rebuild relibc for testing a Cookbook recipe, run:
touch relibc
make prefix r.recipe-nameTouching (changing the "last modified time" of) the relibc folder is needed to trigger recompilation for make prefix. Replace recipe-name with your desired recipe name.
Note: Do not edit relibc inside prefix folder! Do your work on relibc folder directly inside your Redox build system instead.
This section explain how to build and run the tests.
To build the tests run make all on the tests folder, it will store the executables at tests/bins_static
If you did changes to your tests, run make clean all to rebuild the executables.
To test on Redox do the following steps:
- Add the
relibc-testsrecipe on your filesystem configuration atconfig/your-cpu/your-config.toml(generallydesktop.toml) - Run the following commands to rebuild relibc with your changes, update the
relibc-testsrecipe and update your QEMU image:
touch relibcmake prefix cr.relibc-tests image- Run the tests
/usr/share/relibc-tests/bins_static/test-nameRun make test on the relibc directory.
If you want to run one test, run the following command:
tests/bins_static/test-nameI'm building for my own platform which I run, and am getting x86_64-linux-gnu-ar: command not found (or similar)
The Makefile expects GNU compiler tools prefixed with the platform specifier, as would be present when you installed a cross compiler. Since you are building for your own platform, some Linux distributions (like Manjaro) don't install/symlink the prefixed executables.
An easy fix would be to replace the corresponding lines in the Makefile, e.g.
ifeq ($(TARGET),x86_64-unknown-linux-gnu)
export CC=x86_64-linux-gnu-gcc
- export LD=x86_64-linux-gnu-ld
- export AR=x86_64-linux-gnu-ar
+ export LD=ld
+ export AR=ar
export OBJCOPY=x86_64-linux-gnu-objcopy
endifBefore starting to contribute, read this document.
- Redox OS
- Linux
- i686 (Intel/AMD)
- x86_64 (Intel/AMD)
- Aarch64 (ARM64)
This project is funded through NGI Zero Core, a fund established by NLnet with financial support from the European Commission's Next Generation Internet program. Learn more at the NLnet project page.