1# To build these benchmarks, build the target "ScudoBenchmarks.$ARCH", where
2# $ARCH is the name of the target architecture. For example,
3# ScudoBenchmarks.x86_64 for 64-bit x86. The benchmark executable is then
4# available under projects/compiler-rt/lib/scudo/standalone/benchmarks/ in the
5# build directory.
6
7include(AddLLVM)
8
9set(SCUDO_BENCHMARK_CFLAGS -I${COMPILER_RT_SOURCE_DIR}/lib/scudo/standalone)
10if(ANDROID)
11  list(APPEND SCUDO_BENCHMARK_CFLAGS -fno-emulated-tls)
12endif()
13string(REPLACE ";" " " SCUDO_BENCHMARK_CFLAGS " ${SCUDO_BENCHMARK_CFLAGS}")
14
15foreach(arch ${SCUDO_STANDALONE_SUPPORTED_ARCH})
16  add_benchmark(ScudoBenchmarks.${arch}
17                malloc_benchmark.cpp
18                $<TARGET_OBJECTS:RTScudoStandalone.${arch}>)
19  set_property(TARGET ScudoBenchmarks.${arch} APPEND_STRING PROPERTY
20               COMPILE_FLAGS "${SCUDO_BENCHMARK_CFLAGS}")
21
22  if (COMPILER_RT_HAS_GWP_ASAN)
23    add_benchmark(
24      ScudoBenchmarksWithGwpAsan.${arch} malloc_benchmark.cpp
25      $<TARGET_OBJECTS:RTScudoStandalone.${arch}>
26      $<TARGET_OBJECTS:RTGwpAsan.${arch}>
27      $<TARGET_OBJECTS:RTGwpAsanBacktraceLibc.${arch}>
28      $<TARGET_OBJECTS:RTGwpAsanSegvHandler.${arch}>)
29    set_property(
30      TARGET ScudoBenchmarksWithGwpAsan.${arch} APPEND_STRING PROPERTY
31      COMPILE_FLAGS "${SCUDO_BENCHMARK_CFLAGS} -DGWP_ASAN_HOOKS")
32  endif()
33endforeach()
34