build, add ASAN, some CFLAGS changes, add revision

This commit is contained in:
kub 2023-05-02 19:59:53 +00:00
parent 83a9e30508
commit 3a77090514
5 changed files with 34 additions and 20 deletions

View file

@ -1,5 +1,6 @@
$(LD) ?= $(CC) $(LD) ?= $(CC)
TARGET ?= PicoDrive TARGET ?= PicoDrive
ASAN ?= 0
DEBUG ?= 0 DEBUG ?= 0
CFLAGS += -I$(PWD) CFLAGS += -I$(PWD)
CYCLONE_CC ?= gcc CYCLONE_CC ?= gcc
@ -41,22 +42,41 @@ ifneq ($(findstring gcc,$(shell $(CC) -v 2>&1)),)
endif endif
endif endif
ifeq "$(ASAN)" "1"
CFLAGS += -fsanitize=address -fsanitize=leak -fsanitize=bounds -fno-omit-frame-pointer -fno-common -O1 -g
LDLIBS += -fsanitize=address -fsanitize=leak -fsanitize=bounds -static-libasan
else
ifeq "$(DEBUG)" "0" ifeq "$(DEBUG)" "0"
CFLAGS += -O3 -DNDEBUG CFLAGS += -O3 -DNDEBUG
endif
endif endif
LD = $(CC) LD = $(CC)
OBJOUT ?= -o OBJOUT ?= -o
LINKOUT ?= -o LINKOUT ?= -o
endif endif
chkCCflag = $(shell n=/dev/null; echo $(1) | tr " " "\n" | while read f; do \
$(CC) $$f -x c -c $$n -o $$n 2>$$n && echo "_$$f" | tr -d _; done)
ifeq ("$(PLATFORM)",$(filter "$(PLATFORM)","gp2x" "opendingux" "miyoo" "rpi1")) ifeq ("$(PLATFORM)",$(filter "$(PLATFORM)","gp2x" "opendingux" "miyoo" "rpi1"))
# very small caches, avoid optimization options making the binary much bigger # very small caches, avoid optimization options making the binary much bigger
CFLAGS += -finline-limit=42 -fno-unroll-loops -fno-ipa-cp -ffast-math CFLAGS += -fno-common -fno-stack-protector -finline-limit=42 -fno-unroll-loops -ffast-math
# this gets you about 20% better execution speed on 32bit arm/mips ifneq ($(call chkCCflag, -fipa-ra),) # gcc >= 5
CFLAGS += -fno-common -fno-stack-protector -fno-guess-branch-probability -fno-caller-saves -fno-regmove CFLAGS += $(call chkCCflag, -flto -fipa-pta -fipa-ra)
# Ouf, very old gcc toolchains (pre 4.6) don't have this option: else
CFLAGS += $(shell echo | $(CC) -ftree-loop-if-convert -x c -c -o /dev/null - 2>/dev/null && echo xfno-tree-loop-if-convert | tr x -) # these improve execution speed on 32bit arm/mips with gcc pre-5 toolchains
CFLAGS += -fno-ipa-cp -fno-caller-saves -fno-guess-branch-probability -fno-regmove
# very old gcc toolchains may not have these options
CFLAGS += $(call chkCCflag, -fno-tree-loop-if-convert -fipa-pta)
endif endif
endif
# revision info from repository if this not a tagged release
ifeq "$(shell git describe --tags --exact-match HEAD 2>/dev/null)" ""
REVISION ?= -$(shell git rev-parse --short HEAD || echo ???)
endif
CFLAGS += -DREVISION=\"$(REVISION)\"
# default settings # default settings
use_libchdr ?= 1 use_libchdr ?= 1

View file

@ -40,10 +40,8 @@ STATIC_LINKING_LINK:= 0
LOW_MEMORY := 0 LOW_MEMORY := 0
TARGET_NAME := picodrive TARGET_NAME := picodrive
LIBM := -lm LIBM := -lm
GIT_VERSION ?= $(shell git rev-parse --short HEAD || echo unknown) REVISION ?= -$(shell git rev-parse --short HEAD || echo ???)
ifneq ($(GIT_VERSION),"unknown")
CFLAGS += -DGIT_VERSION=\"$(GIT_VERSION)\"
endif
fpic := fpic :=
@ -68,7 +66,6 @@ else ifneq (,$(findstring x86,$(platform)))
ARCH := 86 ARCH := 86
fpic := -fPIC fpic := -fPIC
SHARED := -shared SHARED := -shared
DONT_COMPILE_IN_ZLIB = 1
CFLAGS += -DFAMEC_NO_GOTOS CFLAGS += -DFAMEC_NO_GOTOS
# AARCH64 generic # AARCH64 generic
@ -77,7 +74,6 @@ else ifeq ($(platform), aarch64)
ARCH = aarch64 ARCH = aarch64
fpic := -fPIC fpic := -fPIC
SHARED := -shared SHARED := -shared
DONT_COMPILE_IN_ZLIB = 1
CFLAGS += -DFAMEC_NO_GOTOS CFLAGS += -DFAMEC_NO_GOTOS
# Portable Linux # Portable Linux
@ -492,7 +488,6 @@ else ifeq ($(platform), miyoo)
SHARED := -shared -nostdlib SHARED := -shared -nostdlib
fpic := -fPIC fpic := -fPIC
LIBM := LIBM :=
DONT_COMPILE_IN_ZLIB = 1
CFLAGS += -fomit-frame-pointer -ffast-math -march=armv5te -mtune=arm926ej-s -D__GCW0__ CFLAGS += -fomit-frame-pointer -ffast-math -march=armv5te -mtune=arm926ej-s -D__GCW0__
HAVE_ARMv6 = 0 HAVE_ARMv6 = 0
LOW_MEMORY = 1 LOW_MEMORY = 1
@ -604,7 +599,7 @@ else
endif endif
CFLAGS += -DNO_ZLIB -D__LIBRETRO__ CFLAGS += -D__LIBRETRO__
ifeq ($(USE_LIBRETRO_VFS),1) ifeq ($(USE_LIBRETRO_VFS),1)
CFLAGS += -DUSE_LIBRETRO_VFS CFLAGS += -DUSE_LIBRETRO_VFS
@ -707,6 +702,8 @@ else
LD = $(CC) LD = $(CC)
endif endif
PLATFORM_ZLIB ?= 1
include Makefile include Makefile
ifeq ($(platform), osx) ifeq ($(platform), osx)

View file

@ -35,7 +35,9 @@
#endif #endif
// FIXME // FIXME
#ifndef REVISION
#define REVISION "0" #define REVISION "0"
#endif
static const char *rom_exts[] = { static const char *rom_exts[] = {
"zip", "bin", "zip", "bin",

View file

@ -1 +1 @@
#define VERSION "1.99" #define VERSION "1.99" REVISION

View file

@ -670,12 +670,7 @@ void retro_get_system_info(struct retro_system_info *info)
{ {
memset(info, 0, sizeof(*info)); memset(info, 0, sizeof(*info));
info->library_name = "PicoDrive"; info->library_name = "PicoDrive";
#ifndef GIT_VERSION info->library_version = VERSION;
#define _GIT_VERSION ""
#else
#define _GIT_VERSION "-" GIT_VERSION
#endif
info->library_version = VERSION _GIT_VERSION;
info->valid_extensions = "bin|gen|smd|md|32x|cue|iso|chd|sms|gg|sg|sc|m3u|68k|sgd|pco"; info->valid_extensions = "bin|gen|smd|md|32x|cue|iso|chd|sms|gg|sg|sc|m3u|68k|sgd|pco";
info->need_fullpath = true; info->need_fullpath = true;
} }