fix(bench): separate vlibc-under-test TU from host harness TUs
This commit is contained in:
+24
-6
@@ -10,18 +10,30 @@ EXTRA_PROGRAMS = bench_vlibc bench_string
|
||||
bench_vlibc_SOURCES = bench_vlibc.c
|
||||
bench_string_SOURCES = bench_string.c
|
||||
|
||||
# bench_string is a system-headers-only translation unit (it times whichever
|
||||
# libc it is linked against), so it must NOT inherit AM_CPPFLAGS: -I include
|
||||
# would pull vlibc's self-contained <stddef.h>/<string.h> into the same TU as
|
||||
# the system <stdio.h>/<time.h> and double-define size_t/NULL/offsetof.
|
||||
# bench_vlibc keeps the inherited -I include.
|
||||
# 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
|
||||
# <stdarg.h>/<stddef.h>/<string.h> into the same TU as the system
|
||||
# <stdio.h>/<time.h> and double-define size_t/NULL/offsetof (or hide the
|
||||
# compiler's internal <stdarg.h> 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 = ../libvlibc.la
|
||||
bench_vlibc_LDADD = bench_vlibc_under.o ../libvlibc.la
|
||||
bench_string_LDADD = ../libvlibc.la
|
||||
else
|
||||
bench_vlibc_LDADD =
|
||||
@@ -38,6 +50,12 @@ endif
|
||||
# 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
|
||||
|
||||
Reference in New Issue
Block a user