-
Notifications
You must be signed in to change notification settings - Fork 248
Expand file tree
/
Copy pathconfigure.ac
More file actions
executable file
·203 lines (178 loc) · 8.7 KB
/
Copy pathconfigure.ac
File metadata and controls
executable file
·203 lines (178 loc) · 8.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
dnl configure.ac for memtier_benchmark
dnl Copyright (C) 2011-2026 Redis Labs Ltd.
dnl This file is part of memtier_benchmark.
dnl memtier_benchmark is free software: you can redistribute it and/or modify
dnl it under the terms of the GNU General Public License as published by
dnl the Free Software Foundation, version 2.
dnl This program is distributed in the hope that it will be useful,
dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
dnl GNU General Public License for more details.
dnl You should have received a copy of the GNU General Public License
dnl along with this program. If not, see <http://www.gnu.org/licenses/>.
AC_PREREQ(2.59)
AC_INIT(memtier_benchmark,255.255.255,oss@redis.com)
AC_CONFIG_SRCDIR([memtier_benchmark.cpp])
AC_CONFIG_HEADER([config.h])
AM_INIT_AUTOMAKE
AM_SILENT_RULES([yes])
AC_CONFIG_MACRO_DIR([m4])
LT_INIT
# Python is only required for the maintainer-only `make commands-meta` target.
# Resolve to ":" (the no-op shell builtin) when absent so end-user builds keep
# working without Python installed.
AM_PATH_PYTHON([3.6],, [:])
dnl -Werror=vla rejects variable-length arrays at compile time. VLAs on the
dnl worker-thread stack are how PR #405 / issue #404 shipped: an input-sized
dnl `char buffer[N]` blew an 8-12 MB stack the moment a 20 MB MONITOR-replay
dnl line was selected. Keep this hard-error to prevent the next one.
CXXFLAGS="-O2 -g -Wall -Werror=vla -std=c++11 $CXXFLAGS"
# Checks for programs.
AC_PROG_CXX
# Coverage
AX_CODE_COVERAGE
# Checks for header files.
AC_HEADER_STDC
AC_HEADER_DIRENT
AC_CHECK_HEADERS([stdlib.h string.h sys/time.h getopt.h limits.h malloc.h stdlib.h unistd.h utime.h assert.h sys/socket.h sys/types.h])
AC_CHECK_HEADERS([fcntl.h netinet/tcp.h])
AC_CHECK_HEADERS([execinfo.h])
AC_CHECK_HEADERS([pthread.h])
AC_CHECK_HEADERS([zlib.h])
AC_CHECK_HEADERS([event2/event.h])
# Checks for typedefs, structures, and compiler characteristics.
AC_HEADER_STAT
AC_TYPE_SIZE_T
# Checks for library functions.
AC_FUNC_MALLOC
AC_FUNC_MEMCMP
AC_CHECK_FUNCS([gettimeofday memchr memset socket strerror random_r drand48])
# TLS support is optional.
AC_ARG_ENABLE([tls],
[AS_HELP_STRING([--disable-tls],
[Disable TLS/SSL support])])
AS_IF([test "x$enable_tls" != "xno"], [
AC_DEFINE([USE_TLS],
[1],
[define to enable TLS/SSL support])
PKG_CHECK_MODULES([LIBEVENT_OPENSSL],
[libevent_openssl >= 2.0.10],
AC_SUBST(LIBEVENT_OPENSSL_CFLAGS) AC_SUBST(LIBEVENT_OPENSSL_LIBS))
PKG_CHECK_MODULES([LIBSSL],
[libssl],
AC_SUBST(LIBSSL_CFLAGS) AC_SUBST(LIBSSL_LIBS))
PKG_CHECK_MODULES([LIBCRYPTO],
[libcrypto],
AC_SUBST(LIBCRYPTO_CFLAGS) AC_SUBST(LIBCRYPTO_LIBS))
], [])
# Sanitizers support (ASAN/LSAN) is optional.
AC_ARG_ENABLE([sanitizers],
[AS_HELP_STRING([--enable-sanitizers],
[Enable AddressSanitizer and LeakSanitizer for memory error detection])])
AS_IF([test "x$enable_sanitizers" = "xyes"], [
AC_MSG_NOTICE([Enabling AddressSanitizer and LeakSanitizer])
CXXFLAGS="$CXXFLAGS -fsanitize=address -fsanitize=leak -fno-omit-frame-pointer -O1 -g"
LDFLAGS="$LDFLAGS -fsanitize=address -fsanitize=leak"
], [])
# UndefinedBehaviorSanitizer (UBSan) is optional and can be combined with ASAN.
AC_ARG_ENABLE([ubsan],
[AS_HELP_STRING([--enable-ubsan],
[Enable UndefinedBehaviorSanitizer for undefined behavior detection])])
AS_IF([test "x$enable_ubsan" = "xyes"], [
AC_MSG_NOTICE([Enabling UndefinedBehaviorSanitizer])
CXXFLAGS="$CXXFLAGS -fsanitize=undefined -fno-omit-frame-pointer -O1 -g"
LDFLAGS="$LDFLAGS -fsanitize=undefined"
], [])
# Thread Sanitizer (TSAN) is optional and mutually exclusive with ASAN.
AC_ARG_ENABLE([thread-sanitizer],
[AS_HELP_STRING([--enable-thread-sanitizer],
[Enable ThreadSanitizer for data race detection])])
AS_IF([test "x$enable_thread_sanitizer" = "xyes"], [
AS_IF([test "x$enable_sanitizers" = "xyes"], [
AC_MSG_ERROR([--enable-thread-sanitizer and --enable-sanitizers are mutually exclusive])
])
AC_MSG_NOTICE([Enabling ThreadSanitizer])
CXXFLAGS="$CXXFLAGS -fsanitize=thread -fno-omit-frame-pointer -O1 -g"
LDFLAGS="$LDFLAGS -fsanitize=thread"
], [])
# libFuzzer-based in-process fuzz harnesses (requires clang++).
# When enabled, builds tests/fuzz/*_fuzz binaries under noinst_PROGRAMS.
# Does not perturb the main memtier_benchmark binary's build flags.
AC_ARG_ENABLE([fuzz],
[AS_HELP_STRING([--enable-fuzz],
[Build libFuzzer harnesses under tests/fuzz/ (requires clang++)])])
AS_IF([test "x$enable_fuzz" = "xyes"], [
AC_MSG_CHECKING([whether $CXX is clang++])
AS_CASE(["`$CXX --version 2>/dev/null | head -n 1`"],
[*clang*], [AC_MSG_RESULT([yes])],
[AC_MSG_RESULT([no])
AC_MSG_ERROR([--enable-fuzz requires clang++; re-run configure with CXX=clang++ CC=clang])])
AC_MSG_NOTICE([Enabling libFuzzer fuzz harnesses (tests/fuzz/)])
], [])
AM_CONDITIONAL([FUZZ_ENABLED], [test "x$enable_fuzz" = "xyes"])
# clock_gettime requires -lrt on old glibc only.
AC_SEARCH_LIBS([clock_gettime], [rt], , AC_MSG_ERROR([rt is required libevent.]))
AC_CHECK_LIB([z], [deflateInit_], , AC_MSG_ERROR([zlib is required; try installing zlib1g-dev.]))
AC_CHECK_LIB([pthread], [pthread_create], , AC_MSG_ERROR([pthread is required.]))
AC_CHECK_LIB([socket], [gai_strerror])
# libevent
PKG_CHECK_MODULES(LIBEVENT,
[libevent >= 2.0.10],
AC_SUBST(LIBEVENT_CFLAGS) AC_SUBST(LIBEVENT_LIBS)
)
# libevent_pthreads: needed for evthread_use_pthreads(). Without this,
# event_base_loopbreak() / event_base_loopexit() called from a *different*
# thread than the one running event_base_dispatch() do not wake the
# epoll_wait(), so an idle worker hangs after a cross-thread shutdown
# request (Phase 1 of #426 / Ctrl+C). The pthreads bindings ship as a
# separate .so since libevent 2.0, so we have to depend on it explicitly.
PKG_CHECK_MODULES(LIBEVENT_PTHREADS,
[libevent_pthreads >= 2.0.10],
AC_SUBST(LIBEVENT_PTHREADS_CFLAGS) AC_SUBST(LIBEVENT_PTHREADS_LIBS)
)
# Prometheus exporter (evhttp) is optional, default ON. PKG check = non-fatal hygiene;
# the LINK test is the real gate (bare AC_CHECK_HEADERS mis-detects on keg-only Homebrew
# arm64). Link test deliberately uses the NEWEST evhttp symbol the exporter calls
# (>= 2.1.1) so old libevent fails here, loudly.
AC_ARG_ENABLE([prometheus],
[AS_HELP_STRING([--disable-prometheus],
[Disable the Prometheus /metrics HTTP exporter])])
AS_IF([test "x$enable_prometheus" != "xno"], [
PKG_CHECK_MODULES([LIBEVENT_EXTRA], [libevent_extra >= 2.1.1],
[AC_SUBST(LIBEVENT_EXTRA_CFLAGS) AC_SUBST(LIBEVENT_EXTRA_LIBS)],
[LIBEVENT_EXTRA_CFLAGS="" LIBEVENT_EXTRA_LIBS=""])
memtier_saved_CFLAGS="$CFLAGS"; memtier_saved_LIBS="$LIBS"
CFLAGS="$CFLAGS $LIBEVENT_CFLAGS $LIBEVENT_EXTRA_CFLAGS"
LIBS="$LIBEVENT_EXTRA_LIBS $LIBEVENT_LIBS $LIBS"
AC_MSG_CHECKING([whether libevent evhttp is usable (evhttp_request_set_on_complete_cb)])
AC_LINK_IFELSE(
[AC_LANG_PROGRAM([[#include <event2/event.h>
#include <event2/http.h>
static void mt_done_cb(struct evhttp_request *r, void *a) { (void)r; (void)a; }]],
[[struct event_base *b = event_base_new();
struct evhttp *h = evhttp_new(b);
evhttp_request_set_on_complete_cb((struct evhttp_request *)0,
mt_done_cb, (void *)0);
evhttp_free(h); event_base_free(b);]])],
[AC_MSG_RESULT([yes])
AC_DEFINE([HAVE_EVHTTP], [1], [define to enable the Prometheus /metrics exporter])],
[AC_MSG_RESULT([no])
AC_MSG_ERROR([libevent evhttp >= 2.1.1 is required for the Prometheus exporter.
Install libevent development packages (libevent-dev / libevent-devel),
or configure with --disable-prometheus.])])
CFLAGS="$memtier_saved_CFLAGS"; LIBS="$memtier_saved_LIBS"
], [
LIBEVENT_EXTRA_CFLAGS=""
LIBEVENT_EXTRA_LIBS=""
AC_SUBST(LIBEVENT_EXTRA_CFLAGS)
AC_SUBST(LIBEVENT_EXTRA_LIBS)
])
# bash completion
PKG_CHECK_MODULES([BASH_COMPLETION], [bash-completion >= 2.0],
[BASH_COMPLETION_DIR="`pkg-config --variable=completionsdir bash-completion`"],
[BASH_COMPLETION_DIR="$datadir/bash-completion/completions"])
AC_SUBST([BASH_COMPLETION_DIR])
AC_CONFIG_FILES([
Makefile
])
AC_OUTPUT