# vlibc — benchmark harnesses (musts/BENCHMARKING.md). # Build-dir include FIRST (generated features.h lives there in VPATH builds). AM_CPPFLAGS = -I$(top_builddir)/include -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_string bench_vlibc_SOURCES = bench_vlibc.c bench_string_SOURCES = bench_string.c # Both harness TUs are system-headers-only translation units (they time # whichever libc they are linked against), so they must NOT inherit # AM_CPPFLAGS: -I include would pull vlibc's self-contained # // into the same TU as the system # / and double-define size_t/NULL/offsetof (or hide the # compiler's internal behind vlibc's). The vlibc function under # test is reached through the adapter TU bench_vlibc_under.c, which is # compiled with vlibc's headers and exposes the call to the harness through # its own declaration (see that file). bench_vlibc_CPPFLAGS = bench_string_CPPFLAGS = # Adapter TU for bench_vlibc: vlibc's headers only, so it must NOT inherit # the (empty) per-target CPPFLAGS above; it gets the include path back # explicitly. bench_vlibc_under.o: bench_vlibc_under.c $(AM_V_CC)$(CC) -I$(top_srcdir)/include $(CPPFLAGS) $(AM_CFLAGS) \ $(CFLAGS) -c -o $@ $< # 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 = bench_vlibc_under.o ../libvlibc.la bench_string_LDADD = ../libvlibc.la else bench_vlibc_LDADD = bench_string_LDADD = endif if BENCH_LINK_MUSL CC = $(MUSL_CC) endif # Relink whenever the configuration changes (autogen.sh reruns configure and # rewrites config.status). --with-libc only affects the link (LDADD), and the # objects are compile-time identical, so make would otherwise reuse a stale # binary from the previous configuration and the wrong libc would be measured. EXTRA_bench_string_DEPENDENCIES = $(top_builddir)/config.status EXTRA_bench_vlibc_DEPENDENCIES = $(top_builddir)/config.status bench_vlibc_DEPENDENCIES = bench_vlibc_under.o # The adapter TU is built by a hand-rolled rule (per-TU include paths), so it # is not picked up by automake's automatic distribution/cleaning. EXTRA_DIST = bench_vlibc_under.c CLEANFILES = bench_vlibc_under.o # bench_vlibc.c calls vlibc_version(), which exists only in vlibc — under # --with-libc=glibc/musl it cannot link, so it is built and run only in the # vlibc build. bench_string links either way and runs always. if BENCH_LINK_VLIBC bench: bench_vlibc bench_string ./bench_vlibc ./bench_string else bench: bench_string ./bench_string endif .PHONY: bench