libretro / Lakka-LibreELEC

Lakka is a lightweight Linux distribution that transforms a small computer into a full blown game console.
https://www.lakka.tv
1.74k stars 288 forks source link

Fix parallel_n64 for arm/aarch64 #1519

Closed ToKe79 closed 3 years ago

ToKe79 commented 3 years ago

build crashes during linking

build.Lakka-AMLGX.arm/toolchain/lib/gcc/armv8a-libreelec-linux-gnueabihf/10.2.0/../../../../armv8a-libreelec-linux-gnueabihf/bin/ld.gold: error: ./mupen64plus-core/src/r4300/new_dynarec/arm/linkage_arm.o: multiple definition of 'stop'
build.Lakka-AMLGX.arm/toolchain/lib/gcc/armv8a-libreelec-linux-gnueabihf/10.2.0/../../../../armv8a-libreelec-linux-gnueabihf/bin/ld.gold: ./mupen64plus-core/src/r4300/r4300.o: previous definition here
collect2: error: ld returned 1 exit status
Ntemis commented 3 years ago

https://github.com/libretro/mupen64plus-libretro Core is depreciated, you can safely clean this one out

dmrlawson commented 3 years ago

I think this might be https://github.com/libretro/parallel-n64/

Ntemis commented 3 years ago

I think this might be https://github.com/libretro/parallel-n64/

make WITH_DYNAREC=aarch64 Easy to verify locally. and USE_SSE2NEON=1 when arch=arm

ToKe79 commented 3 years ago

My best guess is that stop is defined in two places on global scope: https://github.com/libretro/parallel-n64/blob/0a67445ce63513584d92e5c57ea87efe0da9b3bd/mupen64plus-core/src/r4300/new_dynarec/arm64/linkage_aarch64.S#L54 https://github.com/libretro/parallel-n64/blob/0a67445ce63513584d92e5c57ea87efe0da9b3bd/mupen64plus-core/src/r4300/r4300.c#L53

I can patch r4300.c and rename stop to something else, e.g. for arm64/aarch64:

diff --git a/mupen64plus-core/src/r4300/new_dynarec/arm64/linkage_aarch64.S b/mupen64plus-core/src/r4300/new_dynarec/arm64/linkage_aarch64.S
index 0cb9af4a..be4048b1 100644
--- a/mupen64plus-core/src/r4300/new_dynarec/arm64/linkage_aarch64.S
+++ b/mupen64plus-core/src/r4300/new_dynarec/arm64/linkage_aarch64.S
@@ -51,7 +51,7 @@ BSS_SECTION
     GLOBAL_VARIABLE(last_count, 4)
     GLOBAL_VARIABLE(pending_exception, 4)
     GLOBAL_VARIABLE(pcaddr, 4)
-    GLOBAL_VARIABLE(stop, 4)
+    GLOBAL_VARIABLE(stopb, 4)
     GLOBAL_VARIABLE(invc_ptr, 8)
     GLOBAL_VARIABLE(address, 4)
     GLOBAL_VARIABLE(readmem_dword, 8)
@@ -87,8 +87,8 @@ extra_memory:
     last_count        = cycle_count       + 4
     pending_exception = last_count        + 4
     pcaddr            = pending_exception + 4
-    stop              = pcaddr            + 4
-    invc_ptr          = stop              + 4
+    stopb             = pcaddr            + 4
+    invc_ptr          = stopb             + 4
     address           = invc_ptr          + 8
     readmem_dword     = address           + 8 /* 4 bytes free */
     cpu_dword         = readmem_dword     + 8
@@ -385,7 +385,7 @@ GLOBAL_FUNCTION(cc_interrupt):
     ldr    w20, [x29, #g_cp0_regs+36-dynarec_local] /* Count */
     ldr    w0, [x29, #next_interrupt-dynarec_local]
     ldr    w1, [x29, #pending_exception-dynarec_local]
-    ldr    w2, [x29, #stop-dynarec_local]
+    ldr    w2, [x29, #stopb-dynarec_local]
     str    w0, [x29, #last_count-dynarec_local]
     sub    w20, w20, w0
     tst    w2, w2

It solves the build issue, but will it work correctly?