Issues with compiling Mupen64 on ARM

Hello.

I have attempted to compile the Mupen64plus libretro implementation on my ARMv7 mini PC running Linux. Upon running make WITH_DYNAREC=arm, or for that matter make alone, the following error occurs:

g++: error: unrecognized command line option ‘-msse’
g++: error: unrecognized command line option ‘-msse2’
make: *** [gles2rice/src/FrameBuffer.o] Error 1

Presumably these features are specific to x86. Removing the -msse and -msse2 flags from the makefile seems to solve this problem, though I am now facing this glut of error messages:

/tmp/ccvujj66.s: Assembler messages:
/tmp/ccvujj66.s:1910: Error: ARM register expected -- `mov %ebx,[sp,#12]'
/tmp/ccvujj66.s:1911: Error: ARM register expected -- `mov %eax,[sp,#16]'
/tmp/ccvujj66.s:1912: Error: ARM register expected -- `mov %ecx,[sp,#20]'
/tmp/ccvujj66.s:1913: Error: ARM register expected -- `mov %edx,[sp,#24]'
/tmp/ccvujj66.s:1914: Error: ARM register expected -- `mov %esi,[sp,#28]'
/tmp/ccvujj66.s:1915: Error: ARM register expected -- `mov [r9,#0],%ecx'
/tmp/ccvujj66.s:1916: Error: ARM register expected -- `mov $0,%edx'
/tmp/ccvujj66.s:1917: Error: ARM register expected -- `mov [sp,#40],%eax'
/tmp/ccvujj66.s:1919: Error: ARM register expected -- `mov [sp,#32],%ebx'
/tmp/ccvujj66.s:1920: Error: ARM register expected -- `sub $4,%ebx'
/tmp/ccvujj66.s:1922: Error: ARM register expected -- `mov (%ecx,%ebx),%esi'
/tmp/ccvujj66.s:1923: Error: bad instruction `xor %ebx,%esi'
/tmp/ccvujj66.s:1924: Error: bad instruction `rol $4,%edx'
/tmp/ccvujj66.s:1925: Error: ARM register expected -- `add %esi,%edx'
/tmp/ccvujj66.s:1926: Error: ARM register expected -- `sub $4,%ebx'
/tmp/ccvujj66.s:1927: Error: bad instruction `jge 1b'
/tmp/ccvujj66.s:1928: Error: bad instruction `xor %eax,%esi'
/tmp/ccvujj66.s:1929: Error: ARM register expected -- `add %esi,%edx'
/tmp/ccvujj66.s:1930: Error: ARM register expected -- `add [sp,#36],%ecx'
/tmp/ccvujj66.s:1931: Error: bad instruction `dec %eax'
/tmp/ccvujj66.s:1932: Error: bad instruction `jge 0b'
/tmp/ccvujj66.s:1933: Error: ARM register expected -- `mov [sp,#12],%ebx'
/tmp/ccvujj66.s:1934: Error: ARM register expected -- `mov %edx,[sp,#44]'
/tmp/ccvujj66.s:1935: Error: ARM register expected -- `mov [sp,#16],%eax'
/tmp/ccvujj66.s:1936: Error: ARM register expected -- `mov [sp,#20],%ecx'
/tmp/ccvujj66.s:1937: Error: ARM register expected -- `mov [sp,#24],%edx'
/tmp/ccvujj66.s:1938: Error: ARM register expected -- `mov [sp,#28],%esi'
make: *** [gles2rice/src/FrameBuffer.o] Error 1

I apologise for my inexperience here, though does this indicate a problem with my compilation tools? Would anyone be able to recommend a course of action here? I understand that Raspberry Pi users have been able to compile this core somehow, and I should note that I have managed to compile several other Libretro cores successfully on my system.

Thank you.

The RPi has its own makefile entry that specifies some appropriate CFLAGs. You could try building with ‘platform=rpi’ and see if that treats you any better, though it might still have issues. If so, you’ll probably want to modify that section of the makefile (line 43) to have some different flags, maybe like this: -march=armv7-a -mfpu=neon -mfloat-abi=hard

Thank you kindly for your quick response, hunterk. Adding platform=rpi overcame all of my previous errors.

Alas, I now face a PIC error when compiling.

/usr/bin/ld: error: mupen64plus-core/src/r4300/new_dynarec/linkage_arm.o: requires unsupported dynamic reloc R_ARM_MOVW_ABS_NC; recompile with -fPIC
collect2: error: ld returned 1 exit status
make: *** [mupen64plus_libretro.so] Error 1

May I ask if I now need to recompile linkage_arm.o myself?

Hmm. The makefile indicates that platform=rpi should include -fPIC. Did you ‘make clean’ first?

Hello again. Running make clean and recompiling with the same commands brings about the same error message. Deleting the working directory and starting afresh makes no change, unfortunately.

Hello once again.

I have now managed to compile this core. Having been inspired by this discussion between Raspberry Pi users, I copied this version of linkage_arm.S from the main Mupen64Plus source code files to my Mupen64 Libretro folder and added the line .eabi_attribute 28, 1 alongside the other .eabi entries near the top of the file. (Incidentally, I cannot get the main version of Mupen64Plus to compile, though this is a separate matter.) The version of linkage_arm.S that caused my previous problems was hence overwritten, and the core compiled.

As might have been expected from this course of action, Retroarch now suffers a segmentation fault whenever the Mupen64 core attempts to load a rom. It gives the following messages:

RetroArch [WARN] :: [GL]: 32-bit FBO not supported. Falling back to 16-bit.
ReadSpecialSettings: DEFAULT
ReadSpecialSettings: DEFAULT
ReadSpecialSettings: SUPER MARIO 64
Congratulations, you have 4 auxilliary buffers, we'll use them wisely !
GL_EXT_texture_format_BGRA8888 supported.
Segmentation fault

Running a gdb backtrace on Retroarch produces this:

#0  0x40290b6c in _essl_mali200_write_instructions () from /usr/lib/arm-linux-gnueabihf/libEGL.so
#1  0x4028eeae in ?? () from /usr/lib/arm-linux-gnueabihf/libEGL.so
#2  0x4028eeae in ?? () from /usr/lib/arm-linux-gnueabihf/libEGL.so
Backtrace stopped: previous frame identical to this frame (corrupt stack?)

One wonders whether this problem is due to a) the fact I have used platform=rpi when compiling, for want of more appropriate options, b) the fact I have used a file from the main version of Mupen64Plus when compiling the Libretro version, c) a compatibility issue with the OpenGLES-enabled plugins of this core on my system or d) a combination of these issues.