Add vlibc scaffold, build system, and documentation

Establish the repository layout per Vox guidelines (layouts/C.md,
building/C.md): Autotools build (GCC-only, C23), five compatibility
profiles (--enable-onlyposix/--enable-muslmimic/--enable-muslext/
--enable-spoof, default vlibc), alongside/overwrite install methods,
vlibc-gcc/vlibc-clang drivers, static-linking requirement (except
spoof), benchmark harness, and tooling (.clang-format/.clang-tidy/
.clangd + compile_commands.json).
This commit is contained in:
2026-08-31 17:06:01 -04:00
parent 3f63ae1cdd
commit 180c1107b6
25 changed files with 17796 additions and 1 deletions
+27
View File
@@ -0,0 +1,27 @@
# vlibc — benchmark harnesses (musts/BENCHMARKING.md).
AM_CPPFLAGS = -I$(top_srcdir)/include
AM_CFLAGS = @VLIBC_CFLAGS@
# Built only on demand (via `make bench`), so `make all` does not need the
# library to be built first.
EXTRA_PROGRAMS = bench_vlibc
bench_vlibc_SOURCES = bench_vlibc.c
# By default benchmarks link against vlibc itself. --with-libc=glibc links the
# same harness against the system glibc; --with-libc=musl builds it with
# musl-gcc for the musl reference.
if BENCH_LINK_VLIBC
bench_vlibc_LDADD = ../libvlibc.la
else
bench_vlibc_LDADD =
endif
if BENCH_LINK_MUSL
CC = $(MUSL_CC)
endif
bench: bench_vlibc
./bench_vlibc
.PHONY: bench
+33
View File
@@ -0,0 +1,33 @@
# Benchmarking
Every vlibc component is benchmarked against the software it replaces, per
`musts/BENCHMARKING.md`. A component that is slower or worse at its task than
the software it replaces is considered failing.
## Layout
- Each benchmark harness is a standalone C program in this directory, named
`bench_<component>.c`.
- `bench_vlibc.c` is the skeleton that per-component benchmarks build on.
## Running
```sh
./autogen.sh # configure (default: link against vlibc)
make bench # build and run the harnesses
# Reference comparison against the libc vlibc replaces:
./autogen.sh --with-libc=glibc
make bench
# musl reference (requires musl-gcc):
./autogen.sh --with-libc=musl
make bench
```
## Adding a benchmark
1. Add `bench_<component>.c` here and list it in `benchmarks/Makefile.am`.
2. Measure the component against the equivalent glibc (and musl) call.
3. Report wall-clock time, throughput, and any binary-size difference.
4. If vlibc is slower, the benchmark fails — fix the implementation.
+53
View File
@@ -0,0 +1,53 @@
/*
* Benchmark harness for vlibc (musts/BENCHMARKING.md).
*
* Every vlibc component is benchmarked against the software it replaces.
* This stub times vlibc_version() and is the skeleton that per-component
* benchmarks build on. Reconfigure with --with-libc=musl or --with-libc=glibc
* to link the same harness against a reference libc for comparison.
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <vlibc.h>
#include <stdio.h>
#include <time.h>
#define ITERATIONS 100000000ULL
int
main(void)
{
volatile const char *version = NULL;
struct timespec start;
struct timespec end;
double whole;
double frac;
double seconds;
if (clock_gettime(CLOCK_MONOTONIC, &start) != 0)
{
return 1;
}
for (unsigned long long i = 0; i < ITERATIONS; i++)
{
version = vlibc_version();
}
if (clock_gettime(CLOCK_MONOTONIC, &end) != 0)
{
return 1;
}
whole = (double)(end.tv_sec - start.tv_sec);
frac = (double)(end.tv_nsec - start.tv_nsec) / 1000000000.0;
seconds = whole + frac;
printf("vlibc_version() x %llu: %.3f s (%.2f ns/call), version=%s\n", ITERATIONS, seconds,
seconds * 1000000000.0 / ITERATIONS, (const char *)version);
return 0;
}