diff options
author | Jose Fonseca <jfonseca@vmware.com> | 2016-04-09 20:26:42 +0100 |
---|---|---|
committer | Jose Fonseca <jfonseca@vmware.com> | 2016-04-13 06:54:32 +0100 |
commit | fa46848e51a619aba5a748316fe8fe4c2e17d243 (patch) | |
tree | 0e3beb3c36eb1940e31ff5aaacd7e39dc02b9a3f /scons | |
parent | d1c89f60050fa5acd0bd1faa993de902631482a0 (diff) |
scons: Allow building with Address Sanitizer.
libasan is never linked to shared objects (which doesn't go well with
-z,defs). It must either be linked to the main executable, or (more
practically for OpenGL drivers) be pre-loaded via LD_PRELOAD.
Otherwise works.
I didn't find anything with llvmpipe. I suspect the fact that the
JIT compiled code isn't instrumented means there are lots of errors it
can't catch.
But for non-JIT drivers, the Address/Leak Sanitizers seem like a faster
alternative to Valgrind.
Usage (Ubuntu 15.10):
scons asan=1 libgl-xlib
export LD_LIBRARY_PATH=$PWD/build/linux-x86_64-debug/gallium/targets/libgl-xlib
LD_PRELOAD=libasan.so.2 any-opengl-application
Acked-by: Roland Scheidegger <sroland@vmware.com>
Diffstat (limited to 'scons')
-rwxr-xr-x | scons/gallium.py | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/scons/gallium.py b/scons/gallium.py index 46520168a0..f37042d9af 100755 --- a/scons/gallium.py +++ b/scons/gallium.py @@ -410,7 +410,7 @@ def generate(env): # Work around aliasing bugs - developers should comment this out ccflags += ['-fno-strict-aliasing'] ccflags += ['-g'] - if env['build'] in ('checked', 'profile'): + if env['build'] in ('checked', 'profile') or env['asan']: # See http://code.google.com/p/jrfonseca/wiki/Gprof2Dot#Which_options_should_I_pass_to_gcc_when_compiling_for_profiling? ccflags += [ '-fno-omit-frame-pointer', @@ -540,6 +540,16 @@ def generate(env): # scan-build will produce more comprehensive output env.Append(CCFLAGS = ['--analyze']) + # https://github.com/google/sanitizers/wiki/AddressSanitizer + if env['asan']: + if gcc_compat: + env.Append(CCFLAGS = [ + '-fsanitize=address', + ]) + env.Append(LINKFLAGS = [ + '-fsanitize=address', + ]) + # Assembler options if gcc_compat: if env['machine'] == 'x86': |