# existing ASAN_OPTIONS, such that we override the user's value if it
# contains detect_leaks=1.
if [ "${BT_TESTS_ENABLE_ASAN:-}" = "1" ]; then
- lib_asan=$(${BT_TESTS_CC_BIN} -print-file-name=libasan.so)
+ if ${BT_TESTS_CC_BIN} --version | head -n 1 | grep -q '^gcc'; then
+ lib_asan=$(${BT_TESTS_CC_BIN} -print-file-name=libasan.so)
+ env_args+=("LD_PRELOAD=${lib_asan}:${LD_PRELOAD:-}")
+ fi
- env_args+=("LD_PRELOAD=${lib_asan}:${LD_PRELOAD:-}")
env_args+=("ASAN_OPTIONS=${ASAN_OPTIONS:-},detect_leaks=0")
fi