From 0a009dbfff32566341b2888530423f90f1b3d945 Mon Sep 17 00:00:00 2001 From: Ross Burton Date: Fri, 11 Mar 2016 15:35:55 +0000 Subject: glib-2.0: relocate the GIO module directory for native builds Glib hard-codes the install path in search path for GIO modules, which causes problems when glib-2.0-native is restored from sstate with a different build directory. In the future we should relocate symbols directly using the same system that the eSDK uses, but for now use dladdr() to look up where the library was loaded from to build the search path. Signed-off-by: Ross Burton Signed-off-by: Richard Purdie --- .../glib-2.0/glib-2.0/relocate-modules.patch | 49 ++++++++++++++++++++++ meta/recipes-core/glib-2.0/glib-2.0_2.46.2.bb | 3 +- 2 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 meta/recipes-core/glib-2.0/glib-2.0/relocate-modules.patch diff --git a/meta/recipes-core/glib-2.0/glib-2.0/relocate-modules.patch b/meta/recipes-core/glib-2.0/glib-2.0/relocate-modules.patch new file mode 100644 index 0000000000..f9e3f3dbaa --- /dev/null +++ b/meta/recipes-core/glib-2.0/glib-2.0/relocate-modules.patch @@ -0,0 +1,49 @@ +Instead of hard-coding GIO_MODULE_PATH when glib is built, use dladdr() to +determine where libglib.so is and use that path to calculate GIO_MODULES_DIR. + +This solves relocation problems with GIOModule for native builds of glib. + +Upstream-Status: Inappropriate +Signed-off-by: Ross Burton + +diff --git a/gio/giomodule.c b/gio/giomodule.c +index 56c498c..a2e32b7 100644 +--- a/gio/giomodule.c ++++ b/gio/giomodule.c +@@ -47,6 +47,27 @@ + #include "gdesktopappinfo.h" + #endif + ++#include ++ ++/* ++ * Generate a GIO module directory based on where glib is installed ++ */ ++static const char * ++_get_gio_module_dir (void) ++{ ++ Dl_info info; ++ ++ if (dladdr (g_io_module_new, &info)) { ++ char *libdir = g_path_get_dirname (info.dli_fname); ++ char *dir = g_build_filename (libdir, "gio", "modules", NULL); ++ g_free (libdir); ++ return dir; ++ } else { ++ return GIO_MODULE_DIR; ++ } ++} ++ ++ + /** + * SECTION:giomodule + * @short_description: Loadable GIO Modules +@@ -1057,7 +1078,7 @@ _g_io_modules_ensure_loaded (void) + /* Then load the compiled in path */ + module_dir = g_getenv ("GIO_MODULE_DIR"); + if (module_dir == NULL) +- module_dir = GIO_MODULE_DIR; ++ module_dir = _get_gio_module_dir (); + + g_io_modules_scan_all_in_directory_with_scope (module_dir, scope); + diff --git a/meta/recipes-core/glib-2.0/glib-2.0_2.46.2.bb b/meta/recipes-core/glib-2.0/glib-2.0_2.46.2.bb index bf3cadeb76..2a2efae977 100644 --- a/meta/recipes-core/glib-2.0/glib-2.0_2.46.2.bb +++ b/meta/recipes-core/glib-2.0/glib-2.0_2.46.2.bb @@ -18,7 +18,8 @@ SRC_URI = "${GNOME_MIRROR}/glib/${SHRT_VER}/glib-${PV}.tar.xz \ file://gi-exclude.patch \ " -SRC_URI_append_class-native = " file://glib-gettextize-dir.patch" +SRC_URI_append_class-native = " file://glib-gettextize-dir.patch \ + file://relocate-modules.patch" SRC_URI[md5sum] = "7f815d6e46df68e070cb421ed7f1139e" SRC_URI[sha256sum] = "5031722e37036719c1a09163cc6cf7c326e4c4f1f1e074b433c156862bd733db" -- cgit 1.2.3-korg