From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:470:142:3::10]:41345) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hkW3h-00015i-7N for guix-patches@gnu.org; Mon, 08 Jul 2019 12:00:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hkW3f-000680-6Y for guix-patches@gnu.org; Mon, 08 Jul 2019 12:00:05 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:50530) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hkW3f-00066n-0S for guix-patches@gnu.org; Mon, 08 Jul 2019 12:00:03 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1hkW3e-0001gj-PB for guix-patches@gnu.org; Mon, 08 Jul 2019 12:00:02 -0400 Subject: [bug#36535] [PATCH] gnu: gobject-introspection: Update absolute-shlib-path.patch. Resent-Message-ID: References: <20190707104803.23662-1-mail@cbaines.net> <87d0il9deh.fsf@cbaines.net> <875zocr4hl.fsf@devup.no> From: Christopher Baines In-reply-to: <875zocr4hl.fsf@devup.no> Date: Mon, 08 Jul 2019 16:59:13 +0100 Message-ID: <87bly4a566.fsf@cbaines.net> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+kyle=kyleam.com@gnu.org Sender: "Guix-patches" To: Marius Bakke Cc: 36535@debbugs.gnu.org --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Marius Bakke writes: > Hi Chris, > > Christopher Baines writes: > >> Christopher Baines writes: >> >>> Incorporate some changes from nixpkgs to the gobject-introspection pack= age >>> patches. This is motivated by looking at issues with libsoup and lolly= pop. >>> This changes means that the share/gir-1.0/Soup-2.4.gir file within libs= oup >>> references libsoup-2.4.so.1 with an absolute filename, whereas previous= ly, the >>> filename wasn't absolute. >>> >>> * gnu/packages/patches/gobject-introspection-absolute-shlib-path.patch: >>> Incorporate changes from nixpkgs. >>> --- >>> ...ct-introspection-absolute-shlib-path.patch | 141 +++++++++++++++++- >>> 1 file changed, 137 insertions(+), 4 deletions(-) >>> >> >> I've pushed this as [1] to core-updates now, as I wanted to get it in >> before the freeze. > > Thank you for addressing this. IIUC previously lollypop failed to > retain a reference to libsoup-2.4.so.1, whereas with this patch it does? Not quite... I think lollypop was reading the typelib in libsoup, but the shared library was just referenced by filename, not the absolute filename, and I think this was causing issues when trying to use libsoup from lollypop. On master: grep shared-library /gnu/store/bafaiiblr2vmmf1zvidkw1137ndqnqg2-libsoup-2.6= 6.2/share/gir-1.0/Soup-2.4.gir shared-library=3D"libsoup-2.4.so.1" On core-updates: grep shared-library /gnu/store/b1ykh6xj11v7zav4r68v8qflk31cnddm-libsoup-2.6= 6.2/share/gir-1.0/Soup-2.4.gir shared-library=3D"/gnu/store/b1ykh6xj11v7zav4r68v8qflk31cnddm-= libsoup-2.66.2/lib/libsoup-2.4.so.1" > A few comments about the patch: > >> diff --git a/gnu/packages/patches/gobject-introspection-absolute-shlib-p= ath.patch b/gnu/packages/patches/gobject-introspection-absolute-shlib-path.= patch >> index d00cc5a420..3c0bb1c6cf 100644 >> --- a/gnu/packages/patches/gobject-introspection-absolute-shlib-path.pat= ch >> +++ b/gnu/packages/patches/gobject-introspection-absolute-shlib-path.pat= ch >> @@ -2,10 +2,131 @@ >> # add the full path. >> # >> # This patch was provided by Luca Bruno for >> -# 'gobject-introspection' 1.40.0 in Nix. >> ---- ./giscanner/utils.py.orig 2014-08-14 22:05:05.055334080 +0200 >> -+++ ./giscanner/utils.py 2014-08-14 22:05:24.687497334 +0200 >> -@@ -110,17 +110,11 @@ >> +# 'gobject-introspection' 1.40.0 in Nix. >> +# >> +# It has since been updated to work with newer versions of >> +# gobject-introspection. >> +--- a/giscanner/scannermain.py >> ++++ b/giscanner/scannermain.py >> +@@ -95,6 +95,39 @@ def get_windows_option_group(parser): >> + return group >> + >> + >> ++def _get_default_fallback_libpath(): >> ++ # Newer multiple-output-optimized stdenv has an environment variab= le >> ++ # $outputLib which in turn specifies another variable which then i= s used as >> ++ # the destination for the library contents (${!outputLib}/lib). >> ++ store_path =3D os.environ.get(os.environ.get("outputLib")) if "out= putLib" in os.environ else None >> ++ if store_path is None: >> ++ outputs =3D os.environ.get("outputs", "out").split() > > gnu-build-system does not currently export an "outputs" variable. > Perhaps it should? Ah, I didn't realise this part of the patch was as Nix specific as it is... At least for the change I was trying to affect, this seems to be probably redundant, or somehow doing the job. Maybe this part of the patch relating to the fallback_libpath should be removed. >> ++ if "lib" in outputs: >> ++ # For multiple output derivations let's try whether there = is a $lib >> ++ # environment variable and use that as the base store path. >> ++ store_path =3D os.environ.get("lib") >> ++ elif "out" in outputs: >> ++ # Otherwise we have a single output derivation, so the lib= raries >> ++ # most certainly will end up in "$out/lib". >> ++ store_path =3D os.environ.get("out") > > Consequently, this is the only ever matching case, and "lib" outputs are > ignored, counter to what one might expect from glancing over this patch. > > That is, unless one sets an "outputs" or "outputLib" variable in a > package recipe, so maybe we don't have to do anything here. > >> ++ >> ++ if store_path is not None: >> ++ # Even if we have a $lib as output, there still should be a $l= ib/lib >> ++ # directory. >> ++ return os.path.join(store_path, 'lib') >> ++ else: >> ++ # If we haven't found a possible scenario, let's return an emp= ty string >> ++ # so that the shared library won't be prepended with a path. >> ++ # >> ++ # Note that this doesn't mean that all hope is lost, because a= fter all >> ++ # we can still use --fallback-library-path to set one. >> ++ # >> ++ # Also, we're not returning None, because that would make it v= ery >> ++ # difficult to disable adding fallback paths altogether using = something >> ++ # like: --fallback-library-path=3D"" >> ++ return "" >> ++ >> ++ >> + def _get_option_parser(): >> + parser =3D optparse.OptionParser('%prog [options] sources', >> + version=3D'%prog ' + giscanner.__ve= rsion__) >> +@@ -205,6 +238,10 @@ match the namespace prefix.""") >> + parser.add_option("", "--filelist", >> + action=3D"store", dest=3D"filelist", default=3D[= ], >> + help=3D"file containing headers and sources to b= e scanned") >> ++ parser.add_option("", "--fallback-library-path", >> ++ action=3D"store", dest=3D"fallback_libpath", >> ++ default=3D_get_default_fallback_libpath(), >> ++ help=3D"Path to prepend to unknown shared librar= ies") >> + >> + group =3D get_preprocessor_option_group(parser) >> + parser.add_option_group(group) >> +--- a/giscanner/shlibs.py >> ++++ b/giscanner/shlibs.py >> +@@ -57,6 +57,12 @@ def _ldd_library_pattern(library_name): >> + $""" % re.escape(library_name), re.VERBOSE) >> + >> + >> ++def _ldd_library_guix_pattern(library_name): >> ++ store_dir =3D re.escape('/gnu/store') > > Here we should use: > > os.environ.get("NIX_STORE") if "NIX_STORE" in os.environ else "/gnu/stor= e" > > So that it works for non-default store prefixes. Given NIX_STORE is set at build time, and this code is mostly used at build time, then that would work. Before I was thinking about how to actually put the store path in the code at build time, but that's probably not necessary. >> ++ pattern =3D r'(%s(?:/[^/]*)+lib%s[^A-Za-z0-9_-][^\s\(\)]*)' >> ++ return re.compile(pattern % (store_dir, re.escape(library_name))) >> ++ >> ++ >> + # This is a what we do for non-la files. We assume that we are on an >> + # ELF-like system where ldd exists and the soname extracted with ldd is >> + # a filename that can be opened with dlopen(). >> +@@ -106,7 +112,8 @@ def _resolve_non_libtool(options, binary, libraries= ): >> + output =3D output.decode("utf-8", "replace") >> + >> + shlibs =3D resolve_from_ldd_output(libraries, output) >> +- return list(map(sanitize_shlib_path, shlibs)) >> ++ fallback_libpath =3D options.fallback_libpath or ""; >> ++ return list(map(lambda p: os.path.join(fallback_libpath, p), m= ap(sanitize_shlib_path, shlibs))) >> + >> + >> + def sanitize_shlib_path(lib): >> +@@ -115,19 +122,18 @@ def sanitize_shlib_path(lib): >> + # In case we get relative paths on macOS (like @rpath) then we fall >> + # back to the basename as well: >> + # https://gitlab.gnome.org/GNOME/gobject-introspection/issues/222 >> +- if sys.platform =3D=3D "darwin": >> +- if not os.path.isabs(lib): >> +- return os.path.basename(lib) >> +- return lib >> +- else: >> ++ >> ++ # Always use absolute paths if available >> ++ if not os.path.isabs(lib): >> + return os.path.basename(lib) >> ++ return lib >> + >> + >> + def resolve_from_ldd_output(libraries, output): >> + patterns =3D {} >> + for library in libraries: >> + if not os.path.isfile(library): >> +- patterns[library] =3D _ldd_library_pattern(library) >> ++ patterns[library] =3D (_ldd_library_pattern(library), _ldd= _library_guix_pattern(library)) >> + if len(patterns) =3D=3D 0: >> + return [] >> + >> +@@ -139,8 +145,11 @@ def resolve_from_ldd_output(libraries, output): >> + if line.endswith(':'): >> + continue >> + for word in line.split(): >> +- for library, pattern in patterns.items(): >> +- m =3D pattern.match(word) >> ++ for library, (pattern, guix_pattern) in patterns.items(): >> ++ if line.find('/gnu/store') !=3D -1: > > Use $NIX_STORE here, too. > > Other than that LGTM. --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQKTBAEBCgB9FiEEPonu50WOcg2XVOCyXiijOwuE9XcFAl0jaFFfFIAAAAAALgAo aXNzdWVyLWZwckBub3RhdGlvbnMub3BlbnBncC5maWZ0aGhvcnNlbWFuLm5ldDNF ODlFRUU3NDU4RTcyMEQ5NzU0RTBCMjVFMjhBMzNCMEI4NEY1NzcACgkQXiijOwuE 9XcFcRAAltWo2Jsf7FqUhdceW/U47N1X7pCQLFsYD5xD0z4tRKGOwOiS3kelqb7f RAAA8cjOqOYN1t0uFamcL82EkZ+RWAj0CJQn4cP81S5p/YrhwWXbMVH4CX2XrX44 okFdpyvkEnRxZ1O30VdlMrtTdgWxG/qQkK/9ZFgLCvxn2Qnw6zIpEuZnm8rrIBft WCz3fmFzd69NN2JM60MOVyta0i6zI4cFOL0i+LqtZCIQGurh3nMvAhN+GE+9/uQ2 OdrZTRN6PNny6rcpN4ZOZ6NE10s5uBHMw9MMUN9A2Lj+1BqAv2nBSzqvmZrmfkGH 6O6e13Y19RYPaNIXPH4W3KaycDRYu2xYhd018PVmBZ1kA4A7P5hll7Vgwv70vH4n wkUDpeKEjl9F7SMnsv28vyDZyV+FiY7rsnXyq6N08+DHH9BJllwgfkqdx5ktRgB+ 54WCETrkG5cZNQ1lqniySXVQIsyEAYpwBaQBOhKILx+zuA4RWTuy6kitwNYWQ0FA eLibQY8UL7iPo38ZuVHuWxIn3ntZkxhJ6qv5kECG+055FF2ZKSorVu9Y3q4XVkRu naWHbTTD6DGOwZ/+Z24/3FL78QN9x8xkfu/4R5Ou5/dAvwgpQO0rbD4sqYaPEnsm DFRA/jzykptvEawfQzjxuFaYxqLeeAefx01G587HPDk159H7dPE= =/I0h -----END PGP SIGNATURE----- --=-=-=--