From d261f3e8fe3f2afe4209066c8bc3f069d60e7ced Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niccol=C3=B2=20Izzo?= Date: Fri, 13 Nov 2020 12:38:39 +0100 Subject: [PATCH] Add optional AddressSanitizer --- meson.build | 18 +++++++++++++----- meson_options.txt | 1 + 2 files changed, 14 insertions(+), 5 deletions(-) create mode 100644 meson_options.txt diff --git a/meson.build b/meson.build index 17249a7b..af55ec4a 100644 --- a/meson.build +++ b/meson.build @@ -154,12 +154,20 @@ mduv380_inc = inc + stm32f405_inc + ['platform/targets/MD-UV380'] ## ## Compilation defines ## -linux_args = [] +linux_c_args = [] +linux_l_args = ['--entry=systemBootstrap'] + +# Add AddressSanitizer if required +if get_option('asan') + linux_c_args += '-fsanitize=address' + linux_l_args += '-fsanitize=address' +endif + foreach k, v : linux_def if v == '' - linux_args += '-D@0@'.format(k) + linux_c_args += '-D@0@'.format(k) else - linux_args += '-D@0@=@1@'.format(k, v) + linux_c_args += '-D@0@=@1@'.format(k, v) endif endforeach @@ -182,10 +190,10 @@ foreach k, v : mduv380_def endforeach linux_opts = {'sources': linux_src, - 'c_args': linux_args, + 'c_args': linux_c_args, 'include_directories': linux_inc, 'dependencies': linux_dep, - 'link_args' : '--entry=systemBootstrap'} + 'link_args' : linux_l_args} md380_opts = {'sources': md380_src, 'c_args': md380_args, diff --git a/meson_options.txt b/meson_options.txt new file mode 100644 index 00000000..e99a9310 --- /dev/null +++ b/meson_options.txt @@ -0,0 +1 @@ +option('asan', type : 'boolean', value : false, description : 'Compile the software with AddressSanitizer')