forked from memkind/memkind
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure.ac
385 lines (343 loc) · 12.4 KB
/
configure.ac
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
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
# SPDX-License-Identifier: BSD-2-Clause
# Copyright (C) 2014 - 2021 Intel Corporation.
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
AC_PREREQ([2.63])
AC_INIT([memkind],m4_esyscmd([tr -d '\n' < VERSION]))
AC_CONFIG_MACRO_DIR([m4])
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_SRCDIR([memkind.spec.mk])
AM_INIT_AUTOMAKE([-Wall -Werror foreign 1.11 silent-rules subdir-objects parallel-tests tar-pax])
AM_SILENT_RULES([yes])
# Checks for programs and libraries.
m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
AC_PROG_CXX
AC_PROG_CC
AC_OPENMP
AC_CHECK_LIB(numa, numa_available, [], [AC_MSG_ERROR([libnuma is required dependency])])
AX_PTHREAD([LIBS="$PTHREAD_LIBS $LIBS" CFLAGS="$CFLAGS $PTHREAD_CFLAGS" CC="$PTHREAD_CC"],
[AC_MSG_ERROR([pthreads are required dependency])])
AC_SEARCH_LIBS([ceilf], [m])
AM_PROG_CC_C_O
#============================tls===============================================
# Check for thread local storage support
AC_ARG_ENABLE([tls],
[AS_HELP_STRING([--enable-tls], [Enable thread-local storage (__thread keyword)])],
[if test "x$enable_tls" = "xyes" ; then
enable_tls="1"
else
enable_tls="0"
fi
],
[enable_tls="0"]
)
if test "x${enable_tls}" = "x1" ; then
AC_MSG_CHECKING([for TLS support])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
[[
__thread int x;
]], [[
x = 1234;
]])],
AC_MSG_RESULT([yes]),
AC_MSG_RESULT([no])
enable_tls="0")
fi
if test "x${enable_tls}" = "x1" ; then
AC_DEFINE([MEMKIND_TLS], [ ], [Enables TLS usage for mapping arenas to threads])
fi
AC_SUBST([enable_tls])
#============================decorators========================================
AC_ARG_ENABLE([decorators],
[AS_HELP_STRING([--enable-decorators], [Enable decorators])],
[if test "x$enable_decorators" = "xyes" ; then
enable_decorators="1"
else
enable_decorators="0"
fi
],
[enable_decorators="0"]
)
if test "x${enable_decorators}" = "x1" ; then
AC_DEFINE([MEMKIND_DECORATION_ENABLED], [ ], [Enables decorators])
fi
AC_SUBST([enable_decorators])
#============================debug=============================================
AC_ARG_ENABLE([debug],
[AS_HELP_STRING([--enable-debug], [Build debugging code and compile with -O0 -g])],
[if test "x$enable_debug" = "xno" ; then
enable_debug="0"
else
enable_debug="1"
fi
],
[enable_debug="0"]
)
if test "x$enable_debug" = "x1" ; then
AC_DEFINE([MEMKIND_DEBUG], [ ], [Enables code for debugging])
CFLAGS="$CFLAGS -O0 -g"
CXXFLAGS="$CXXFLAGS -O0 -g"
fi
AC_SUBST([enable_debug])
#=======================jemalloc_debug=========================================
AC_ARG_ENABLE([debug-jemalloc],
[AS_HELP_STRING([--enable-debug-jemalloc], [Build debugging jemalloc code])],
[if test "x$enable_debug_jemalloc" = "xno" ; then
enable_debug_jemalloc="0"
else
enable_debug_jemalloc="1"
fi
],
[enable_debug_jemalloc="0"]
)
if test "x$enable_debug_jemalloc" = "x1" ; then
jemalloc_build_type_flags=--enable-debug
else
jemalloc_build_type_flags=--disable-fill
fi
AC_SUBST([jemalloc_build_type_flags])
#============================gcov==============================================
AC_ARG_ENABLE([gcov],
[AS_HELP_STRING([--enable-gcov], [Build code with gcov instructions])],
[if test "x$enable_gcov" = "xno" ; then
enable_gcov="0"
else
enable_gcov="1"
fi
],
[enable_gcov="0"]
)
if test "x$enable_gcov" = "x1" ; then
CFLAGS="$CFLAGS -O0 -fprofile-arcs -ftest-coverage"
CXXFLAGS="$CXXFLAGS -O0 -fprofile-arcs -ftest-coverage"
fi
AC_SUBST([enable_gcov])
#============================secure_flags======================================
AC_ARG_ENABLE([secure],
[AS_HELP_STRING([--enable-secure], [Build library with security enchantments])],
[if test "x$enable_secure" = "xno" ; then
enable_secure="0"
else
enable_secure="1"
fi
],
[enable_secure="1"]
)
if test "x$enable_secure" = "x1" ; then
CFLAGS="$CFLAGS -fstack-protector"
LDFLAGS="$LDFLAGS -Wl,-z,relro,-z,now"
if test "$CFLAGS" != "${CFLAGS%-O0*}" ; then # if CFLAGS contains -O0
echo "WARNING: Could not apply FORTIFY_SOURCE=2 due to lack of optimization (-O0)"
else
CFLAGS="$CFLAGS -D_FORTIFY_SOURCE=2" #FORTITFY_SOURCE does not work with -O0 (ex. if enable_debug=1 or enable_gcov=1)
fi
fi
AC_SUBST([enable_secure])
#============================secure_getenv===============================
AC_CHECK_FUNC([secure_getenv],
[have_secure_getenv="1"],
[have_secure_getenv="0"]
)
if test "x$have_secure_getenv" = "x1" ; then
AC_DEFINE([MEMKIND_HAVE_SECURE_GETENV], [], [Detect secure_getenv])
fi
#============================tcache_max_size_class======================
tcache_max_size_class=12;
AC_DEFINE_UNQUOTED([JEMALLOC_TCACHE_CLASS], $tcache_max_size_class,
[Maximum size class (log base 2) to cache in jemalloc tcache])
AC_SUBST(tcache_max_size_class)
#============================auto_arenas================================
auto_arenas=256;
AC_DEFINE_UNQUOTED([ARENA_LIMIT_DEFAULT_KIND], $auto_arenas,
[Maximum number of automatic managed arenas by jemalloc (used by MEMKIND_DEFAULT)])
AC_SUBST(auto_arenas)
#============================arena_limit=======================================
arena_limit=256;
AC_ARG_VAR(ARENA_LIMIT,
[Upper bound for number of arenas per kind, if set to 0 then no limit]
)
if test "$ARENA_LIMIT" != "" ; then
arena_limit=$ARENA_LIMIT;
fi
AC_DEFINE_UNQUOTED([ARENA_LIMIT_PER_KIND], $arena_limit, [Upper bound for number of arenas per kind])
#============================memkind_prefix=======================================
memkind_prefix=jemk_;
AC_ARG_VAR(MEMKIND_PREFIX,
[Prefix used for all jemalloc public API under memkind, default value jemk_]
)
if test "$MEMKIND_PREFIX" != "" ; then
memkind_prefix=$MEMKIND_PREFIX;
fi
AC_SUBST(memkind_prefix)
#============================memtier_prefix===========================================
memtier_prefix=je_;
AC_ARG_VAR(MEMTIER_PREFIX,
[Prefix used for intercept additional malloc API with libmemtier, default value je_]
)
if test "$MEMTIER_PREFIX" != "" ; then
memtier_prefix=$MEMTIER_PREFIX;
fi
AC_SUBST(memtier_prefix)
if test "$memtier_prefix" == "$memkind_prefix" ; then
AC_MSG_ERROR([MEMTIER_PREFIX and MEMKIND_PREFIX cannot be the same])
fi
#============================min_log_alignment=====================================
min_lg_align_opt="";
AC_ARG_VAR(MIN_LG_ALIGN,
[minimum allocation alignment (base 2 log) used in jemalloc, default value is architecture specific]
)
if test "$MIN_LG_ALIGN" != "" ; then
min_lg_align_opt=--with-lg-quantum=$MIN_LG_ALIGN;
fi
AC_SUBST(min_lg_align_opt)
#============================memkind-initial-exec-tls=====================================
AC_ARG_ENABLE([memkind-initial-exec-tls],
[AS_HELP_STRING([--enable-memkind-initial-exec-tls], [Build library with initial-exec-tls support])],
[if test "x$enable_memkind_initial_exec_tls" = "xno" ; then
enable_memkind_initial_exec_tls="0"
else
enable_memkind_initial_exec_tls="1"
fi
],
[enable_memkind_initial_exec_tls="0"]
)
if test "x$enable_memkind_initial_exec_tls" = "x0" ; then
memkind_initial_exec_tls=--disable-initial-exec-tls;
fi
AC_SUBST(memkind_initial_exec_tls)
#===============================daxctl=========================================
AC_ARG_ENABLE([daxctl],
[AS_HELP_STRING([--enable-daxctl], [Build library with daxctl support])],
[if test "x$enable_daxctl" = "xno" ; then
enable_daxctl="0"
else
enable_daxctl="2"
fi
],
[enable_daxctl="1"]
)
if test "x$enable_daxctl" = "x1" ; then
AC_CHECK_LIB(daxctl, daxctl_dev_get_memory, [daxctl_kmem=yes], [daxctl_kmem=no])
fi
if test "x$enable_daxctl" = "x2" ; then
AC_CHECK_LIB(daxctl, daxctl_dev_get_memory, [daxctl_kmem=yes], [AC_MSG_ERROR([libdaxctl-devel v66 or later is required dependency by --enable-daxctl option])])
fi
if test $daxctl_kmem = "yes" ; then
AC_DEFINE([MEMKIND_DAXCTL_KMEM], [1], [Automatic recognition of PMEM as system memory in MEMKIND_DAX_KMEM])
AC_SUBST(DAXCTL_LIBS, [-ldaxctl])
LDFLAGS="$LDFLAGS -ldaxctl"
fi
AC_SUBST([enable_daxctl])
#===============================hwloc=========================================
AC_ARG_ENABLE([hwloc],
[AS_HELP_STRING([--enable-hwloc], [Build library with hwloc support])],
[if test "x$enable_hwloc" = "xno" ; then
enable_hwloc="0"
else
enable_hwloc="2"
fi
],
[enable_hwloc="1"]
)
if test "x$enable_hwloc" = "x1" ; then
AC_CHECK_LIB(hwloc, hwloc_memattr_get_best_target, [hwloc_hmat=yes], [hwloc_hmat=no])
fi
if test "x$enable_hwloc" = "x2" ; then
AC_CHECK_LIB(hwloc, hwloc_memattr_get_best_target, [hwloc_hmat=yes], [AC_MSG_ERROR([libhwloc-devel v2.3.0 or later is required dependency by --enable-hwloc option])])
fi
if test $hwloc_hmat = "yes" ; then
AC_DEFINE([MEMKIND_HWLOC], [1], [Support for hwloc library])
AC_SUBST(HWLOC_LIBS, [-lhwloc])
LDFLAGS="$LDFLAGS -lhwloc"
fi
AC_SUBST([enable_hwloc])
#===============================heap manager=========================================
AC_ARG_ENABLE([heap_manager],
[AS_HELP_STRING([--disable-heap-manager], [Use only default allocator: jemalloc])],
[if test "x$enable_heap_manager" = "xno" ; then
enable_heap_manager="0"
else
enable_heap_manager="1"
fi
],
[enable_heap_manager="1"]
)
if test "x$enable_heap_manager" = "x1" ; then
AC_DEFINE([MEMKIND_ENABLE_HEAP_MANAGER], [], [Enable heap manager])
fi
AC_SUBST([enable_heap_manager])
#===============================clang-format====================================
clang_support=no;
AC_CHECK_PROGS(CLANG_FORMAT, [clang-format-11 clang-format], "")
if test "$CLANG_FORMAT" != ""; then
CLANG_FORMAT_VERSION=$($CLANG_FORMAT --version)
AX_COMPARE_VERSION([$CLANG_FORMAT_VERSION], [ge], [11.0.0], [clang_support=yes], [])
fi
AC_SUBST([clang_format], $CLANG_FORMAT)
AM_CONDITIONAL([HAVE_CLANG_FORMAT], [test "x$clang_support" = xyes])
AC_CHECK_PROGS(pytest, [pytest pytest-3], false)
#===============================atomic=========================================
AC_CHECK_HEADERS(stdatomic.h)
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
#include <stdint.h>
#include <stdatomic.h>
]],[[
atomic_int v = 8;
atomic_fetch_add_explicit(&v, 1, memory_order_relaxed);
]])], [memkind_c11_atomics="1"], [memkind_c11_atomics="0"])
if test "x$memkind_c11_atomics" = "x1" ; then
AC_DEFINE([MEMKIND_ATOMIC_C11_SUPPORT], [1], [C11 Atomics are supported])
fi
AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],[[
int v = 8;
__atomic_fetch_add(&v, 1, __ATOMIC_RELAXED);
]])], [memkind_atomic_builtins="1"], [memkind_atomic_builtins="0"])
if test "x$memkind_atomic_builtins" = "x1" ; then
AC_DEFINE([MEMKIND_ATOMIC_BUILTINS_SUPPORT], [1], [__atomic_c* compiler builtins are supported])
fi
AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],[[
int v = 8;
__sync_fetch_and_add(&v, 1);
]])], [memkind_sync_fetch="1"], [memkind_sync_fetch="0"])
if test "x$memkind_sync_fetch" = "x1" ; then
AC_DEFINE([MEMKIND_ATOMIC_SYNC_SUPPORT], [1], [__sync_* compiler builtins are supported])
fi
#============================cxx11=============================================
AX_CXX_COMPILE_STDCXX_11([noext], [optional])
AM_CONDITIONAL([HAVE_CXX11], [test "x$HAVE_CXX11" = x1])
LT_PREREQ([2.2])
LT_INIT
AC_CONFIG_FILES([Makefile memkind.pc])
AC_OUTPUT
AC_MSG_RESULT([=================================================================================])
AC_MSG_RESULT([
Memkind version $VERSION])
if test $daxctl_kmem = "yes" ; then
AC_MSG_RESULT([
Automatic recognition of PMEM NUMA in MEMKIND_DAX_KMEM is enabled])
else
AC_MSG_RESULT([
Automatic recognition of PMEM NUMA in MEMKIND_DAX_KMEM is disabled
To enable this feature please install libdaxctl-devel v66 or later
and run configure again])
fi
if test $hwloc_hmat = "yes" ; then
AC_MSG_RESULT([
Utilization of information about memory performance characteristics is enabled])
else
AC_MSG_RESULT([
Utilization of information about memory performance characteristics is disabled
To enable this feature please install libhwloc-devel v2.3.0 or later
and run configure again])
fi
if test "$clang_support" = "yes" ; then
AC_MSG_RESULT([
Automatic code style formatting is enabled
Calling 'make code-style-check' will print suggested style changes
Calling 'make code-style-apply' will apply suggested style changes to code])
else
AC_MSG_RESULT([
Automatic code style formatting is disabled. To enable this feature please
install clang-format v11.0.0 or later and run configure again.])
fi
AC_MSG_RESULT([=================================================================================])