Draft: meson: Full static linking of gstreamer-full
This merge request allows to bundle gstreamer, a selection of plugin and its dependencies recursively in a single libgstreamer-full
library. Before, gstreamer-full
created static libraries for all of the dependencies and had a huge pkg-config file with all of the linking arguments. This change is meant to serve as a base for creating precompiled library binaries that can be downloaded, for example, when building the rust bindings without having to install gstreamer locally.
This change depends on these meson PRs:
-
#13768: Adds a recursive argument to
as_link_whole
that makes the dependency statically link all of the libraries of all of its dependencies (excluding system libraries). -
#13769: Since we already have all of the objects from libraries inside
gstreamer-full
, we can override thepkg-config
files of the dependencies to point to it. To do this reliably, the best way I could find (that included all subdependencies) was to add aget_link_whole_targets
to build targets so that we could get their names. This works but there might be a cleaner way of doing it.
Since we are using new meson features, the minimum meson version needs to be updated.
Additionally, there were some issues in a few subprojects that made the static linking fail:
- In
subprojects/gst-plugins-base/ext/gl/meson.build
,cc.has_header
was being called onlibdrm
even if it was built internally, makingwrap-mode=forcefallback
fail. - The
gudev
dependency was not detecting that introspection was disabled, which compiledgobject-introspection
that at the moment causes problem withgstreamer-full
, so I passed the option explicitly. - The
sqlite3
wrap was addingshell.c
to the library sources, which contains amain
function. This may cause duplicate symbol issues when building tools. I updated the wrap version to match wrapdb#1725 where this source is removed.
Unresolved questions:
- When linking against
gstreamer-full
ingstreamer-rs
, the standard c++ library needs to be explicitly added to prevent unresolved symbols. Right now I am adding it togst_full_c_flags
if the compiler supports it, but there must be a better way of doing this. Meson should detect if the libraries it has are build using c++ and add this. - I have not tested this in Windows, so I'm not sure if the external dependency will be correct there.
At the moment, default plugins in base
, good
and ugly
are linking correctly. I have not finished testing all of the plugins in bad
, but I already fixed some of them. The setup command I was using for testing is this (make sure to use the meson patches):
Setup command
meson setup --reconfigure \
"--default-library=static" \
"--wrap-mode=forcefallback" \
"--auto-features=auto" \
"-Dgst-full-target-type=static_library" \
"-Dgst-full-libraries=*" \
\
"-Dbase=enabled" \
"-Dgood=enabled" \
"-Dbad=enabled" \
"-Dugly=enabled" \
\
"-Ddevtools=enabled" \
"-Dges=enabled" \
"-Dlibav=enabled" \
"-Drtsp_server=enabled" \
"-Dtools=enabled" \
\
"-Ddoc=disabled" \
"-Dexamples=disabled" \
"-Dintrospection=disabled" \
"-Dgpl=disabled" \
"-Dgst-examples=disabled" \
"-Dpython=disabled" \
"-Dsharp=disabled" \
"-Dtests=disabled" \
"-Dvaapi=disabled" \
\
"-Dgst-plugins-base:gl=enabled" \
"-Dgst-plugins-base:playback=enabled" \
"-Dgst-plugins-base:x11=enabled" \
"-Dgst-plugins-bad:va=enabled" \
"-Dgst-plugins-bad:curl=disabled" \
"-Dgst-plugins-bad:decklink=disabled" \
"-Dgst-plugins-bad:dtls=disabled" \
"-Dgst-plugins-bad:gtk3=disabled" \
"-Dgst-plugins-bad:iqa=disabled" \
"-Dgst-plugins-bad:lc3=disabled" \
"-Dgst-plugins-bad:nvcodec=disabled" \
"-Dgst-plugins-bad:openal=disabled" \
"-Dgst-plugins-bad:opencv=disabled" \
"-Dgst-plugins-bad:openexr=disabled" \
"-Dgst-plugins-bad:vulkan=disabled" \
"-Dgst-plugins-bad:wayland=disabled" \
\
"-Dglib:tests=false" \
"-Dharfbuzz:freetype=disabled" \
"-Dharfbuzz:cairo=disabled" \
"-Dpixman:demos=disabled" \
"-Dcairo:png=false" \
\
build
Closes #1459.