From c223011e19b3cb720f033ff91107d383a48f1586 Mon Sep 17 00:00:00 2001 From: q66 Date: Sat, 27 Apr 2019 20:31:43 +0200 Subject: [PATCH] gobject-introspection: fix wrong ld library path in cross See comments in patch for further information. This solution is a bit hacky but I don't see any other way out. Closes: #11359 [via git-merge-pr] --- .../files/g-ir-scanner-wrapper | 2 + .../0011-giscanner-ld-library-path.patch | 40 +++++++++++++++++++ srcpkgs/gobject-introspection/template | 2 +- 3 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 srcpkgs/gobject-introspection/patches/0011-giscanner-ld-library-path.patch diff --git a/srcpkgs/gobject-introspection/files/g-ir-scanner-wrapper b/srcpkgs/gobject-introspection/files/g-ir-scanner-wrapper index 4ff14ccc7be..d5c426d3cc2 100755 --- a/srcpkgs/gobject-introspection/files/g-ir-scanner-wrapper +++ b/srcpkgs/gobject-introspection/files/g-ir-scanner-wrapper @@ -4,6 +4,8 @@ if [ -n "$XBPS_CROSS_BASE" -a -n "$XBPS_TARGET_MACHINE" -a -n "$XBPS_VERSION" ]; then # This prevents g-ir-scanner from writing cache data to $HOME export GI_SCANNER_DISABLE_CACHE=1 + # This prevents the native C compiler from using $XBPS_CROSS_BASE libraries + export GI_SCANNER_EXTRA_LD_LIBRARY_PATH=/usr/lib exec /usr/bin/g-ir-scanner.wrapped \ --use-binary-wrapper=/usr/bin/g-ir-scanner-qemuwrapper \ diff --git a/srcpkgs/gobject-introspection/patches/0011-giscanner-ld-library-path.patch b/srcpkgs/gobject-introspection/patches/0011-giscanner-ld-library-path.patch new file mode 100644 index 00000000000..5d336d8f3dd --- /dev/null +++ b/srcpkgs/gobject-introspection/patches/0011-giscanner-ld-library-path.patch @@ -0,0 +1,40 @@ +This is a hack that, combined with g-ir-scanner-wrapper, allows us to put +/usr/lib inside LD_LIBRARY_PATH before all the other paths that g-ir-scanner +appends. This is very important, because if we don't put /usr/lib first, the +cross base will be first and during certain circumstances (musl, cross-endian) +the compiler will fail to execute. + +We cannot use another way to append it, because we don't want to put /usr/lib +inside the library paths for scanning - we don't want the gi scanner to +process any of these libs. We just want the native executables to run +correctly. + +As for using the literal LD_LIBRARY_PATH inside the environment - the scanner +will actually read it, but it will put it at the *end*, which does not help +us. + +Ping 'q66 ' for any questions. + +--- a/giscanner/ccompiler.py ++++ b/giscanner/ccompiler.py +@@ -180,6 +180,7 @@ class CCompiler(object): + + runtime_path_envvar = [] + runtime_paths = [] ++ extra_ld_libpath = 'GI_SCANNER_EXTRA_LD_LIBRARY_PATH' + + if os.name == 'nt': + runtime_path_envvar = ['LIB', 'PATH'] +@@ -234,6 +235,12 @@ class CCompiler(object): + else: + os.environ[envvar] = os.pathsep.join(runtime_paths) + ++ # extra paths to prepend, for cross-compiling ++ if extra_ld_libpath in os.environ: ++ os.environ[envvar] = os.pathsep.join([ ++ os.environ[extra_ld_libpath], os.environ[envvar] ++ ]) ++ + def get_external_link_flags(self, args, libraries): + # An "external" link is where the library to be introspected + # is installed on the system; this case is used for the scanning diff --git a/srcpkgs/gobject-introspection/template b/srcpkgs/gobject-introspection/template index 554aba27d5a..728fab6aca9 100644 --- a/srcpkgs/gobject-introspection/template +++ b/srcpkgs/gobject-introspection/template @@ -1,7 +1,7 @@ # Template file for 'gobject-introspection' pkgname=gobject-introspection version=1.60.0 -revision=2 +revision=3 build_style=meson pycompile_dirs="usr/lib/${pkgname}/giscanner" hostmakedepends="flex pkg-config"