mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
b.sh: Add a build option for address sanitizer. When enabled, we turn on some compatibility options to make it work right.
This commit is contained in:
parent
22e28e218b
commit
67b8c4527d
4 changed files with 14 additions and 3 deletions
|
@ -114,6 +114,7 @@ option(SIMULATOR "Set to ON when targeting an x86 simulator of an ARM platform"
|
|||
option(USE_FFMPEG "Build with FFMPEG support" ${USE_FFMPEG})
|
||||
option(USE_SYSTEM_FFMPEG "Dynamically link against system FFMPEG" ${USE_SYSTEM_FFMPEG})
|
||||
option(USE_WAYLAND_WSI "Set to ON to require Wayland support for Vulkan" ${USE_WAYLAND_WSI})
|
||||
option(USE_ADDRESS_SANITIZER "Use Clang memory sanitizer" ${USE_ADDRESS_SANITIZER})
|
||||
|
||||
if(UNIX AND NOT (APPLE OR ANDROID) AND VULKAN)
|
||||
add_definitions(-DVK_USE_PLATFORM_XLIB_KHR)
|
||||
|
@ -214,6 +215,13 @@ if(NOT MSVC)
|
|||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-switch -Wno-uninitialized")
|
||||
endif()
|
||||
|
||||
if(USE_ADDRESS_SANITIZER)
|
||||
message("Address sanitizer enabled (DEBUG only)")
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS} -fsanitize=address")
|
||||
set(CMAKE_LINKER_FLAGS_DEBUG "${CMAKE_LINKER_FLAGS_DEBUG} -fsanitize=address")
|
||||
add_definitions(-DUSE_ADDRESS_SANITIZER)
|
||||
endif()
|
||||
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g -D_DEBUG")
|
||||
set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} -Os -D_NDEBUG")
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3 -D_NDEBUG")
|
||||
|
|
|
@ -102,7 +102,7 @@ void MemArena::ReleaseView(void* view, size_t size) {
|
|||
|
||||
u8* MemArena::Find4GBBase() {
|
||||
// Now, create views in high memory where there's plenty of space.
|
||||
#if PPSSPP_ARCH(64BIT)
|
||||
#if PPSSPP_ARCH(64BIT) && !defined(USE_ADDRESS_SANITIZER)
|
||||
// Very precarious - mmap cannot return an error when trying to map already used pages.
|
||||
// This makes the Windows approach above unusable on Linux, so we will simply pray...
|
||||
return reinterpret_cast<u8*>(0x2300000000ULL);
|
||||
|
|
|
@ -83,8 +83,8 @@ extern u32 g_MemorySize;
|
|||
extern u32 g_PSPModel;
|
||||
|
||||
// UWP has such limited memory management that we need to mask
|
||||
// even in 64-bit mode.
|
||||
#if PPSSPP_ARCH(32BIT) || PPSSPP_PLATFORM(UWP)
|
||||
// even in 64-bit mode. Also, when using the sanitizer, we need to mask as well.
|
||||
#if PPSSPP_ARCH(32BIT) || PPSSPP_PLATFORM(UWP) || USE_ADDRESS_SANITIZER
|
||||
#define MASKED_PSP_MEMORY
|
||||
#endif
|
||||
|
||||
|
|
3
b.sh
3
b.sh
|
@ -43,6 +43,9 @@ do
|
|||
export CC=/usr/bin/clang
|
||||
export CXX=/usr/bin/clang++
|
||||
;;
|
||||
--sanitize) echo "Enabling address-sanitizer if available"
|
||||
CMAKE_ARGS="-DUSE_ADDRESS_SANITIZER=ON ${CMAKE_ARGS}"
|
||||
;;
|
||||
*) MAKE_OPT="$1 ${MAKE_OPT}"
|
||||
;;
|
||||
esac
|
||||
|
|
Loading…
Add table
Reference in a new issue