Skip to content

Commit 711e738

Browse files
committed
meson: Simplify asan-options handling even more
Instead of specifying env variables all the time we can instead embed the __asan_default_options symbol in all executables / shared objects. This reduces code duplication.
1 parent d9cabdd commit 711e738

File tree

16 files changed

+12
-26
lines changed

16 files changed

+12
-26
lines changed

doc/manual/meson.build

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ pymod = import('python')
1515
python = pymod.find_installation('python3')
1616

1717
nix_env_for_docs = {
18-
'ASAN_OPTIONS' : 'abort_on_error=1:print_summary=1:detect_leaks=0',
1918
'HOME' : '/dummy',
2019
'NIX_CONF_DIR' : '/dummy',
2120
'NIX_SSL_CERT_FILE' : '/dummy/no-ca-bundle.crt',

src/nix/asan-options.cc renamed to nix-meson-build-support/common/asan-options/asan-options.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
extern "C" [[gnu::retain]] const char * __asan_default_options()
1+
extern "C" [[gnu::retain, gnu::weak]] const char * __asan_default_options()
22
{
33
// We leak a bunch of memory knowingly on purpose. It's not worthwhile to
44
// diagnose that memory being leaked for now.
Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
asan_test_options_env = {
2-
'ASAN_OPTIONS' : 'abort_on_error=1:print_summary=1:detect_leaks=0',
3-
}
4-
51
# Clang gets grumpy about missing libasan symbols if -shared-libasan is not
62
# passed when building shared libs, at least on Linux
73
if cxx.get_id() == 'clang' and ('address' in get_option('b_sanitize') or 'undefined' in get_option(
@@ -10,3 +6,6 @@ if cxx.get_id() == 'clang' and ('address' in get_option('b_sanitize') or 'undefi
106
add_project_link_arguments('-shared-libasan', language : 'cpp')
117
endif
128

9+
if 'address' in get_option('b_sanitize')
10+
deps_other += declare_dependency(sources : 'asan-options.cc')
11+
endif

src/libexpr-tests/meson.build

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ this_exe = executable(
8282
test(
8383
meson.project_name(),
8484
this_exe,
85-
env : asan_test_options_env + {
85+
env : {
8686
'_NIX_TEST_UNIT_DATA' : meson.current_source_dir() / 'data',
8787
},
8888
protocol : 'gtest',

src/libexpr-tests/package.nix

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ mkMesonExecutable (finalAttrs: {
6262
mkdir -p "$HOME"
6363
''
6464
+ ''
65-
export ASAN_OPTIONS=abort_on_error=1:print_summary=1:detect_leaks=0
6665
export _NIX_TEST_UNIT_DATA=${resolvePath ./data}
6766
${stdenv.hostPlatform.emulator buildPackages} ${lib.getExe finalAttrs.finalPackage}
6867
touch $out

src/libfetchers-tests/meson.build

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ this_exe = executable(
6363
test(
6464
meson.project_name(),
6565
this_exe,
66-
env : asan_test_options_env + {
66+
env : {
6767
'_NIX_TEST_UNIT_DATA' : meson.current_source_dir() / 'data',
6868
},
6969
protocol : 'gtest',

src/libfetchers-tests/package.nix

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ mkMesonExecutable (finalAttrs: {
6161
buildInputs = [ writableTmpDirAsHomeHook ];
6262
}
6363
''
64-
export ASAN_OPTIONS=abort_on_error=1:print_summary=1:detect_leaks=0
6564
export _NIX_TEST_UNIT_DATA=${resolvePath ./data}
6665
${stdenv.hostPlatform.emulator buildPackages} ${lib.getExe finalAttrs.finalPackage}
6766
touch $out

src/libflake-tests/meson.build

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ this_exe = executable(
5858
test(
5959
meson.project_name(),
6060
this_exe,
61-
env : asan_test_options_env + {
61+
env : {
6262
'_NIX_TEST_UNIT_DATA' : meson.current_source_dir() / 'data',
6363
'NIX_CONFIG' : 'extra-experimental-features = flakes',
6464
'HOME' : meson.current_build_dir() / 'test-home',

src/libflake-tests/package.nix

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ mkMesonExecutable (finalAttrs: {
5959
buildInputs = [ writableTmpDirAsHomeHook ];
6060
}
6161
(''
62-
export ASAN_OPTIONS=abort_on_error=1:print_summary=1:detect_leaks=0
6362
export _NIX_TEST_UNIT_DATA=${resolvePath ./data}
6463
export NIX_CONFIG="extra-experimental-features = flakes"
6564
${stdenv.hostPlatform.emulator buildPackages} ${lib.getExe finalAttrs.finalPackage}

src/libstore-tests/meson.build

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ this_exe = executable(
104104
test(
105105
meson.project_name(),
106106
this_exe,
107-
env : asan_test_options_env + {
107+
env : {
108108
'_NIX_TEST_UNIT_DATA' : meson.current_source_dir() / 'data',
109109
'HOME' : meson.current_build_dir() / 'test-home',
110110
'NIX_REMOTE' : meson.current_build_dir() / 'test-home' / 'store',
@@ -138,7 +138,7 @@ if get_option('benchmarks')
138138
benchmark(
139139
'nix-store-benchmarks',
140140
benchmark_exe,
141-
env : asan_test_options_env + {
141+
env : {
142142
'_NIX_TEST_UNIT_DATA' : meson.current_source_dir() / 'data',
143143
},
144144
)

0 commit comments

Comments
 (0)