From 808b7f0fde0077c08f9f0920bbcfcd49160612f4 Mon Sep 17 00:00:00 2001 From: notaz Date: Tue, 21 May 2024 01:09:40 +0300 Subject: [PATCH] update libchdr for zstd support --- Makefile | 18 ++++++++++++++---- Makefile.libretro | 4 ++++ jni/Android.mk | 44 ++++++++++++++++++++++++++++++++++---------- pico/cd/libchdr | 2 +- 4 files changed, 53 insertions(+), 15 deletions(-) diff --git a/Makefile b/Makefile index 2566e740b..99c339163 100644 --- a/Makefile +++ b/Makefile @@ -328,16 +328,26 @@ CHDR_OBJS += $(CHDR)/src/libchdr_chd.o $(CHDR)/src/libchdr_cdrom.o CHDR_OBJS += $(CHDR)/src/libchdr_flac.o CHDR_OBJS += $(CHDR)/src/libchdr_bitstream.o $(CHDR)/src/libchdr_huffman.o -# lzma - use 19.00 as newer versions have compile problems with libretro platforms -LZMA = $(CHDR)/deps/lzma-19.00 +LZMA = $(CHDR)/deps/lzma-24.05 LZMA_OBJS += $(LZMA)/src/CpuArch.o $(LZMA)/src/Alloc.o $(LZMA)/src/LzmaEnc.o LZMA_OBJS += $(LZMA)/src/Sort.o $(LZMA)/src/LzmaDec.o $(LZMA)/src/LzFind.o LZMA_OBJS += $(LZMA)/src/Delta.o -$(LZMA_OBJS): CFLAGS += -D_7ZIP_ST +$(LZMA_OBJS): CFLAGS += -DZ7_ST -Wno-unused + +ZSTD = $(CHDR)/deps/zstd-1.5.6/lib +ZSTD_OBJS += $(ZSTD)/common/entropy_common.o $(ZSTD)/common/error_private.o +ZSTD_OBJS += $(ZSTD)/common/fse_decompress.o $(ZSTD)/common/xxhash.o +ZSTD_OBJS += $(ZSTD)/common/zstd_common.o +ZSTD_OBJS += $(ZSTD)/decompress/huf_decompress.o +ZSTD_OBJS += $(ZSTD)/decompress/huf_decompress_amd64.o +ZSTD_OBJS += $(ZSTD)/decompress/zstd_ddict.o +ZSTD_OBJS += $(ZSTD)/decompress/zstd_decompress_block.o +ZSTD_OBJS += $(ZSTD)/decompress/zstd_decompress.o +$(ZSTD_OBJS) $(CHDR_OBJS): CFLAGS += -I$(ZSTD) -Wno-unused OBJS += $(CHDR_OBJS) ifneq ($(STATIC_LINKING), 1) -OBJS += $(LZMA_OBJS) +OBJS += $(LZMA_OBJS) $(ZSTD_OBJS) endif # ouf... prepend includes to overload headers available in the toolchain CFLAGS := -I$(LZMA)/include -I$(CHDR)/include $(CFLAGS) diff --git a/Makefile.libretro b/Makefile.libretro index 9a2e2ebb3..2e37c98cb 100644 --- a/Makefile.libretro +++ b/Makefile.libretro @@ -218,6 +218,7 @@ else ifeq ($(platform), ctr) CXX = $(DEVKITARM)/bin/arm-none-eabi-g++$(EXE_EXT) AR = $(DEVKITARM)/bin/arm-none-eabi-ar$(EXE_EXT) CFLAGS += -DARM11 -D_3DS + CFLAGS += -DZ7_DECL_Int32_AS_long CFLAGS += -march=armv6k -mtune=mpcore -mfloat-abi=hard -marm -mfpu=vfp CFLAGS += -Wall -mword-relocations CFLAGS += -fomit-frame-pointer -ffast-math @@ -269,6 +270,7 @@ else ifeq ($(platform), ngc) CC = $(DEVKITPPC)/bin/powerpc-eabi-gcc$(EXE_EXT) AR = $(DEVKITPPC)/bin/powerpc-eabi-ar$(EXE_EXT) CFLAGS += -DGEKKO -DHW_DOL -mrvl -mcpu=750 -meabi -mhard-float + CFLAGS += -DZ7_DECL_Int32_AS_long STATIC_LINKING = 1 STATIC_LINKING_LINK = 1 @@ -278,6 +280,7 @@ else ifeq ($(platform), wii) CC = $(DEVKITPPC)/bin/powerpc-eabi-gcc$(EXE_EXT) AR = $(DEVKITPPC)/bin/powerpc-eabi-ar$(EXE_EXT) CFLAGS += -DGEKKO -DHW_RVL -mrvl -mcpu=750 -meabi -mhard-float -ffat-lto-objects + CFLAGS += -DZ7_DECL_Int32_AS_long STATIC_LINKING = 1 STATIC_LINKING_LINK = 1 @@ -288,6 +291,7 @@ else ifeq ($(platform), wiiu) CXX = $(DEVKITPPC)/bin/powerpc-eabi-g++$(EXE_EXT) AR = $(DEVKITPPC)/bin/powerpc-eabi-ar$(EXE_EXT) CFLAGS += -DGEKKO -DWIIU -DHW_RVL -DHW_WUP -mwup -mcpu=750 -meabi -mhard-float + CFLAGS += -DZ7_DECL_Int32_AS_long STATIC_LINKING = 1 STATIC_LINKING_LINK = 1 diff --git a/jni/Android.mk b/jni/Android.mk index b4d0143cd..43680aa76 100644 --- a/jni/Android.mk +++ b/jni/Android.mk @@ -53,6 +53,10 @@ endif include $(COMMON_DIR)/common.mak +LCHDR = $(CORE_DIR)/pico/cd/libchdr +LCHDR_LZMA = $(LCHDR)/deps/lzma-24.05 +LCHDR_ZSTD = $(LCHDR)/deps/zstd-1.5.6/lib + SOURCES_C := $(LIBRETRO_DIR)/libretro.c \ $(LIBRETRO_COMM_DIR)/formats/png/rpng.c \ $(LIBRETRO_COMM_DIR)/streams/trans_stream.c \ @@ -70,16 +74,36 @@ SOURCES_C := $(LIBRETRO_DIR)/libretro.c \ $(COMMON_DIR)/mp3_sync.c \ $(COMMON_DIR)/mp3_dummy.c \ $(UNZIP_DIR)/unzip.c \ - $(CORE_DIR)/pico/cd/libchdr/src/libchdr_bitstream.c \ - $(CORE_DIR)/pico/cd/libchdr/src/libchdr_cdrom.c \ - $(CORE_DIR)/pico/cd/libchdr/src/libchdr_chd.c \ - $(CORE_DIR)/pico/cd/libchdr/src/libchdr_flac.c \ - $(CORE_DIR)/pico/cd/libchdr/src/libchdr_huffman.c \ - $(CORE_DIR)/pico/cd/libchdr/deps/lzma-19.00/src/LzFind.c \ - $(CORE_DIR)/pico/cd/libchdr/deps/lzma-19.00/src/LzmaDec.c \ - $(CORE_DIR)/pico/cd/libchdr/deps/lzma-19.00/src/LzmaEnc.c - -COREFLAGS := $(addprefix -D,$(DEFINES)) -fno-strict-aliasing -DUSE_LIBCHDR=1 -D_7ZIP_ST -I$(CORE_DIR)/pico/cd/libchdr/include -I$(CORE_DIR)/pico/cd/libchdr/deps/lzma-19.00/include + $(LCHDR)/src/libchdr_bitstream.c \ + $(LCHDR)/src/libchdr_cdrom.c \ + $(LCHDR)/src/libchdr_chd.c \ + $(LCHDR)/src/libchdr_flac.c \ + $(LCHDR)/src/libchdr_huffman.c \ + $(LCHDR_LZMA)/src/Alloc.c \ + $(LCHDR_LZMA)/src/CpuArch.c \ + $(LCHDR_LZMA)/src/Delta.c \ + $(LCHDR_LZMA)/src/LzFind.c \ + $(LCHDR_LZMA)/src/LzmaDec.c \ + $(LCHDR_LZMA)/src/LzmaEnc.c \ + $(LCHDR_LZMA)/src/Sort.c \ + $(LCHDR_ZSTD)/common/entropy_common.c \ + $(LCHDR_ZSTD)/common/error_private.c \ + $(LCHDR_ZSTD)/common/fse_decompress.c \ + $(LCHDR_ZSTD)/common/xxhash.c \ + $(LCHDR_ZSTD)/common/zstd_common.c \ + $(LCHDR_ZSTD)/decompress/huf_decompress.c \ + $(LCHDR_ZSTD)/decompress/zstd_ddict.c \ + $(LCHDR_ZSTD)/decompress/zstd_decompress_block.c \ + $(LCHDR_ZSTD)/decompress/zstd_decompress.c + +COREFLAGS := $(addprefix -D,$(DEFINES)) -fno-strict-aliasing -DUSE_LIBCHDR=1 -DZ7_ST -DZSTD_DISABLE_ASM +COREFLAGS += -I$(LCHDR)/include -I$(LCHDR_LZMA)/include -I$(LCHDR_ZSTD) +ifeq (,$(call gte,$(APP_PLATFORM_LEVEL),18)) +ifneq ($(TARGET_ARCH_ABI),arm64-v8a) +# HACK +COREFLAGS += -Dgetauxval=0* +endif +endif GIT_REVISION := $(shell git rev-parse --short HEAD || echo unknown) COREFLAGS += -DREVISION=\"$(GIT_REVISION)\" diff --git a/pico/cd/libchdr b/pico/cd/libchdr index 4ad57f9e7..0b5a86fe0 160000 --- a/pico/cd/libchdr +++ b/pico/cd/libchdr @@ -1 +1 @@ -Subproject commit 4ad57f9e71ea35a8e62be20a059463bfe3abf043 +Subproject commit 0b5a86fe0c8b64497d7c6cbc23db72fd6fb1b982