From: kub Date: Tue, 2 May 2023 19:59:53 +0000 (+0000) Subject: build, add ASAN, some CFLAGS changes, add revision X-Git-Tag: v2.00~234 X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3a77090514c3ba3c1a0286a046bc9fe323e07f27;p=picodrive.git build, add ASAN, some CFLAGS changes, add revision --- diff --git a/Makefile b/Makefile index 8e68a7dc..6abb430d 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,6 @@ $(LD) ?= $(CC) TARGET ?= PicoDrive +ASAN ?= 0 DEBUG ?= 0 CFLAGS += -I$(PWD) CYCLONE_CC ?= gcc @@ -41,22 +42,41 @@ ifneq ($(findstring gcc,$(shell $(CC) -v 2>&1)),) 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" CFLAGS += -O3 -DNDEBUG +endif endif LD = $(CC) OBJOUT ?= -o LINKOUT ?= -o 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")) # very small caches, avoid optimization options making the binary much bigger -CFLAGS += -finline-limit=42 -fno-unroll-loops -fno-ipa-cp -ffast-math -# this gets you about 20% better execution speed on 32bit arm/mips -CFLAGS += -fno-common -fno-stack-protector -fno-guess-branch-probability -fno-caller-saves -fno-regmove -# Ouf, very old gcc toolchains (pre 4.6) don't have this option: -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 -) +CFLAGS += -fno-common -fno-stack-protector -finline-limit=42 -fno-unroll-loops -ffast-math +ifneq ($(call chkCCflag, -fipa-ra),) # gcc >= 5 +CFLAGS += $(call chkCCflag, -flto -fipa-pta -fipa-ra) +else +# 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 + +# 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 use_libchdr ?= 1 diff --git a/Makefile.libretro b/Makefile.libretro index 0d1dc08f..caa22721 100644 --- a/Makefile.libretro +++ b/Makefile.libretro @@ -40,10 +40,8 @@ STATIC_LINKING_LINK:= 0 LOW_MEMORY := 0 TARGET_NAME := picodrive LIBM := -lm -GIT_VERSION ?= $(shell git rev-parse --short HEAD || echo unknown) -ifneq ($(GIT_VERSION),"unknown") - CFLAGS += -DGIT_VERSION=\"$(GIT_VERSION)\" -endif +REVISION ?= -$(shell git rev-parse --short HEAD || echo ???) + fpic := @@ -68,7 +66,6 @@ else ifneq (,$(findstring x86,$(platform))) ARCH := 86 fpic := -fPIC SHARED := -shared - DONT_COMPILE_IN_ZLIB = 1 CFLAGS += -DFAMEC_NO_GOTOS # AARCH64 generic @@ -77,7 +74,6 @@ else ifeq ($(platform), aarch64) ARCH = aarch64 fpic := -fPIC SHARED := -shared - DONT_COMPILE_IN_ZLIB = 1 CFLAGS += -DFAMEC_NO_GOTOS # Portable Linux @@ -492,7 +488,6 @@ else ifeq ($(platform), miyoo) SHARED := -shared -nostdlib fpic := -fPIC LIBM := - DONT_COMPILE_IN_ZLIB = 1 CFLAGS += -fomit-frame-pointer -ffast-math -march=armv5te -mtune=arm926ej-s -D__GCW0__ HAVE_ARMv6 = 0 LOW_MEMORY = 1 @@ -604,7 +599,7 @@ else endif -CFLAGS += -DNO_ZLIB -D__LIBRETRO__ +CFLAGS += -D__LIBRETRO__ ifeq ($(USE_LIBRETRO_VFS),1) CFLAGS += -DUSE_LIBRETRO_VFS @@ -707,6 +702,8 @@ else LD = $(CC) endif +PLATFORM_ZLIB ?= 1 + include Makefile ifeq ($(platform), osx) diff --git a/platform/common/menu_pico.c b/platform/common/menu_pico.c index b839697e..ec34535f 100644 --- a/platform/common/menu_pico.c +++ b/platform/common/menu_pico.c @@ -35,7 +35,9 @@ #endif // FIXME +#ifndef REVISION #define REVISION "0" +#endif static const char *rom_exts[] = { "zip", "bin", diff --git a/platform/common/version.h b/platform/common/version.h index 5ed3a1c3..45138ddb 100644 --- a/platform/common/version.h +++ b/platform/common/version.h @@ -1 +1 @@ -#define VERSION "1.99" +#define VERSION "1.99" REVISION diff --git a/platform/libretro/libretro.c b/platform/libretro/libretro.c index 2ebf31b7..edfef307 100644 --- a/platform/libretro/libretro.c +++ b/platform/libretro/libretro.c @@ -670,12 +670,7 @@ void retro_get_system_info(struct retro_system_info *info) { memset(info, 0, sizeof(*info)); info->library_name = "PicoDrive"; -#ifndef GIT_VERSION -#define _GIT_VERSION "" -#else -#define _GIT_VERSION "-" GIT_VERSION -#endif - info->library_version = VERSION _GIT_VERSION; + info->library_version = VERSION; info->valid_extensions = "bin|gen|smd|md|32x|cue|iso|chd|sms|gg|sg|sc|m3u|68k|sgd|pco"; info->need_fullpath = true; }