Skip to content

Commit 7fe6ec3

Browse files
kanard38knard38
authored andcommitted
DAOS-16501 build: Support of mercury with ASan
Instrument mercury with libasan according to build option SANITIZERS Signed-off-by: Cedric Koch-Hofer <cedric.koch-hofer@hpe.com>
1 parent 77eef6a commit 7fe6ec3

File tree

5 files changed

+34
-4
lines changed

5 files changed

+34
-4
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
diff --git a/CMakeLists.txt b/CMakeLists.txt
2+
index b075819..a764bc6 100644
3+
--- a/CMakeLists.txt
4+
+++ b/CMakeLists.txt
5+
@@ -229,9 +229,9 @@ function(mercury_set_lib_options libtarget libname libtype var_prefix)
6+
OUTPUT_NAME_RELEASE ${LIB_RELEASE_NAME}
7+
OUTPUT_NAME_MINSIZEREL ${LIB_RELEASE_NAME}
8+
OUTPUT_NAME_RELWITHDEBINFO ${LIB_RELEASE_NAME}
9+
- OUTPUT_NAME_ASAN ${LIB_DEBUG_NAME}
10+
- OUTPUT_NAME_TSAN ${LIB_DEBUG_NAME}
11+
- OUTPUT_NAME_UBSAN ${LIB_DEBUG_NAME}
12+
+ OUTPUT_NAME_ASAN ${LIB_RELEASE_NAME}
13+
+ OUTPUT_NAME_TSAN ${LIB_RELEASE_NAME}
14+
+ OUTPUT_NAME_UBSAN ${LIB_RELEASE_NAME}
15+
)
16+
if(${libtype} MATCHES "SHARED")
17+
set_target_properties(${libtarget}

docs/dev/development.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,11 +138,12 @@ such as maximum function stack size, may lead to unexpected behavior in the inst
138138
binaries.
139139

140140
#### Customizing ASan Behavior
141+
141142
ASan behavior can be configured using the `ASAN_OPTIONS` environment variable. For example, you can
142143
add the following entry to the `env_vars` section of the `daos_server.yml` configuration file:
143144
```yaml
144145
engines:
145-
- ..
146+
- ...
146147
env_vars:
147148
...
148149
- ASAN_OPTIONS=atexit=1:print_stats=1:log_path=/tmp/daos_engine0.asan:disable_coredump=1:handle_segv=2:handle_abort=2:handle_sigfpe=2:handle_sigill=2:handle_sigbus=2:use_sigaltstack=1

site_scons/components/__init__.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,6 @@ def define_mercury(reqs):
187187

188188
mercury_build = ['cmake',
189189
'-DBUILD_SHARED_LIBS:BOOL=ON',
190-
'-DCMAKE_BUILD_TYPE:STRING=RelWithDebInfo',
191190
'-DCMAKE_CXX_FLAGS:STRING="-std=c++11"',
192191
'-DCMAKE_INSTALL_PREFIX:PATH=$MERCURY_PREFIX',
193192
'-DMERCURY_INSTALL_LIB_DIR:PATH=$MERCURY_PREFIX/lib64',
@@ -208,6 +207,19 @@ def define_mercury(reqs):
208207
'-DNA_USE_UCX:BOOL=ON',
209208
'../mercury']
210209

210+
build_type = "RelWithDebInfo"
211+
try:
212+
sanitizers = reqs.get_env('SANITIZERS').split(',')
213+
if 'address' in sanitizers:
214+
build_type = "Asan"
215+
elif 'thread' in sanitizers:
216+
build_type = "Tsan"
217+
elif 'undefined' in sanitizers:
218+
build_type = "Ubsan"
219+
except KeyError:
220+
pass
221+
mercury_build.append(f'-DCMAKE_BUILD_TYPE:STRING={build_type}')
222+
211223
if reqs.target_type == 'debug':
212224
mercury_build.append('-DMERCURY_ENABLE_DEBUG:BOOL=ON')
213225
else:

site_scons/prereq_tools/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,7 @@ def __init__(self, env, opts):
517517
['gcc', 'covc', 'clang', 'icc'], ignorecase=2))
518518
opts.Add(EnumVariable('WARNING_LEVEL', "Set default warning level", 'error',
519519
['warning', 'warn', 'error'], ignorecase=2))
520-
opts.Add(('SANITIZERS', 'Instrument C code with google sanitizers', None))
520+
opts.Add(('SANITIZERS', 'Instrument C code with Google Sanitizers', None))
521521

522522
opts.Update(self.__env)
523523

utils/build.config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,5 @@ ucx=https://github.com/openucx/ucx.git
2727

2828
[patch_versions]
2929
spdk=0001_b0aba3fcd5aceceea530a702922153bc75664978.diff,0002_445a4c808badbad3942696ecf16fa60e8129a747.diff
30-
mercury=0001_na_ucx.patch,0002_na_ucx_ep_flush.patch,0003_combined_plugin_path.patch
30+
mercury=0001_na_ucx.patch,0002_na_ucx_ep_flush.patch,0003_combined_plugin_path.patch,0004_asan_workaround.patch
3131
argobots=0001_411e5b344642ebc82190fd8b125db512e5b449d1.diff,0002_bb0c908abfac4bfe37852eee621930634183c6aa.diff

0 commit comments

Comments
 (0)