From 0eb6c856063e52fa01f280592c52e3e9dc5555ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Wed, 8 May 2024 23:07:48 +0200 Subject: [PATCH] build: Define glib_sanitizers variable to easily get the sanitizers in use It's an array containing the list of sanitizers in use, normally it contains a value, but in some cases may have more than one (e.g. 'address' and 'undefined'). And so use it to avoid repeated checks --- gio/tests/meson.build | 2 +- girepository/introspection/meson.build | 2 +- meson.build | 5 +++++ 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/gio/tests/meson.build b/gio/tests/meson.build index d6b7f26d5..1821a121e 100644 --- a/gio/tests/meson.build +++ b/gio/tests/meson.build @@ -310,7 +310,7 @@ if host_machine.system() != 'windows' } # LD_PRELOAD modules don't work so well with AddressSanitizer - if have_rtld_next and glib_build_shared and get_option('b_sanitize') == 'none' + if have_rtld_next and glib_build_shared and glib_sanitizers.length() == 0 gio_tests += { 'gsocketclient-slow' : { 'depends' : [ diff --git a/girepository/introspection/meson.build b/girepository/introspection/meson.build index ee2bd1b41..6ed8d6b59 100644 --- a/girepository/introspection/meson.build +++ b/girepository/introspection/meson.build @@ -9,7 +9,7 @@ gi_gen_shared_sources = [ gi_gen_env_variables = environment() -if get_option('b_sanitize') != 'none' +if glib_sanitizers.length() > 0 gi_gen_env_variables.append( 'ASAN_OPTIONS', 'verify_asan_link_order=0', separator: ',') endif diff --git a/meson.build b/meson.build index 8b4294055..aad78f574 100644 --- a/meson.build +++ b/meson.build @@ -635,6 +635,11 @@ endif # improve this. glib_link_flags = cc.get_supported_link_arguments(warning_c_link_args) +glib_sanitizers = get_option('b_sanitize').split(',') +if glib_sanitizers == ['none'] + glib_sanitizers = [] +endif + # Windows SDK requirements and checks if host_system == 'windows' # Check whether we're building for UWP apps