Re: multimedia/ffmpeg: fix symbol versioning problem on stable/14

From: Andriy Gapon <avg_at_FreeBSD.org>
Date: Fri, 31 Oct 2025 10:18:56 UTC
No interest at all?
Or nobody is actually subscribed to this list? :-)

On 25/09/2025 16:16, Andriy Gapon wrote:
> 
> Preamble: I made this change a while ago but couldn't find time to share it.
> Now I see that ffmpeg 8 is in the works, so maybe I am too late or, at least, 
> the change will need some rework.
> The change addresses an issue similar to https://bugs.freebsd.org/bugzilla/ 
> show_bug.cgi?id=284651 and multiple others.
> 
> commit 7f9d8df0bafbb3ffbe0399a28b8d232bb2c58612
> Author:     Andriy Gapon <avg@FreeBSD.org>
> AuthorDate: Sat Jun 21 17:16:33 2025 +0300
> Commit:     Andriy Gapon <avg@FreeBSD.org>
> CommitDate: Sat Sep 6 15:47:50 2025 +0300
> 
>      multimedia/ffmpeg: fix symbol versioning problem on stable/14
> 
>      This is a well-known issue related to visibility of environ and __progname
>      symbols from /usr/lib/crt1.o.
> 
>      This change patches configure to give those symbols global visibility
>      when testing --version-script support.
>      Otherwise, the port would produce broken libraries without symbol versions.
> 
>      This change also adds HAS_SYMBOL_VERSION to catch the problem using
>      libavcodec.so as a canary.
> 
> diff --git a/multimedia/ffmpeg/Makefile b/multimedia/ffmpeg/Makefile
> index f7c5d80adeac..fd25b9238021 100644
> --- a/multimedia/ffmpeg/Makefile
> +++ b/multimedia/ffmpeg/Makefile
> @@ -28,6 +28,7 @@ USE_PERL5=    build
>   SHEBANG_FILES=    doc/texi2pod.pl
>   NOPRECIOUSMAKEVARS=    yes # ARCH
> 
> +HAS_SYMBOL_VERSION=    ${PREFIX}/lib/libavcodec.so
>   PORTSCOUT=    limit:^6\.
> 
>   # Option CHROMAPRINT disabled, it cannot work and people are baffled.
> diff --git a/multimedia/ffmpeg/files/patch-configure b/multimedia/ffmpeg/files/ 
> patch-configure
> index 9654237228cc..c3a166b984ca 100644
> --- a/multimedia/ffmpeg/files/patch-configure
> +++ b/multimedia/ffmpeg/files/patch-configure
> @@ -28,3 +28,12 @@
>                                -lSPVRemapper -lSPIRV -lSPIRV-Tools-opt -lSPIRV- 
> Tools -lpthread -lstdc++ -lm; }
>    enabled libgme            && { check_pkg_config libgme libgme gme/gme.h 
> gme_new_emu ||
>                                   require libgme gme/gme.h gme_new_emu -lgme - 
> lstdc++; }
> +@@ -7307,7 +7301,7 @@
> + EOF
> +
> + if enabled proper_dce; then
> +-    echo "X { local: *; };" > $TMPV
> ++    echo "X { global: environ; __progname; local: *; };" > $TMPV
> +     if test_ldflags -Wl,${version_script},$TMPV; then
> +         append SHFLAGS '-Wl,${version_script},\$(SUBDIR)lib\$(NAME).ver'
> +         quotes='""'
> 
> 
> 


-- 
Andriy Gapon