|
38 | 38 | LDD=ldd |
39 | 39 | fi |
40 | 40 |
|
41 | | -TEMP=`getopt -o v: --long headers:,libs:,cc:,cxx:,with-glog,with-thrift,with-rdma,with-mesalink,with-bthread-tracer,with-debug-bthread-sche-safety,with-debug-lock,nodebugsymbols,werror -n 'config_brpc' -- "$@"` |
| 41 | +TEMP=`getopt -o v: --long headers:,libs:,cc:,cxx:,with-glog,with-thrift,with-rdma,with-mesalink,with-bthread-tracer,with-debug-bthread-sche-safety,with-debug-lock,with-asan,nodebugsymbols,werror -n 'config_brpc' -- "$@"` |
42 | 42 | WITH_GLOG=0 |
43 | 43 | WITH_THRIFT=0 |
44 | 44 | WITH_RDMA=0 |
45 | 45 | WITH_MESALINK=0 |
46 | 46 | WITH_BTHREAD_TRACER=0 |
| 47 | +WITH_ASAN=0 |
47 | 48 | BRPC_DEBUG_BTHREAD_SCHE_SAFETY=0 |
48 | 49 | DEBUGSYMBOLS=-g |
49 | 50 | WERROR= |
@@ -74,6 +75,7 @@ while true; do |
74 | 75 | --with-bthread-tracer) WITH_BTHREAD_TRACER=1; shift 1 ;; |
75 | 76 | --with-debug-bthread-sche-safety ) BRPC_DEBUG_BTHREAD_SCHE_SAFETY=1; shift 1 ;; |
76 | 77 | --with-debug-lock ) BRPC_DEBUG_LOCK=1; shift 1 ;; |
| 78 | + --with-asan) WITH_ASAN=1; shift 1 ;; |
77 | 79 | --nodebugsymbols ) DEBUGSYMBOLS=; shift 1 ;; |
78 | 80 | --werror ) WERROR=-Werror; shift 1 ;; |
79 | 81 | -- ) shift; break ;; |
@@ -345,10 +347,15 @@ else |
345 | 347 | CXXFLAGS="-std=c++0x" |
346 | 348 | fi |
347 | 349 |
|
348 | | -LEVELDB_HDR=$(find_dir_of_header_or_die leveldb/db.h) |
349 | | - |
350 | 350 | CPPFLAGS= |
351 | 351 |
|
| 352 | +if [ $WITH_ASAN != 0 ]; then |
| 353 | + CPPFLAGS="${CPPFLAGS} -fsanitize=address" |
| 354 | + DYNAMIC_LINKINGS="$DYNAMIC_LINKINGS -fsanitize=address" |
| 355 | +fi |
| 356 | + |
| 357 | +LEVELDB_HDR=$(find_dir_of_header_or_die leveldb/db.h) |
| 358 | + |
352 | 359 | if [ $WITH_BTHREAD_TRACER != 0 ]; then |
353 | 360 | if [ "$SYSTEM" != "Linux" ] || [ "$(uname -m)" != "x86_64" ]; then |
354 | 361 | >&2 $ECHO "bthread tracer is only supported on Linux x86_64 platform" |
@@ -425,7 +432,7 @@ append_to_output "STATIC_LINKINGS=$STATIC_LINKINGS" |
425 | 432 | append_to_output "DYNAMIC_LINKINGS=$DYNAMIC_LINKINGS" |
426 | 433 |
|
427 | 434 | # CPP means C PreProcessing, not C PlusPlus |
428 | | -CPPFLAGS="${CPPFLAGS} -DBRPC_WITH_GLOG=$WITH_GLOG -DBRPC_DEBUG_BTHREAD_SCHE_SAFETY=$BRPC_DEBUG_BTHREAD_SCHE_SAFETY -DBRPC_DEBUG_LOCK=$BRPC_DEBUG_LOCK" |
| 435 | +CPPFLAGS="${CPPFLAGS} -DBRPC_WITH_GLOG=$WITH_GLOG -DBRPC_DEBUG_BTHREAD_SCHE_SAFETY=$BRPC_DEBUG_BTHREAD_SCHE_SAFETY -DBRPC_DEBUG_LOCK=$BRPC_DEBUG_LOCK" |
429 | 436 |
|
430 | 437 | # Avoid over-optimizations of TLS variables by GCC>=4.8 |
431 | 438 | # See: https://github.com/apache/brpc/issues/1693 |
@@ -523,7 +530,10 @@ append_to_output "ifeq (\$(NEED_GPERFTOOLS), 1)" |
523 | 530 | TCMALLOC_LIB=$(find_dir_of_lib tcmalloc_and_profiler) |
524 | 531 | if [ -z "$TCMALLOC_LIB" ]; then |
525 | 532 | append_to_output " \$(error \"Fail to find gperftools\")" |
| 533 | +elif [ $WITH_ASAN != 0 ]; then |
| 534 | + append_to_output " \$(error \"gperftools is not compatible with ASAN\")" |
526 | 535 | else |
| 536 | + append_to_output " CPPFLAGS+=-DBRPC_ENABLE_CPU_PROFILER" |
527 | 537 | append_to_output_libs "$TCMALLOC_LIB" " " |
528 | 538 | if [ -f $TCMALLOC_LIB/libtcmalloc.$SO ]; then |
529 | 539 | append_to_output " DYNAMIC_LINKINGS+=-ltcmalloc_and_profiler" |
|
0 commit comments