+ local -x LD_LIBRARY_PATH=$main_lib_path${LD_LIBRARY_PATH:+:}${LD_LIBRARY_PATH:-}
+ fi
+
+ # On Windows, an embedded Python 3 interpreter needs a way to locate
+ # the path to its internal modules: set the `PYTHONHOME` variable to
+ # the prefix from `python3-config`.
+ if [[ $BT_TESTS_OS_TYPE == mingw ]]; then
+ local -x PYTHONHOME
+
+ PYTHONHOME=$("$BT_TESTS_PYTHON_CONFIG_BIN" --prefix)
+ fi
+
+ # If AddressSanitizer is used, we must preload `libasan.so` so that
+ # libasan doesn't complain about not being the first loaded library.
+ #
+ # Python and sed (executed as part of the Libtool wrapper) produce
+ # some leaks, so we must unfortunately disable leak detection.
+ #
+ # Append it to existing `ASAN_OPTIONS` variable, such that we
+ # override the user's value if it contains `detect_leaks=1`.
+ if [[ ${BT_TESTS_ENABLE_ASAN:-} == 1 ]]; then
+ if "$BT_TESTS_CC_BIN" --version | head -n 1 | bt_grep -q '^gcc'; then
+ local -r lib_asan=$("$BT_TESTS_CC_BIN" -print-file-name=libasan.so)
+ local -x LD_PRELOAD=$lib_asan${LD_PRELOAD:+:}${LD_PRELOAD:-}
+ fi
+
+ local -x ASAN_OPTIONS=${ASAN_OPTIONS:-}${ASAN_OPTIONS:+,}detect_leaks=0