glib: make sure RTLD_LOCAL is used for G_MODULE_BIND_LOCAL

Unlike Linux, Darwin defines `RTLD_LOCAL` as a non-zero value.
This commit is contained in:
Randy Eckenrode 2024-06-08 16:08:03 -04:00
parent afa876d6fe
commit bdc870b17a
No known key found for this signature in database
GPG Key ID: 64C1CD4EC2A600D9
2 changed files with 16 additions and 0 deletions

View File

@ -130,6 +130,9 @@ stdenv.mkDerivation (finalAttrs: {
# and by default meson installs in to $out/share/gdb/auto-load
# which does not help
./gdb_script.patch
# glib assumes that `RTLD_LOCAL` is defined to `0`, which is true on Linux and FreeBSD but not on Darwin.
./gmodule-rtld_local.patch
];
outputs = [ "bin" "out" "dev" "devdoc" ];

View File

@ -0,0 +1,13 @@
diff --git a/gmodule/gmodule-dl.c b/gmodule/gmodule-dl.c
index 6d1c5fab7..b21773bca 100644
--- a/gmodule/gmodule-dl.c
+++ b/gmodule/gmodule-dl.c
@@ -136,7 +136,7 @@ _g_module_open (const gchar *file_name,
lock_dlerror ();
handle = dlopen (file_name,
- (bind_local ? 0 : RTLD_GLOBAL) | (bind_lazy ? RTLD_LAZY : RTLD_NOW));
+ (bind_local ? RTLD_LOCAL : RTLD_GLOBAL) | (bind_lazy ? RTLD_LAZY : RTLD_NOW));
if (!handle)
{
const gchar *message = fetch_dlerror (TRUE);