There are some failures when trying to compile on ARMv9 (ODROID U2).
There was a segfault happening on co_switch, hence I added the NULL check, please review that.
I am still not able to run mupen64plus with rice because of a segfault in my vendor's video driver (ess_mali200_write_instructions () from /usr/lib/libEGL.so); couldn't try with Glide64 yet because it also crashes because of missing INI file.
diff --git a/libretro-build-common.sh b/libretro-build-common.sh
index 5d44be0..b4eba15 100644
--- a/libretro-build-common.sh
+++ b/libretro-build-common.sh
@@ -532,8 +532,8 @@ build_libretro_mupen64()
${MAKE} WITH_DYNAREC=x86 $COMPILER -j$JOBS || die "Failed to build Mupen 64 (x86 dynarec)"
elif [ "$CORTEX_A8" ] || [ "$CORTEX_A9" ]; then
echo "=== Building Mupen 64 Plus (ARM dynarec) ==="
- ${MAKE} WITH_DYNAREC=arm -j$JOBS clean || die "Failed to clean Mupen 64 (ARM dynarec)"
- ${MAKE} WITH_DYNAREC=arm $COMPILER -j$JOBS || die "Failed to build Mupen 64 (ARM dynarec)"
+ ${MAKE} WITH_DYNAREC=arm platform=$FORMAT_COMPILER_TARGET -j$JOBS clean || die "Failed to clean Mupen 64 (ARM dynarec)"
+ ${MAKE} WITH_DYNAREC=arm platform=$FORMAT_COMPILER_TARGET $COMPILER -j$JOBS || die "Failed to build Mupen 64 (ARM dynarec)"
else
echo "=== Building Mupen 64 Plus ==="
${MAKE} -j$JOBS clean || die "Failed to clean Mupen 64"
diff --git a/libretro-build.sh b/libretro-build.sh
index 47d1bd9..0013872 100755
--- a/libretro-build.sh
+++ b/libretro-build.sh
@@ -79,6 +79,8 @@ echo "STRIP = $STRIP"
. ./libretro-build-common.sh
+check_opengl
+
mkdir -p "$RARCH_DIST_DIR"
if [ $1 ]; then
@@ -113,7 +115,6 @@ if [ $FORMAT_COMPILER_TARGET != "win" ]; then
build_libretro_desmume
build_libretro_pcsx_rearmed
fi
- check_opengl
build_libretro_modelviewer
build_libretro_scenewalker
build_libretro_instancingviewer
diff --git a/Makefile b/Makefile
index 6f3f10c..46efe77 100644
--- a/Makefile
+++ b/Makefile
@@ -19,14 +19,51 @@ CC_AS ?= $(CC)
ifneq (,$(findstring unix,$(platform)))
TARGET := $(TARGET_NAME)_libretro.so
LDFLAGS += -shared -Wl,--version-script=libretro/link.T
-
+ SHARED := -shared -Wl,--version-script=libretro/link.T -Wl,--no-undefined
+ CPPFLAGS += -I.
+ LIBS := -lz
fpic = -fPIC
+
ifneq (,$(findstring gles,$(platform)))
GLES = 1
GL_LIB := -lGLESv2
else
GL_LIB := -lGL
endif
+
+ifneq (,$(findstring cortexa8,$(platform)))
+ CFLAGS += -DARM -DNO_ASM -DNOSSE -marm -mcpu=cortex-a8
+ CPPFLAGS += -DARM -DNO_ASM -DNOSSE -marm -mcpu=cortex-a8
+ifeq ($(DEBUG), 0)
+ CFLAGS += -mtune=cortex-a8
+ CPPFLAGS += -mtune=cortex-a8
+endif
+
+ OBJECTS += libretro/libco/armeabi_asm.o
+else ifneq (,$(findstring cortexa9,$(platform)))
+ CFLAGS += -DARM -DNO_ASM -DNOSSE -marm -mcpu=cortex-a9
+ CPPFLAGS += -DARM -DNO_ASM -DNOSSE -marm -mcpu=cortex-a9
+ifeq ($(DEBUG), 0)
+ CFLAGS += -mtune=cortex-a9
+ CPPFLAGS += -mtune=cortex-a9
+endif
+
+ OBJECTS += libretro/libco/armeabi_asm.o
+endif
+ifneq (,$(findstring softfloat,$(platform)))
+ CFLAGS += -mfloat-abi=softfp
+ CPPFLAGS += -mfloat-abi=softfp
+else ifneq (,$(findstring hardfloat,$(platform)))
+ CFLAGS += -mfloat-abi=hard
+ CPPFLAGS += -mfloat-abi=hard
+endif
+
+ifneq (,$(findstring neon,$(platform)))
+ CPPFLAGS += -mfpu=neon
+ CFLAGS += -mfpu=neon
+ HAVE_NEON = 1
+endif
+
PLATFORM_EXT := unix
else ifneq (,$(findstring osx,$(platform)))
TARGET := $(TARGET_NAME)_libretro.dylib
@@ -65,35 +102,6 @@ else ifneq (,$(findstring android,$(platform)))
fpic = -fPIC
PLATFORM_EXT := unix
-else ifneq (,$(findstring armv,$(platform)))
- CC = gcc
- CXX = g++
- TARGET := $(TARGET_NAME)_libretro.so
- fpic := -fPIC
- SHARED := -shared -Wl,--version-script=libretro/link.T -Wl,--no-undefined
- CPPFLAGS += -I.
- LIBS := -lz
-ifneq (,$(findstring gles,$(platform)))
- GLES := 1
-else
- GL_LIB := -lGL
-endif
-ifneq (,$(findstring cortexa8,$(platform)))
- CPPFLAGS += -marm -mcpu=cortex-a8
-else ifneq (,$(findstring cortexa9,$(platform)))
- CPPFLAGS += -marm -mcpu=cortex-a9
-endif
- CPPFLAGS += -marm
-ifneq (,$(findstring neon,$(platform)))
- CPPFLAGS += -mfpu=neon
- HAVE_NEON = 1
-endif
-ifneq (,$(findstring softfloat,$(platform)))
- CPPFLAGS += -mfloat-abi=softfp
-else ifneq (,$(findstring hardfloat,$(platform)))
- CPPFLAGS += -mfloat-abi=hard
-endif
- CPPFLAGS += -DARM
else ifneq (,$(findstring win,$(platform)))
TARGET := $(TARGET_NAME)_libretro.dll
LDFLAGS += -shared -static-libgcc -static-libstdc++ -Wl,--version-script=libretro/link.T -lwinmm -lgdi32
@@ -218,13 +226,14 @@ endif
all: $(TARGET)
$(COREDIR)/src/r4300/new_dynarec/linkage_arm.o: $(COREDIR)/src/r4300/new_dynarec/linkage_arm.S
- $(CC_AS) $(CFLAGS) -c $^ -o $@
+ $(CC_AS) $(CFLAGS) $(fpic) -c $^ -o $@
$(COREDIR)/src/r4300/new_dynarec/new_dynarec.o: $(COREDIR)/src/r4300/new_dynarec/new_dynarec.c
$(CC) -c -o $@ $< $(CPPFLAGS) $(CFLAGS) -O0
$(TARGET): $(OBJECTS)
- $(CXX) -o $@ $(OBJECTS) $(LDFLAGS) $(GL_LIB)
+ @echo $(platform)
+ $(CXX) $(CPPFLAGS) -shared -o $@ $(OBJECTS) $(LDFLAGS) $(GL_LIB)
clean:
rm -f $(OBJECTS) $(TARGET)
diff --git a/gles2glide64/src/Glide64/3dmath.cpp b/gles2glide64/src/Glide64/3dmath.cpp
index dd732e8..644bf03 100644
--- a/gles2glide64/src/Glide64/3dmath.cpp
+++ b/gles2glide64/src/Glide64/3dmath.cpp
@@ -40,8 +40,10 @@
#include "Gfx_1.3.h"
extern "C" {
#ifndef NOSSE
+#ifndef NO_ASM
#include <xmmintrin.h>
#endif
+#endif
}
#include <math.h>
diff --git a/gles2rice/src/Config.cpp b/gles2rice/src/Config.cpp
index 125be0b..41ff3c3 100644
--- a/gles2rice/src/Config.cpp
+++ b/gles2rice/src/Config.cpp
@@ -362,7 +362,9 @@ BOOL InitConfiguration(void)
bool isMMXSupported()
{
int IsMMXSupported = 0;
-
+#if defined(ARM)
+ return false;
+#else
#if !defined(__GNUC__) && !defined(NO_ASM)
__asm
{
@@ -389,10 +391,14 @@ bool isMMXSupported()
return true;
else
return false;
-}
+#endif
+}
bool isSSESupported()
{
+#if defined(ARM)
+ return false;
+#else
int SSESupport = 0;
// And finally, check the CPUID for Streaming SIMD Extensions support.
@@ -423,7 +429,8 @@ bool isSSESupported()
return true;
else
return false;
-}
+#endif
+}
static void ReadConfiguration(void)
{
diff --git a/libretro/libco/armeabi.c b/libretro/libco/armeabi.c
index ef418bf..ba49f47 100644
--- a/libretro/libco/armeabi.c
+++ b/libretro/libco/armeabi.c
@@ -65,6 +65,7 @@ void co_delete(cothread_t handle) {
}
void co_switch(cothread_t handle) {
+ assert(handle != NULL);
cothread_t co_previous_handle = co_active();
co_switch_arm(co_active_handle = handle, co_previous_handle);
}
diff --git a/libretro/libretro.c b/libretro/libretro.c
index d93af8e..fe42508 100644
--- a/libretro/libretro.c
+++ b/libretro/libretro.c
@@ -25,7 +25,7 @@ struct retro_rumble_interface rumble;
static struct retro_hw_render_callback render_iface;
static cothread_t main_thread;
-static cothread_t emulator_thread;
+static cothread_t emulator_thread = NULL;
static bool emu_thread_has_run = false; // < This is used to ensure the core_gl_context_reset
// function doesn't try to reinit graphics before needed
static bool flip_only;
@@ -412,7 +412,10 @@ bool retro_load_game(const struct retro_game_info *game)
void retro_unload_game(void)
{
stop = 1;
- co_switch(emulator_thread);
+ if (emulator_thread != NULL)
+ co_switch(emulator_thread);
+ else
+ printf("mupen64plus: no running emulator thread");
CoreDoCommand(M64CMD_ROM_CLOSE, 0, NULL);
}