Incorrect shared-library value in GIRs built on macOS for libraries that use @rpath in install_name
When GIRs are built on macOS with Meson, the shared-library=
entry in the GIR incorrectly prepends @rpath
to the library name.
<?xml version="1.0"?>
<!-- This file was automatically generated from C sources - DO NOT EDIT!
To affect the contents of this file, edit the original C definitions,
and/or use gtk-doc annotations. -->
<repository version="1.2"
xmlns="http://www.gtk.org/introspection/core/1.0"
xmlns:c="http://www.gtk.org/introspection/c/1.0"
xmlns:glib="http://www.gtk.org/introspection/glib/1.0">
<include name="GObject" version="2.0"/>
<package name="atk"/>
<c:include name="atk/atk.h"/>
<namespace name="Atk"
version="1.0"
shared-library="/nix/store/3y2alx23lizpj0pqsz8g9ydfcmw6b3qs-atk-2.28.1/lib/@rpath/libatk-1.0.0.dylib"
c:identifier-prefixes="Atk"
c:symbol-prefixes="atk">
...
(Example taken from the Meson bug)
I tracked this down to giscanner/shlibs.py:_resolve_non_libtool():
if platform_system == 'Darwin':
args.extend(['otool', '-L', binary.args[0]])
otool -L
here will return @rpath/libatk-1.0.0.dylib
Then it extracts the library name with this regex: "([^\s]*lib*%s[^A-Za-z0-9_-][^\s\(\)]*)"
. This will erroneously include the leading @rpath
in the result.
This doesn't happen with Autotools because it does not use @rpath
in install_name
. Meson does.