libretro / parallel-n64

Optimized/rewritten Nintendo 64 emulator made specifically for Libretro. Originally based on Mupen64 Plus.
310 stars 128 forks source link

Build failed on aarch64 Linux #671

Open guoyunhe opened 4 years ago

guoyunhe commented 4 years ago
make WITH_DYNAREC=aarch64
[  157s] /usr/lib64/gcc/aarch64-suse-linux/10/../../../../aarch64-suse-linux/bin/ld: ./mupen64plus-core/src/r4300/recomp.o: in function `init_block.localalias':
[  157s] recomp.c:(.text+0x6140): undefined reference to `free_assembler'
[  157s] /usr/lib64/gcc/aarch64-suse-linux/10/../../../../aarch64-suse-linux/bin/ld: recomp.c:(.text+0x6250): undefined reference to `init_assembler'
[  157s] /usr/lib64/gcc/aarch64-suse-linux/10/../../../../aarch64-suse-linux/bin/ld: ./mupen64plus-core/src/r4300/recomp.o: in function `recompile_block':
[  157s] recomp.c:(.text+0x6904): undefined reference to `passe2'
[  157s] /usr/lib64/gcc/aarch64-suse-linux/10/../../../../aarch64-suse-linux/bin/ld: recomp.c:(.text+0x694c): undefined reference to `free_assembler'
[  157s] /usr/lib64/gcc/aarch64-suse-linux/10/../../../../aarch64-suse-linux/bin/ld: recomp.c:(.text+0x6990): undefined reference to `init_assembler'
[  157s] collect2: error: ld returned 1 exit status
derekstodghill commented 3 years ago

Getting a similar issue on raspberry pi 4 running ubuntu. I used the same make command.

make WITH_DYNAREC=aarch64

/usr/bin/ld: ./mupen64plus-core/src/r4300/recomp.o: in function init_block.localalias': recomp.c:(.text+0x5f58): undefined reference tofree_assembler' /usr/bin/ld: recomp.c:(.text+0x608c): undefined reference to init_assembler' /usr/bin/ld: ./mupen64plus-core/src/r4300/recomp.o: in functionrecompile_block': recomp.c:(.text+0x674c): undefined reference to passe2' /usr/bin/ld: recomp.c:(.text+0x6794): undefined reference tofree_assembler' /usr/bin/ld: recomp.c:(.text+0x67d8): undefined reference to `init_assembler' collect2: error: ld returned 1 exit status make: *** [Makefile:968: parallel_n64_libretro.so] Error 1

derekstodghill commented 3 years ago

I looked into this by searching for the missing reference. nm ./mupen64plus-core/src/r4300/recomp.o | grep init_assembler U init_assembler nm ./mupen64plus-core/src/r4300/empty_dynarec.o | grep init_assembler

Looks like it is declared in mupen64plus-core/src/r4300/empty_dynarec.c BUT only when the ARM_FIX compiler directive is set. The makefile wasn't putting that -DARM_FIX in the command line for some reason. I got it to compile that one file by doing this command. gcc -DARM_FIX -DHAVE_RICE -DHAVE_GLN64 -DHAVE_GLIDE64 -DHAVE_THR_AL -MMD -DINLINE="inline" -Ofast -DNDEBUG -fipa-pta -DGIT_VERSION=\"" cfb9789e"\" -D__LIBRETRO__ -DM64P_PLUGIN_API -DM64P_CORE_PROTOTYPES -D_ENDUSER_RELEASE -DSINC_LOWER_QUALITY -I./glide2gl/src/Glitch64/inc -I./mupen64plus-core/src -I./mupen64plus-core/src/api -I./include -I./mupen64plus-core/src/plugin/audio_libretro -I./libretro-common/include -I./libretro -fPIC -DENABLE_3POINT -DENABLE_TEXTURE_SAMPLING -DHAVE_OPENGL -DDYNAREC -DNEW_DYNAREC=4 -c mupen64plus-core/src/r4300/empty_dynarec.c -o mupen64plus-core/src/r4300/empty_dynarec.o

After that, the reference existed in the object file. nm ./mupen64plus-core/src/r4300/empty_dynarec.o | grep init_assembler 0000000000000000 T init_assembler

Then I re-ran the make command which skipped the compile since all the object files already existed and went straight to the link which worked. Hopefully some one can figure out why the Makefile isn't setting the correct compiler directives for aarch64.

KiralyCraft commented 3 years ago

Thank you for reporting the fix! I was bashing my head with this as well and this finally worked. I am at commit 29e7f39e95af38c2c4056a825286261161eae640 right now.

markand commented 3 years ago

Would you mind telling where in the Makefile you've added the -DARM_FIX flag so we can write a PR for it?

derekstodghill commented 3 years ago

I never updated the makefile. I just ran the compile and link commands individually.

coreybruce commented 3 years ago

Was this issues fixed with a update at all?

yuppox commented 2 months ago

This is still an issue in aarch64.

/usr/bin/ld: ./mupen64plus-core/src/r4300/recomp.o: in function `init_block.localalias':
recomp.c:(.text+0x5f0c): undefined reference to `free_assembler'
/usr/bin/ld: recomp.c:(.text+0x61e4): undefined reference to `init_assembler'
/usr/bin/ld: ./mupen64plus-core/src/r4300/recomp.o: in function `recompile_block':
recomp.c:(.text+0x684c): undefined reference to `passe2'
/usr/bin/ld: recomp.c:(.text+0x6890): undefined reference to `free_assembler'
/usr/bin/ld: recomp.c:(.text+0x68d4): undefined reference to `init_assembler'
collect2: error: ld returned 1 exit status
yuppox commented 2 months ago

For anyone that needs to apply the fix:

libretro-parallel_n64/Makefile:25

CPUFLAGS  := -DARM_FIX

It should work to set the initial value. You can always append it, too.