Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

can libretro jni so support x86_64 platform (ffmpeg) #16020

Closed
2 tasks done
hsoftxl opened this issue Sep 13, 2022 · 5 comments
Closed
2 tasks done

can libretro jni so support x86_64 platform (ffmpeg) #16020

hsoftxl opened this issue Sep 13, 2022 · 5 comments
Labels
Libretro Issue on Libretro but not all ports.

Comments

@hsoftxl
Copy link
Contributor

hsoftxl commented Sep 13, 2022

What should happen

libretro jni so not support x86_64

Who would this benefit

..

Platform (if relevant)

No response

Games this would be useful in

..

Other emulators or software with a similar feature

No response

Checklist

@hsoftxl
Copy link
Contributor Author

hsoftxl commented Sep 13, 2022

[x86_64] Compile : retro <= rtime.c
[x86_64] Compile : retro <= vfs_implementation.c
[x86_64] Compile : retro <= filter_neon.S
[x86_64] SharedLibrary : libretro.so
/home/xielei/ndk/android-ndk-r21e/toolchains/llvm/prebuilt/linux-x86_64/bin/../lib/gcc/x86_64-linux-android/4.9.x/../../../../x86_64-linux-android/bin/ld: error: /home/xielei/ppsspp/libretro/jni/../../ffmpeg/android/x86_64/lib/libavcodec.a(h264_qpel_10bit.o): requires dynamic R_X86_64_PC32 reloc against 'ff_pw_1023' which may overflow at runtime; recompile with -fPIC
/home/xielei/ndk/android-ndk-r21e/toolchains/llvm/prebuilt/linux-x86_64/bin/../lib/gcc/x86_64-linux-android/4.9.x/../../../../x86_64-linux-android/bin/ld: error: /home/xielei/ppsspp/libretro/jni/../../ffmpeg/android/x86_64/lib/libavcodec.a(h264_qpel_8bit.o): requires dynamic R_X86_64_PC32 reloc against 'ff_pw_5' which may overflow at runtime; recompile with -fPIC
/home/xielei/ndk/android-ndk-r21e/toolchains/llvm/prebuilt/linux-x86_64/bin/../lib/gcc/x86_64-linux-android/4.9.x/../../../../x86_64-linux-android/bin/ld: error: /home/xielei/ppsspp/libretro/jni/../../ffmpeg/android/x86_64/lib/libavcodec.a(h264_cabac.o): requires dynamic R_X86_64_PC32 reloc against 'ff_h264_cabac_tables' which may overflow at runtime; recompile with -fPIC
/home/xielei/ndk/android-ndk-r21e/toolchains/llvm/prebuilt/linux-x86_64/bin/../lib/gcc/x86_64-linux-android/4.9.x/../../../../x86_64-linux-android/bin/ld: error: /home/xielei/ppsspp/libretro/jni/../../ffmpeg/android/x86_64/lib/libavcodec.a(h263_loopfilter.o): requires dynamic R_X86_64_PC32 reloc against 'ff_h263_loop_filter_strength' which may overflow at runtime; recompile with -fPIC
/home/xielei/ndk/android-ndk-r21e/toolchains/llvm/prebuilt/linux-x86_64/bin/../lib/gcc/x86_64-linux-android/4.9.x/../../../../x86_64-linux-android/bin/ld: error: /home/xielei/ppsspp/libretro/jni/../../ffmpeg/android/x86_64/lib/libavcodec.a(h264_chromamc.o): requires dynamic R_X86_64_PC32 reloc against 'ff_pw_8' which may overflow at runtime; recompile with -fPIC
/home/xielei/ndk/android-ndk-r21e/toolchains/llvm/prebuilt/linux-x86_64/bin/../lib/gcc/x86_64-linux-android/4.9.x/../../../../x86_64-linux-android/bin/ld: error: /home/xielei/ppsspp/libretro/jni/../../ffmpeg/android/x86_64/lib/libavcodec.a(h264_chromamc_10bit.o): requires dynamic R_X86_64_PC32 reloc against 'ff_pw_8' which may overflow at runtime; recompile with -fPIC
/home/xielei/ndk/android-ndk-r21e/toolchains/llvm/prebuilt/linux-x86_64/bin/../lib/gcc/x86_64-linux-android/4.9.x/../../../../x86_64-linux-android/bin/ld: error: /home/xielei/ppsspp/libretro/jni/../../ffmpeg/android/x86_64/lib/libavcodec.a(h264_deblock.o): requires dynamic R_X86_64_PC32 reloc against 'ff_pb_1' which may overflow at runtime; recompile with -fPIC
/home/xielei/ndk/android-ndk-r21e/toolchains/llvm/prebuilt/linux-x86_64/bin/../lib/gcc/x86_64-linux-android/4.9.x/../../../../x86_64-linux-android/bin/ld: error: /home/xielei/ppsspp/libretro/jni/../../ffmpeg/android/x86_64/lib/libavcodec.a(h264_deblock_10bit.o): requires dynamic R_X86_64_PC32 reloc against 'ff_pw_4' which may overflow at runtime; recompile with -fPIC
/home/xielei/ndk/android-ndk-r21e/toolchains/llvm/prebuilt/linux-x86_64/bin/../lib/gcc/x86_64-linux-android/4.9.x/../../../../x86_64-linux-android/bin/ld: error: /home/xielei/ppsspp/libretro/jni/../../ffmpeg/android/x86_64/lib/libavcodec.a(h264_idct.o): requires dynamic R_X86_64_PC32 reloc against 'ff_pw_32' which may overflow at runtime; recompile with -fPIC
/home/xielei/ndk/android-ndk-r21e/toolchains/llvm/prebuilt/linux-x86_64/bin/../lib/gcc/x86_64-linux-android/4.9.x/../../../../x86_64-linux-android/bin/ld: error: /home/xielei/ppsspp/libretro/jni/../../ffmpeg/android/x86_64/lib/libavcodec.a(h264_idct_10bit.o): requires dynamic R_X86_64_PC32 reloc against 'ff_pd_32' which may overflow at runtime; recompile with -fPIC
/home/xielei/ndk/android-ndk-r21e/toolchains/llvm/prebuilt/linux-x86_64/bin/../lib/gcc/x86_64-linux-android/4.9.x/../../../../x86_64-linux-android/bin/ld: error: /home/xielei/ppsspp/libretro/jni/../../ffmpeg/android/x86_64/lib/libavcodec.a(h264_intrapred.o): requires dynamic R_X86_64_PC32 reloc against 'ff_pb_3' which may overflow at runtime; recompile with -fPIC
/home/xielei/ndk/android-ndk-r21e/toolchains/llvm/prebuilt/linux-x86_64/bin/../lib/gcc/x86_64-linux-android/4.9.x/../../../../x86_64-linux-android/bin/ld: error: /home/xielei/ppsspp/libretro/jni/../../ffmpeg/android/x86_64/lib/libavcodec.a(h264_intrapred_10bit.o): requires dynamic R_X86_64_PC32 reloc against 'ff_pw_1' which may overflow at runtime; recompile with -fPIC
/home/xielei/ndk/android-ndk-r21e/toolchains/llvm/prebuilt/linux-x86_64/bin/../lib/gcc/x86_64-linux-android/4.9.x/../../../../x86_64-linux-android/bin/ld: error: /home/xielei/ppsspp/libretro/jni/../../ffmpeg/android/x86_64/lib/libavcodec.a(h264_weight_10bit.o): requires dynamic R_X86_64_PC32 reloc against 'ff_pw_1' which may overflow at runtime; recompile with -fPIC
/home/xielei/ndk/android-ndk-r21e/toolchains/llvm/prebuilt/linux-x86_64/bin/../lib/gcc/x86_64-linux-android/4.9.x/../../../../x86_64-linux-android/bin/ld: error: /home/xielei/ppsspp/libretro/jni/../../ffmpeg/android/x86_64/lib/libavcodec.a(qpeldsp.o): requires dynamic R_X86_64_PC32 reloc against 'ff_pw_3' which may overflow at runtime; recompile with -fPIC
/home/xielei/ndk/android-ndk-r21e/toolchains/llvm/prebuilt/linux-x86_64/bin/../lib/gcc/x86_64-linux-android/4.9.x/../../../../x86_64-linux-android/bin/ld: error: /home/xielei/ppsspp/libretro/jni/../../ffmpeg/android/x86_64/lib/libavcodec.a(simple_idct10.o): requires dynamic R_X86_64_PC32 reloc against 'ff_pw_1023' which may overflow at runtime; recompile with -fPIC
/home/xielei/ndk/android-ndk-r21e/toolchains/llvm/prebuilt/linux-x86_64/bin/../lib/gcc/x86_64-linux-android/4.9.x/../../../../x86_64-linux-android/bin/ld: error: /home/xielei/ppsspp/libretro/jni/../../ffmpeg/android/x86_64/lib/libavcodec.a(fft.o): requires dynamic R_X86_64_PC32 reloc against 'ff_cos_32' which may overflow at runtime; recompile with -fPIC
/home/xielei/ndk/android-ndk-r21e/toolchains/llvm/prebuilt/linux-x86_64/bin/../lib/gcc/x86_64-linux-android/4.9.x/../../../../x86_64-linux-android/bin/ld: error: /home/xielei/ppsspp/libretro/jni/../../ffmpeg/android/x86_64/lib/libavcodec.a(hpeldsp.o): requires dynamic R_X86_64_PC32 reloc against 'ff_pb_1' which may overflow at runtime; recompile with -fPIC
/home/xielei/ndk/android-ndk-r21e/toolchains/llvm/prebuilt/linux-x86_64/bin/../lib/gcc/x86_64-linux-android/4.9.x/../../../../x86_64-linux-android/bin/ld: error: /home/xielei/ppsspp/libretro/jni/../../ffmpeg/android/x86_64/lib/libavcodec.a(idctdsp.o): requires dynamic R_X86_64_PC32 reloc against 'ff_pb_80' which may overflow at runtime; recompile with -fPIC
/home/xielei/ndk/android-ndk-r21e/toolchains/llvm/prebuilt/linux-x86_64/bin/../lib/gcc/x86_64-linux-android/4.9.x/../../../../x86_64-linux-android/bin/ld: error: /home/xielei/ppsspp/libretro/jni/../../ffmpeg/android/x86_64/lib/libavcodec.a(me_cmp.o): requires dynamic R_X86_64_PC32 reloc against 'ff_pb_1' which may overflow at runtime; recompile with -fPIC
/home/xielei/ndk/android-ndk-r21e/toolchains/llvm/prebuilt/linux-x86_64/bin/../lib/gcc/x86_64-linux-android/4.9.x/../../../../x86_64-linux-android/bin/ld: error: /home/xielei/ppsspp/libretro/jni/../../ffmpeg/android/x86_64/lib/libavcodec.a(sbrdsp.o): requires dynamic R_X86_64_PC32 reloc against 'ff_ps_neg' which may overflow at runtime; recompile with -fPIC
/home/xielei/ndk/android-ndk-r21e/toolchains/llvm/prebuilt/linux-x86_64/bin/../lib/gcc/x86_64-linux-android/4.9.x/../../../../x86_64-linux-android/bin/ld: error: /home/xielei/ppsspp/libretro/jni/../../ffmpeg/android/x86_64/lib/libswscale.a(swscale.o): requires dynamic R_X86_64_PC32 reloc against 'ff_M24A' which may overflow at runtime; recompile with -fPIC
/home/xielei/ndk/android-ndk-r21e/toolchains/llvm/prebuilt/linux-x86_64/bin/../lib/gcc/x86_64-linux-android/4.9.x/../../../../x86_64-linux-android/bin/ld: error: /home/xielei/ppsspp/libretro/jni/../../ffmpeg/android/x86_64/lib/libswscale.a(rgb2rgb.o): requires dynamic R_X86_64_PC32 reloc against 'ff_w1111' which may overflow at runtime; recompile with -fPIC
/home/xielei/ndk/android-ndk-r21e/toolchains/llvm/prebuilt/linux-x86_64/bin/../lib/gcc/x86_64-linux-android/4.9.x/../../../../x86_64-linux-android/bin/ld: warning: shared library text segment is not shareable
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [/home/xielei/ndk/android-ndk-r21e/build/core/build-binary.mk:725: /home/xielei/ppsspp/libretro/obj/local/x86_64/libretro.so] Error 1
xielei@DESKTOP-T3240L7:~/ppsspp/libretro/jni$

@anr2me
Copy link
Collaborator

anr2me commented Sep 13, 2022

According to this https://codegrepr.com/question/how-to-recompile-with-fpic/

x86_64/libavcodec.a(h264_qpel_10bit.o): 
requires dynamic R_X86_64_PC32 reloc against 'ff_pw_1023' 
which may overflow at runtime; recompile with -fPIC

Possible solutions:

  1. compile all ffmpeg files with no assembler optimizations (for ffmpeg this is configure option: –disable-asm)
  2. produce dynamic libraries (e.g. libavcodec.so) and link them in your final library dynamically

Briefly, the error means that you can’t use a static library to be linked w/ a dynamic one.
The correct way is to have a libavcodec compiled into a .so instead of .a, so the other .so library you are trying to build will link well.

The shortest way to do so is to add --enable-shared at ./configure options. Or even you may try to disable shared (or static) libraries at all… you choose what is suitable for you!

PS: might be related to #15969

@hsoftxl
Copy link
Contributor Author

hsoftxl commented Sep 14, 2022

thanks

@unknownbrackets
Copy link
Collaborator

On Android, it's more of a pain to use .so files and might cause problems for jni as well as the headless binary, because of OS restrictions. On Windows, it can also cause DLL confusion. We also need a specific version of FFmpeg that other people are unlikely to use - shared objects aren't designed for this use case.

Really you just need to compile ffmpeg. See #15969 and #15814 (which is essentially a duplicate at this point, really this and that both are duplicates of #15969.)

I think this is the same error I mentioned with the latest NDK, and we're still compiling with an older NDK.

-[Unknown]

@unknownbrackets unknownbrackets added the Libretro Issue on Libretro but not all ports. label Sep 18, 2022
@unknownbrackets unknownbrackets changed the title can libretro jni so support x86_64 plantform can libretro jni so support x86_64 platform (ffmpeg) Sep 18, 2022
@unknownbrackets
Copy link
Collaborator

I'm going to close this as a duplicate of #15969.

-[Unknown]

@unknownbrackets unknownbrackets closed this as not planned Won't fix, can't repro, duplicate, stale Nov 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Libretro Issue on Libretro but not all ports.
Projects
None yet
Development

No branches or pull requests

3 participants