From ad8c07406043e4344fba3b5891dbe3dd3aa5d91e Mon Sep 17 00:00:00 2001 From: Valentin David Date: Wed, 27 Aug 2025 19:23:12 +0200 Subject: [PATCH] Install missing libgnome_disks.so There were two issues. First, because of missing soname, the NEEDED path was not the base name. So gnome-disks had to load the libgnome_disks.so from the build directory. And meson is not capable to rewrite that path. However it can rewrite RPATH instead. Second, the library was not installed at all. Fixes #455 --- src/disks/meson.build | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/src/disks/meson.build b/src/disks/meson.build index c69cc514..11654643 100644 --- a/src/disks/meson.build +++ b/src/disks/meson.build @@ -30,7 +30,20 @@ else message('Building in release mode') endif -cargo_env = {'CARGO_HOME': build_root / 'cargo-home'} +cargo_env = { + 'CARGO_HOME': build_root / 'cargo-home', + # Without a soname we cannot link libgnome_disks.so in build directory and + # for it to load correctly after installation, since the path in DT_NEEDED + # (in gnome-disks binary) will be the full path to libgnome_disks.so given + # the link command line. + # meson cannot rewrite DT_NEEDED entries. But it can rewrite DT_RPATH. + # And soname will make the name in DT_NEEDED a basename, and allow + # us to use DT_RPATH. + # Now, cargo does not allow us to set the soname, but rust can. So we + # are forced to set RUSTFLAGS. + # See https://github.com/rust-lang/cargo/issues/5045 + 'RUSTFLAGS': '-Clink-arg=-Wl,-soname=libgnome_disks.so', +} cargo_build = custom_target( 'cargo-build', @@ -46,6 +59,8 @@ cargo_build = custom_target( ], ) +private_libdir = join_paths(get_option('prefix'), get_option('libdir')) / 'gnome_disks' + # meson expects the .so file to be in the disks build directory libgnome_disks = custom_target( 'libgnome_disks', @@ -62,7 +77,6 @@ libgnome_disks = custom_target( libgnome_disks_dep = declare_dependency( sources: libgnome_disks, - link_args: [build_root / 'src' / 'disks' / 'libgnome_disks.so'], ) # Build C version @@ -179,6 +193,8 @@ executable( sources, include_directories: top_inc, dependencies: deps, + build_rpath: meson.current_build_dir(), + install_rpath: private_libdir, c_args: cflags, install: true, )