From 97655eb8ac70b6de0b672e8df73ece5c901371d3 Mon Sep 17 00:00:00 2001 From: Nirbheek Chauhan Date: Mon, 18 Apr 2022 15:44:47 +0530 Subject: [PATCH] meson: Add -Wl,-rpath,${libdir} on macOS We made the gstreamer installation prefix relocatable by picking up plugins relative to the location of libgstreamer-1.0.dylib, similar to how it's done for Windows: https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1627 This had a lot of side-effects: https://gitlab.freedesktop.org/gstreamer/gstreamer/-/issues/1051 https://gitlab.freedesktop.org/gstreamer/cerbero/-/issues/363 https://gitlab.freedesktop.org/gstreamer/cerbero/-/issues/371 https://gitlab.freedesktop.org/gstreamer/cerbero/-/issues/362 A partial fix for the cerbero side of these was: https://gitlab.freedesktop.org/gstreamer/cerbero/-/merge_requests/807 However, this relied on the consumers knowing that they need to add `LC_RPATH` entries to the libdir of the prefix. This is done automatically by build systems like Meson, but not by others, such as Autotools, CMake, Cargo, XCode, etc. For those, we need to add the RPATH entries to the gstreamer-1.0.pc file. This also has the side-effect of fixing the loading of gstreamer rust plugins on macOS: Fixes https://gitlab.freedesktop.org/gstreamer/gstreamer/-/issues/1159 Fixes https://gitlab.freedesktop.org/gstreamer/gstreamer/-/issues/1149 Part-of: --- subprojects/gst-plugins-base/gst-libs/gst/sdp/meson.build | 1 + subprojects/gstreamer/gst/meson.build | 2 +- subprojects/gstreamer/meson.build | 4 ++++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/subprojects/gst-plugins-base/gst-libs/gst/sdp/meson.build b/subprojects/gst-plugins-base/gst-libs/gst/sdp/meson.build index 4841d6155f..c8d3851421 100644 --- a/subprojects/gst-plugins-base/gst-libs/gst/sdp/meson.build +++ b/subprojects/gst-plugins-base/gst-libs/gst/sdp/meson.build @@ -24,6 +24,7 @@ library_def = {'lib': gstsdp} pkg_name = 'gstreamer-sdp-1.0' sdp_gen_sources = [] pkgconfig.generate(gstsdp, + libraries : [gst_dep], variables : pkgconfig_variables, subdirs : pkgconfig_subdirs, name : pkg_name, diff --git a/subprojects/gstreamer/gst/meson.build b/subprojects/gstreamer/gst/meson.build index 2692e195fd..e1e8b6c156 100644 --- a/subprojects/gstreamer/gst/meson.build +++ b/subprojects/gstreamer/gst/meson.build @@ -259,7 +259,7 @@ libgst = library('gstreamer-1.0', gst_sources, pkg_name = 'gstreamer-1.0' library_def = {'lib': libgst} pkgconfig.generate(libgst, - libraries : [glib_dep, gobject_dep], + libraries : [glib_dep, gobject_dep] + pkgconfig_libs, variables : pkgconfig_variables, uninstalled_variables: pkgconfig_uninstalled_variables, subdirs : pkgconfig_subdirs, diff --git a/subprojects/gstreamer/meson.build b/subprojects/gstreamer/meson.build index 17c7e17f9c..a293e43109 100644 --- a/subprojects/gstreamer/meson.build +++ b/subprojects/gstreamer/meson.build @@ -616,6 +616,10 @@ pkgconfig_uninstalled_variables = ['exec_prefix=${prefix}', 'bashhelpersdir=${gstreamerdir}/data/bash-completion/helpers', 'helpersdir=${gstreamerdir}/libs/gst/helpers'] pkgconfig_subdirs = ['gstreamer-1.0'] +pkgconfig_libs = [] +if host_system == 'darwin' + pkgconfig_libs = ['-Wl,-rpath,${libdir}'] +endif static_build = get_option('default_library') == 'static' libraries = []