benchtests: Building benchmarks as static executables

Building benchmarks as static executables:
=========================================

To build benchmarks as static executables, on the build system, run:

  $ make STATIC-BENCHTESTS=yes bench-build

You can copy benchmark executables to another machine and run them
without copying the source nor build directories.
This commit is contained in:
H.J. Lu 2021-07-30 12:15:27 -07:00
parent 83b5323261
commit de0a7c5a0b
2 changed files with 29 additions and 7 deletions

View File

@ -110,11 +110,23 @@ else
bench-malloc := $(filter malloc-%,${BENCHSET}) bench-malloc := $(filter malloc-%,${BENCHSET})
endif endif
$(addprefix $(objpfx)bench-,$(bench-math)): $(libm) ifeq (${STATIC-BENCHTESTS},yes)
$(addprefix $(objpfx)bench-,$(math-benchset)): $(libm) +link-benchtests = $(+link-static-tests)
$(addprefix $(objpfx)bench-,$(bench-pthread)): $(shared-thread-library) link-libc-benchtests = $(link-libc-static)
$(addprefix $(objpfx)bench-,$(bench-malloc)): $(shared-thread-library) libm-benchtests = $(common-objpfx)math/libm.a
$(addprefix $(objpfx)bench-,pthread-locks): $(libm) thread-library-benchtests = $(static-thread-library)
else
link-libc-benchtests = $(link-libc)
+link-benchtests = $(+link-tests)
thread-library-benchtests = $(shared-thread-library)
libm-benchtests = $(libm)
endif
$(addprefix $(objpfx)bench-,$(bench-math)): $(libm-benchtests)
$(addprefix $(objpfx)bench-,$(math-benchset)): $(libm-benchtests)
$(addprefix $(objpfx)bench-,$(bench-pthread)): $(thread-library-benchtests)
$(addprefix $(objpfx)bench-,$(bench-malloc)): $(thread-library-benchtests)
$(addprefix $(objpfx)bench-,pthread-locks): $(libm-benchtests)
@ -270,9 +282,9 @@ bench-link-targets = $(timing-type) $(binaries-bench) $(binaries-benchset) \
$(bench-link-targets): %: %.o $(objpfx)json-lib.o \ $(bench-link-targets): %: %.o $(objpfx)json-lib.o \
$(link-extra-libs-tests) \ $(link-extra-libs-tests) \
$(sort $(filter $(common-objpfx)lib%,$(link-libc))) \ $(sort $(filter $(common-objpfx)lib%,$(link-libc-benchtests))) \
$(addprefix $(csu-objpfx),start.o) $(+preinit) $(+postinit) $(addprefix $(csu-objpfx),start.o) $(+preinit) $(+postinit)
$(+link-tests) $(+link-benchtests)
$(bench-link-targets): LDFLAGS += $(link-bench-bind-now) $(bench-link-targets): LDFLAGS += $(link-bench-bind-now)

View File

@ -62,6 +62,16 @@ otherwise the above command may try to build the benchmark again. Benchmarks
that require generated code to be executed during the build are skipped when that require generated code to be executed during the build are skipped when
cross-building. cross-building.
Building benchmarks as static executables:
=========================================
To build benchmarks as static executables, on the build system, run:
$ make STATIC-BENCHTESTS=yes bench-build
You can copy benchmark executables to another machine and run them
without copying the source nor build directories.
Running subsets of benchmarks: Running subsets of benchmarks:
============================== ==============================