Find a file
2022-08-01 19:59:30 +01:00
.github/workflows workflows: run aarch64 tests on CI 2022-07-22 17:33:37 +02:00
abis abis/linux: change cc_t from uint to uchar 2022-08-01 19:15:40 +02:00
ci workflows: run aarch64 tests on CI 2022-07-22 17:33:37 +02:00
dummy-libs meta: move stubbed libs to dummy-libs folder 2022-06-06 19:29:50 +01:00
options rtdl: use range-based for loops 2022-08-01 19:59:30 +01:00
scripts scripts: make abi-link.sh a bit more useful 2022-07-16 19:02:18 +01:00
subprojects build: Add wraps for cxxshim and frigg deps. 2018-11-17 16:11:20 +01:00
sysdeps aero: use linux ABI for {wait,signal,utsname,termios}.h 2022-08-01 19:15:40 +02:00
tests tests/rtdl: add basic rtdl tests 2022-08-01 19:59:30 +01:00
.gitignore sysdeps: update aero sysdeps (more syscalls) 2022-06-30 17:01:38 +10:00
ABI_BREAKS.md options/posix: Overhaul glob.h 2022-08-01 19:15:40 +02:00
internal-config.h.in options/internal: add a more strict debug allocator 2022-07-23 16:11:18 +02:00
LICENSE license: update copyright year 2022-06-11 16:31:20 +01:00
meson.build abis: add deprecation notices to mlibc/{wait,termios,signal,utsname}.h 2022-08-01 19:15:40 +02:00
meson_options.txt options/internal: add a more strict debug allocator 2022-07-23 16:11:18 +02:00
mlibc-config.h.in libcrypt: Allow for disabling of libcrypt, following glibc 2021-10-31 18:11:26 +01:00
README.md meta: mention default_library in README.md 2022-06-30 14:17:29 +01:00
RELEASE_PROCEDURE.md meta: add a release procedure 2021-11-30 20:12:56 +01:00

mlibc is a C standard library

Continuous Integration

Official Discord server: https://discord.gg/7WB6Ur3

AUR package (provides mlibc-gcc): https://aur.archlinux.org/packages/mlibc

Design of the library

Directory Purpose
options/ (More or less) OS-independent headers and code.
options/ is divided into subdirectories that can be enabled or disabled by ports.
sysdeps/ OS-specific headers and code.
sysdeps/ is divded into per-port subdirectories. Exactly one of those subdirectories is enabled in each build.
abis/ OS-specific interface headers ("ABI headers"). Those contain the constants and structs of the OS interface. For example, the numerical values of SEEK_SET or O_CREAT live here, as well as structs like struct stat. ABI headers are only allowed to contain constants, structs and unions but no function declarations or logic.
abis/ is divided into per-OS subdirectories but this division is for organizational purposes only. Ports can still mix headers from different abis/ subdirectories.

Porting mlibc to a new OS

Ports to new OSes are welcome. To port mlibc to another OS, the following changes need to be made:

  1. Add new sysdeps/ subdirectory sysdeps/some-new-os/ and a meson.build to compile it. Integreate sysdeps/some-new-os/meson.build into the toplevel meson.build.
  2. Create ABI headers in abis/some-new-os/. Add symlinks in sysdeps/some-new-os/include/abi-bits to your ABI headers. Look at existing ports to figure out the ABI headers required for the options enabled by sysdeps/some-new-os/meson.build.
  3. In sysdeps/some-new-os/, add code to implement (a subset of) the functions from options/internal/include/mlibc/internal-sysdeps.hpp. Which subset you need depends on the options that sysdeps/some-new-os/meson.build enables.

We recommend that new ports do not build from master as we occasionally make internal changes that cause out-of-tree sysdeps to break. Instead we recommend you pin a specific release (or commit), or to upstream your changes to this repository so that we can build them on our CI and thus any breakages will be fixed by us in-tree.

Build Configuration

The following custom meson options are accepted, in addition to the built-in options. The options below are booleans which default to false (see meson_options.txt).

  • headers_only: Only install headers; don't build libc.so or ld.so.
  • mlibc_no_headers: Don't install headers; only build libc.so and ld.so.
  • build_tests: Build the test suite (see below).
  • disable_x_option: Disable x component of mlibc functionality. See meson_options.txt for a full list of possible values for x. This may be used to e.g disable POSIX and glibc extensions.

The type of library to be built (static, shared, or both) is controlled by meson's default_library option. Passing -Ddefault_library=static effectively disables the dynamic linker.

We also support building with -Db_sanitize=undefined to use UBSan inside mlibc. Note that this does not enable UBSan for external applications which link against libc.so, but it can be useful during development to detect internal bugs (e.g when adding new sysdeps).

Running Tests

The mlibc test suite can be run under a Linux host. To do this, first run from the project root:

meson -Dbuild_tests=true build

This will create a build directory. Then, cd build and run the tests (showing output) with:

meson test -v