Skip to content

Commit

Permalink
Use __asan_default_options instead of ASAN_OPTIONS
Browse files Browse the repository at this point in the history
  • Loading branch information
Rangi42 committed Dec 31, 2024
1 parent 0ac09da commit abdd51d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
15 changes: 15 additions & 0 deletions src/version.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,21 @@

#include "helpers.hpp"

// We do not build `make develop` with `-fsanitize=leak` because macOS clang++ does not support it.
// Instead, we enable ASan (`-fsanitize=address`) to check for memory leaks in all four programs.
#ifdef __clang__
#if __has_feature(address_sanitizer) && !defined(__SANITIZE_ADDRESS__)
#define __SANITIZE_ADDRESS__
#endif
#endif
#ifdef __SANITIZE_ADDRESS__
extern "C" {
char const *__asan_default_options(void) {
return "detect_leaks=1";
}
}
#endif

// This variable is passed via `-D` from the Makefile, but not from CMake
// (in which `configure_file()` is used on this file to replace some syntax)
#ifndef BUILD_VERSION_STRING
Expand Down
6 changes: 0 additions & 6 deletions test/run-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,6 @@ if [[ ! ( -x ../rgbasm && -x ../rgblink && -x ../rgbfix && -x ../rgbgfx ) ]]; th
false
fi

# We do not compile with `-fsanitize=leak` because macOS clang++ does not support it.
# Instead, enable ASan (`-fsanitize=address`) to check for memory leaks.
if [ "$(uname)" != "Darwin" ]; then
export ASAN_OPTIONS=detect_leaks=1
fi

# Tests included with the repository

for dir in asm link fix gfx; do
Expand Down

0 comments on commit abdd51d

Please sign in to comment.