[Bug 282188] New port: multimedia/ffmpeg3 (legacy ffmpeg as a dependency for emulators/ppsspp)

From: <bugzilla-noreply_at_freebsd.org>
Date: Mon, 28 Oct 2024 22:27:28 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=282188

--- Comment #11 from Kevin Reinholz <kreinholz@gmail.com> ---
Daniel,

Thank you very much for reviewing and for your improved patch. (And Commit
9c4f84d from the PPSSPP devs!)

I tested building your version of ffmpeg3 both manually and with synth, and it
works great. PPSSPP built against ffmpeg3 with your updates was able to play a
game with an early FMV that reliably caused PPSSPP built against higher
versions of ffmpeg to crash, so these updated options look good.

I did experiment with building ffmpeg3 static libs (just swapped CONFIGURE_ARGS
to --enable-static and --disable-shared, and of course updated pkg-plist
accordingly).

ffmpeg3 builds static libs fine, but PPSSPP gets 99% of the way through
building against static ffmpeg3, then dies during the staging portion of the
build with undefined symbol errors related to lzma and bz2:

ld: error: undefined symbol: lzma_stream_decoder
>>> referenced by tiff.c:396 (libavcodec/tiff.c:396)
>>>               tiff.o:(decode_frame) in archive /usr/local/ffmpeg3/lib/libavcodec.a

ld: error: undefined symbol: lzma_code
>>> referenced by tiff.c:401 (libavcodec/tiff.c:401)
>>>               tiff.o:(decode_frame) in archive /usr/local/ffmpeg3/lib/libavcodec.a

ld: error: undefined symbol: lzma_end
>>> referenced by tiff.c:402 (libavcodec/tiff.c:402)
>>>               tiff.o:(decode_frame) in archive /usr/local/ffmpeg3/lib/libavcodec.a

ld: error: undefined symbol: BZ2_bzDecompressInit
>>> referenced by matroskadec.c:1327 (libavformat/matroskadec.c:1327)
>>>               matroskadec.o:(matroska_decode_buffer) in archive /usr/local/ffmpeg3/lib/libavformat.a
ld: error: undefined symbol: BZ2_bzDecompress
>>> referenced by matroskadec.c:1342 (libavformat/matroskadec.c:1342)
>>>               matroskadec.o:(matroska_decode_buffer) in archive /usr/local/ffmpeg3/lib/libavformat.a

ld: error: undefined symbol: BZ2_bzDecompressEnd
>>> referenced by matroskadec.c:1345 (libavformat/matroskadec.c:1345)
>>>               matroskadec.o:(matroska_decode_buffer) in archive /usr/local/ffmpeg3/lib/libavformat.a
>>> referenced by matroskadec.c:1335 (libavformat/matroskadec.c:1335)
>>>               matroskadec.o:(matroska_decode_buffer) in archive /usr/local/ffmpeg3/lib/libavformat.a
c++: error: linker command failed with exit code 1 (use -v to see invocation)


I ran `ldd` on the shared lib versions of libavcodec.so and libavformat.so, and
sure enough lzma and bz2 are properly linked:

/usr/local/ffmpeg3/lib/libavcodec.so:
        libswresample.so.2 => /usr/local/ffmpeg3/lib/libswresample.so.2
(0x18e4d4e54000)
        libavutil.so.55 => /usr/local/ffmpeg3/lib/libavutil.so.55
(0x18e4d505f000)
        libm.so.5 => /lib/libm.so.5 (0x18e4d570c000)
        liblzma.so.5 => /usr/lib/liblzma.so.5 (0x18e4d8153000)
        libz.so.6 => /lib/libz.so.6 (0x18e4d8f88000)
        libthr.so.3 => /lib/libthr.so.3 (0x18e4d9ae1000)
        libc.so.7 => /lib/libc.so.7 (0x18e4d4514000)
        libmd.so.6 => /lib/libmd.so.6 (0x18e4d9e3d000)

/usr/local/ffmpeg3/lib/libavformat.so:
        libavcodec.so.57 => /usr/local/ffmpeg3/lib/libavcodec.so.57
(0x995d3e00000)
        libavutil.so.55 => /usr/local/ffmpeg3/lib/libavutil.so.55
(0x995d18e1000)
        libm.so.5 => /lib/libm.so.5 (0x995d2b33000)
        libbz2.so.4 => /usr/lib/libbz2.so.4 (0x995d306c000)
        libz.so.6 => /lib/libz.so.6 (0x995d551a000)
        libthr.so.3 => /lib/libthr.so.3 (0x995d6a3b000)
        libc.so.7 => /lib/libc.so.7 (0x995d12c2000)
        libswresample.so.2 => /usr/local/ffmpeg3/lib/libswresample.so.2
(0x995d5ce2000)
        liblzma.so.5 => /usr/lib/liblzma.so.5 (0x995d7708000)
        libmd.so.6 => /lib/libmd.so.6 (0x995d7f81000)

So I'm not surprised those undefined symbol errors do not occur when building
PPSSPP against shared ffmpeg3 libs.

The linker errors occur with static ffmpeg3 libs regardless of whether I hack
PPSSPP's CMakeLists.txt to have it find ffmpeg in /usr/local/ffmpeg3
(system_ffmpeg, albeit static libs) or whether I manually copy over the
contents of /usr/local/ffmpeg3/ to
/usr/ports/emulators/ppsspp/work/ppsspp-1.17.1/ffmpeg/FreeBSD/x86_64/ and then
add a conditional so cmake finds bundled_ffmpeg where it would be expected if
PPSSPP shipped with precompiled ffmpeg binaries for FreeBSD.

I haven't been smart enough to pinpoint the exact problem yet, but I suspect it
has to do with the way static ffmpeg3 is built, and it continuing to link
against the shared version of lzma and bz2 rather than picking up the static
versions (which I confirmed exist in /usr/lib alongside the shared versions),
or perhaps omitting them altogether.

ffmpeg3 with shared libs is really easy to set as a dependency of
emulators/ppsspp with minimal changes to the existing port; getting PPSSPP to
build against static ffmpeg3 on FreeBSD is going to be more of a project. I'm
not sure how much the juice is worth the squeeze to get ppsspp to build against
static ffmpeg3 so it can serve solely as a build dependency and not hang around
the system after ppsspp is built.

-- 
You are receiving this mail because:
You are the assignee for the bug.