summaryrefslogtreecommitdiff
path: root/emulators/mame
diff options
context:
space:
mode:
authorRobert Clausecker <fuz@FreeBSD.org>2023-06-25 18:58:55 +0200
committerRobert Clausecker <fuz@FreeBSD.org>2023-06-27 01:30:28 +0200
commitcb40b0a43949a621f407fa3b65dff7349b024ba2 (patch)
treeace4d110caf6b78f6aeff3e74ba72f7c3a8beeaa /emulators/mame
parentemulators/qmc2: fix build on armv7 and arm64 (diff)
emulators/mame: fix build on armv7 and arm64
Port now bundles LZMA with known build issues. Import patch set from archivers/7-zip to fix the build on armv7 and arm64. PR: 271987 Approved by: portmgr (build fix blanket) Obtained from: archivers/7-zip
Diffstat (limited to 'emulators/mame')
-rw-r--r--emulators/mame/Makefile3
-rw-r--r--emulators/mame/files/patch-3rdparty_lzma_CPP_7zip_7zip__gcc.mak27
-rw-r--r--emulators/mame/files/patch-3rdparty_lzma_CPP_7zip_var__gcc.mak12
-rw-r--r--emulators/mame/files/patch-3rdparty_lzma_CPP_Windows_SystemInfo.cpp27
-rw-r--r--emulators/mame/files/patch-3rdparty_lzma_C_7zCrc.c11
-rw-r--r--emulators/mame/files/patch-3rdparty_lzma_C_Aes.c11
-rw-r--r--emulators/mame/files/patch-3rdparty_lzma_C_AesOpt.c38
-rw-r--r--emulators/mame/files/patch-3rdparty_lzma_C_CpuArch.c42
-rw-r--r--emulators/mame/files/patch-3rdparty_lzma_C_Sha256Opt.c11
9 files changed, 182 insertions, 0 deletions
diff --git a/emulators/mame/Makefile b/emulators/mame/Makefile
index ffeae0127dc2..07f8578e0c3c 100644
--- a/emulators/mame/Makefile
+++ b/emulators/mame/Makefile
@@ -1,5 +1,6 @@
PORTNAME= mame
DISTVERSION= 0.255
+PORTREVISION= 1
CATEGORIES= emulators games
MAINTAINER= agh@riseup.net
@@ -67,6 +68,8 @@ MAKE_ENV= LDOPTS="${LDFLAGS}" \
USE_SYSTEM_LIB_ZLIB=1 \
USE_TAPTUN=1
+CFLAGS_aarch64= -march=armv8-a+crc+crypto
+
SUB_FILES= pkg-message mame.ini plugin.ini ui.ini
PORTDOCS= html/*
diff --git a/emulators/mame/files/patch-3rdparty_lzma_CPP_7zip_7zip__gcc.mak b/emulators/mame/files/patch-3rdparty_lzma_CPP_7zip_7zip__gcc.mak
new file mode 100644
index 000000000000..3949c6e06167
--- /dev/null
+++ b/emulators/mame/files/patch-3rdparty_lzma_CPP_7zip_7zip__gcc.mak
@@ -0,0 +1,27 @@
+--- 3rdparty/lzma/CPP/7zip/7zip_gcc.mak.orig 2023-05-30 17:50:57 UTC
++++ 3rdparty/lzma/CPP/7zip/7zip_gcc.mak
+@@ -18,13 +18,13 @@ PROGPATH_STATIC = $(O)/$(PROG)s
+
+
+ ifneq ($(CC), xlc)
+-CFLAGS_WARN_WALL = -Wall -Werror -Wextra
++CFLAGS_WARN_WALL =
+ endif
+
+ # for object file
+ CFLAGS_BASE_LIST = -c
+ # CFLAGS_BASE_LIST = -S
+-CFLAGS_BASE = -O2 $(CFLAGS_BASE_LIST) $(CFLAGS_WARN_WALL) $(CFLAGS_WARN) \
++CFLAGS_BASE = $(CFLAGS_BASE_LIST) $(CFLAGS_WARN_WALL) $(CFLAGS_WARN) \
+ -DNDEBUG -D_REENTRANT -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE \
+ -fPIC
+
+@@ -131,7 +131,7 @@ DEL_OBJ_EXE = -$(RM) $(PROGPATH) $(PROGPATH_STATIC) $(
+
+ # LOCAL_LIBS=-lpthread
+ # LOCAL_LIBS_DLL=$(LOCAL_LIBS) -ldl
+-LIB2 = -lpthread -ldl
++LIB2 = $(LOCAL_LIBS) -lpthread
+
+
+ endif
diff --git a/emulators/mame/files/patch-3rdparty_lzma_CPP_7zip_var__gcc.mak b/emulators/mame/files/patch-3rdparty_lzma_CPP_7zip_var__gcc.mak
new file mode 100644
index 000000000000..cfd83c3c7213
--- /dev/null
+++ b/emulators/mame/files/patch-3rdparty_lzma_CPP_7zip_var__gcc.mak
@@ -0,0 +1,12 @@
+--- 3rdparty/lzma/CPP/7zip/var_gcc.mak.orig 2023-05-30 17:50:57 UTC
++++ 3rdparty/lzma/CPP/7zip/var_gcc.mak
+@@ -6,7 +6,7 @@ IS_ARM64=
+ CROSS_COMPILE=
+ MY_ARCH=
+ USE_ASM=
+-CC=$(CROSS_COMPILE)gcc
+-CXX=$(CROSS_COMPILE)g++
++CC=$(CC)
++CXX=$(CXX)
+
+ # -march=armv8-a+crc+crypto
diff --git a/emulators/mame/files/patch-3rdparty_lzma_CPP_Windows_SystemInfo.cpp b/emulators/mame/files/patch-3rdparty_lzma_CPP_Windows_SystemInfo.cpp
new file mode 100644
index 000000000000..25e855008237
--- /dev/null
+++ b/emulators/mame/files/patch-3rdparty_lzma_CPP_Windows_SystemInfo.cpp
@@ -0,0 +1,27 @@
+--- 3rdparty/lzma/CPP/Windows/SystemInfo.cpp.orig 2023-05-30 17:50:57 UTC
++++ 3rdparty/lzma/CPP/Windows/SystemInfo.cpp
+@@ -20,6 +20,15 @@
+
+ #include <sys/auxv.h>
+
++#if defined(__FreeBSD__)
++unsigned long getauxval(unsigned long type)
++{
++ unsigned long aux = 0;
++ elf_aux_info(type, &aux, sizeof(aux));
++ return aux;
++}
++#endif
++
+ // #undef AT_HWCAP // to debug
+ // #undef AT_HWCAP2 // to debug
+
+@@ -36,7 +45,7 @@
+ #endif
+ */
+
+-#ifdef MY_CPU_ARM_OR_ARM64
++#if defined(MY_CPU_ARM_OR_ARM64) && !defined(__FreeBSD__)
+ #include <asm/hwcap.h>
+ #endif
+ #endif
diff --git a/emulators/mame/files/patch-3rdparty_lzma_C_7zCrc.c b/emulators/mame/files/patch-3rdparty_lzma_C_7zCrc.c
new file mode 100644
index 000000000000..5047b6809214
--- /dev/null
+++ b/emulators/mame/files/patch-3rdparty_lzma_C_7zCrc.c
@@ -0,0 +1,11 @@
+--- 3rdparty/lzma/C/7zCrc.c.orig 2023-05-30 17:50:57 UTC
++++ 3rdparty/lzma/C/7zCrc.c
+@@ -71,7 +71,7 @@ UInt32 MY_FAST_CALL CrcUpdateT1(UInt32 v, const void *
+
+ #ifdef MY_CPU_LE
+
+-#if defined(MY_CPU_ARM_OR_ARM64)
++#if defined(MY_CPU_ARM64)
+
+ // #pragma message("ARM*")
+
diff --git a/emulators/mame/files/patch-3rdparty_lzma_C_Aes.c b/emulators/mame/files/patch-3rdparty_lzma_C_Aes.c
new file mode 100644
index 000000000000..8c66c80c974f
--- /dev/null
+++ b/emulators/mame/files/patch-3rdparty_lzma_C_Aes.c
@@ -0,0 +1,11 @@
+--- 3rdparty/lzma/C/Aes.c.orig 2023-05-30 17:50:57 UTC
++++ 3rdparty/lzma/C/Aes.c
+@@ -55,7 +55,7 @@ static Byte InvS[256];
+
+ #ifdef MY_CPU_X86_OR_AMD64
+ #define USE_HW_AES
+-#elif defined(MY_CPU_ARM_OR_ARM64) && defined(MY_CPU_LE)
++#elif defined(MY_CPU_ARM) && defined(MY_CPU_LE)
+ #if defined(__clang__)
+ #if (__clang_major__ >= 8) // fix that check
+ #define USE_HW_AES
diff --git a/emulators/mame/files/patch-3rdparty_lzma_C_AesOpt.c b/emulators/mame/files/patch-3rdparty_lzma_C_AesOpt.c
new file mode 100644
index 000000000000..d9c7100bbe30
--- /dev/null
+++ b/emulators/mame/files/patch-3rdparty_lzma_C_AesOpt.c
@@ -0,0 +1,38 @@
+--- 3rdparty/lzma/C/AesOpt.c.orig 2023-05-30 17:50:57 UTC
++++ 3rdparty/lzma/C/AesOpt.c
+@@ -506,7 +506,7 @@ VAES_COMPAT_STUB (AesCtr_Code_HW)
+ #endif // ! USE_INTEL_VAES
+
+
+-#elif defined(MY_CPU_ARM_OR_ARM64) && defined(MY_CPU_LE)
++#elif defined(MY_CPU_ARM64) && defined(MY_CPU_LE)
+
+ #if defined(__clang__)
+ #if (__clang_major__ >= 8) // fix that check
+@@ -773,4 +773,25 @@ AES_FUNC_START2 (AesCtr_Code_HW)
+
+ #endif // USE_HW_AES
+
+-#endif // MY_CPU_ARM_OR_ARM64
++#else
++
++/* no USE_HW_AES */
++
++#pragma message("AES HW_SW stub was used")
++
++#define AES_TYPE_keys UInt32
++#define AES_TYPE_data Byte
++
++#define AES_FUNC_START(name) \
++ void MY_FAST_CALL name(UInt32 *p, Byte *data, size_t numBlocks) \
++
++#define AES_COMPAT_STUB(name) \
++ AES_FUNC_START(name); \
++ AES_FUNC_START(name ## _HW) \
++ { name(p, data, numBlocks); }
++
++AES_COMPAT_STUB (AesCbc_Encode)
++AES_COMPAT_STUB (AesCbc_Decode)
++AES_COMPAT_STUB (AesCtr_Code)
++
++#endif
diff --git a/emulators/mame/files/patch-3rdparty_lzma_C_CpuArch.c b/emulators/mame/files/patch-3rdparty_lzma_C_CpuArch.c
new file mode 100644
index 000000000000..0845a73832cb
--- /dev/null
+++ b/emulators/mame/files/patch-3rdparty_lzma_C_CpuArch.c
@@ -0,0 +1,42 @@
+--- 3rdparty/lzma/C/CpuArch.c.orig 2023-05-30 17:50:57 UTC
++++ 3rdparty/lzma/C/CpuArch.c
+@@ -417,6 +417,31 @@ BoolInt CPU_IsSupported_AES (void) { return APPLE_CRYP
+
+ #include <sys/auxv.h>
+
++#if defined(__FreeBSD__)
++static unsigned long get_hwcap(int aux) {
++ unsigned long hwcap;
++ if (elf_aux_info(aux, &hwcap, sizeof hwcap) != 0) {
++ return 0;
++ }
++ return hwcap;
++}
++
++#ifdef MY_CPU_ARM64
++BoolInt CPU_IsSupported_CRC32(void) { return get_hwcap(AT_HWCAP) & HWCAP_CRC32; }
++BoolInt CPU_IsSupported_NEON(void) { return 1; }
++BoolInt CPU_IsSupported_SHA1(void){ return get_hwcap(AT_HWCAP) & HWCAP_SHA1; }
++BoolInt CPU_IsSupported_SHA2(void) { return get_hwcap(AT_HWCAP) & HWCAP_SHA2; }
++BoolInt CPU_IsSupported_AES(void) { return get_hwcap(AT_HWCAP) & HWCAP_AES; }
++#else /* MY_CPU_ARM */
++BoolInt CPU_IsSupported_CRC32(void) { return get_hwcap(AT_HWCAP2) & HWCAP2_CRC32; }
++BoolInt CPU_IsSupported_NEON(void) { return get_hwcap(AT_HWCAP) & HWCAP_NEON; }
++BoolInt CPU_IsSupported_SHA1(void){ return get_hwcap(AT_HWCAP2) & HWCAP2_SHA1; }
++BoolInt CPU_IsSupported_SHA2(void) { return get_hwcap(AT_HWCAP2) & HWCAP2_SHA2; }
++BoolInt CPU_IsSupported_AES(void) { return get_hwcap(AT_HWCAP2) & HWCAP2_AES; }
++#endif
++
++#else // __FreeBSD__
++
+ #define USE_HWCAP
+
+ #ifdef USE_HWCAP
+@@ -450,6 +475,7 @@ MY_HWCAP_CHECK_FUNC (SHA1)
+ MY_HWCAP_CHECK_FUNC (SHA2)
+ MY_HWCAP_CHECK_FUNC (AES)
+
++#endif // FreeBSD
+ #endif // __APPLE__
+ #endif // _WIN32
+
diff --git a/emulators/mame/files/patch-3rdparty_lzma_C_Sha256Opt.c b/emulators/mame/files/patch-3rdparty_lzma_C_Sha256Opt.c
new file mode 100644
index 000000000000..525d4f9e96e0
--- /dev/null
+++ b/emulators/mame/files/patch-3rdparty_lzma_C_Sha256Opt.c
@@ -0,0 +1,11 @@
+--- 3rdparty/lzma/C/Sha256Opt.c.orig 2023-05-30 17:50:57 UTC
++++ 3rdparty/lzma/C/Sha256Opt.c
+@@ -212,7 +212,7 @@ void MY_FAST_CALL Sha256_UpdateBlocks_HW(UInt32 state[
+
+ #endif // USE_HW_SHA
+
+-#elif defined(MY_CPU_ARM_OR_ARM64)
++#elif defined(MY_CPU_ARM64)
+
+ #if defined(__clang__)
+ #if (__clang_major__ >= 8) // fix that check