mirror of https://github.com/PCSX2/pcsx2.git
gcc: support address sanitizer
This commit is contained in:
parent
8c03d50421
commit
c60fefa1a6
6
build.sh
6
build.sh
|
@ -30,6 +30,7 @@ do
|
|||
--gles ) flags="$flags -DGLES_API=TRUE" ;;
|
||||
--sdl2 ) flags="$flags -DSDL2_API=TRUE" ;;
|
||||
--extra ) flags="$flags -DEXTRA_PLUGINS=TRUE" ;;
|
||||
--asan ) flags="$flags -DUSE_ASAN=TRUE";;
|
||||
--clang ) use_clang=1; flags="$flags -DUSE_CLANG=TRUE" ;;
|
||||
--clean ) clean_build=1 ;;
|
||||
|
||||
|
@ -40,8 +41,11 @@ do
|
|||
echo "--debug : Build PCSX2 as a Debug build."
|
||||
echo "--release : Build PCSX2 as a Release build."
|
||||
echo "--clean : Do a clean build."
|
||||
echo "--extra : Build all plugins"
|
||||
echo "** Developper option **"
|
||||
echo "--clang : Build with Clang/llvm"
|
||||
echo "--extra : Build all plugins"
|
||||
echo "--asan : Enable with Address sanitizer"
|
||||
echo ""
|
||||
echo "--glsl : Replace CG backend of ZZogl by GLSL"
|
||||
echo "--egl : Replace GLX by EGL (ZZogl plugins only)"
|
||||
echo "--sdl2 : Build with SDL2 (crash if wx is linked to SDL1)"
|
||||
|
|
|
@ -53,6 +53,7 @@ endif(PACKAGE_MODE)
|
|||
# Compiler extra
|
||||
#-------------------------------------------------------------------------------
|
||||
option(USE_CLANG "Use llvm/clang to build PCSX2 (developer option)")
|
||||
option(USE_ASAN "Enable address sanitizer")
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Select the architecture
|
||||
|
@ -204,7 +205,13 @@ else()
|
|||
set(DEBUG_FLAG "")
|
||||
endif()
|
||||
|
||||
set(DEFAULT_GCC_FLAG "${ARCH_FLAG} ${COMMON_FLAG} ${DEFAULT_WARNINGS} ${HARDENING_FLAG} ${DEBUG_FLAG}")
|
||||
if (USE_ASAN)
|
||||
set(ASAN_FLAG "-fsanitize=address -fno-omit-frame-pointer -g -mpreferred-stack-boundary=4 -mincoming-stack-boundary=2 -DASAN_WORKAROUND")
|
||||
else()
|
||||
set(ASAN_FLAG "")
|
||||
endif()
|
||||
|
||||
set(DEFAULT_GCC_FLAG "${ARCH_FLAG} ${COMMON_FLAG} ${DEFAULT_WARNINGS} ${HARDENING_FLAG} ${DEBUG_FLAG} ${ASAN_FLAG}")
|
||||
# c++ only flags
|
||||
set(DEFAULT_CPP_FLAG "${DEFAULT_GCC_FLAG} -Wno-invalid-offsetof")
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ void* __fastcall pcsx2_aligned_malloc(size_t size, size_t align)
|
|||
{
|
||||
pxAssert( align < 0x10000 );
|
||||
|
||||
#ifdef __USE_ISOC11
|
||||
#if defined(__USE_ISOC11) && !defined(ASAN_WORKAROUND) // not supported yet on gcc 4.9
|
||||
return aligned_alloc(align, size);
|
||||
#else
|
||||
u8* p = (u8*)malloc(size+align+headsize);
|
||||
|
@ -57,7 +57,7 @@ void* __fastcall pcsx2_aligned_realloc(void* handle, size_t size, size_t align)
|
|||
|
||||
if( handle != NULL )
|
||||
{
|
||||
#ifdef __USE_ISOC11
|
||||
#if defined(__USE_ISOC11) && !defined(ASAN_WORKAROUND) // not supported yet on gcc 4.9
|
||||
memcpy_fast( newbuf, handle, size );
|
||||
free( handle );
|
||||
#else
|
||||
|
@ -71,7 +71,7 @@ void* __fastcall pcsx2_aligned_realloc(void* handle, size_t size, size_t align)
|
|||
|
||||
__fi void pcsx2_aligned_free(void* pmem)
|
||||
{
|
||||
#ifdef __USE_ISOC11
|
||||
#if defined(__USE_ISOC11) && !defined(ASAN_WORKAROUND) // not supported yet on gcc 4.9
|
||||
free(pmem);
|
||||
#else
|
||||
if( pmem == NULL ) return;
|
||||
|
|
|
@ -107,7 +107,7 @@ void vmfree(void* ptr, size_t size)
|
|||
|
||||
// declare linux equivalents (alignment must be power of 2 (1,2,4...2^15)
|
||||
|
||||
#if !defined(__USE_ISOC11)
|
||||
#if !defined(__USE_ISOC11) || defined(ASAN_WORKAROUND)
|
||||
|
||||
void* _aligned_malloc(size_t size, size_t alignment)
|
||||
{
|
||||
|
|
|
@ -358,7 +358,7 @@ struct aligned_free_second {template<class T> void operator()(T& p) {_aligned_fr
|
|||
|
||||
#if !defined(_MSC_VER)
|
||||
|
||||
#if defined(__USE_ISOC11)
|
||||
#if defined(__USE_ISOC11) && !defined(ASAN_WORKAROUND) // not supported yet on gcc 4.9
|
||||
|
||||
#define _aligned_malloc(size, a) aligned_alloc(a, size)
|
||||
static inline void _aligned_free(void* p) { free(p); }
|
||||
|
|
Loading…
Reference in New Issue