* Re: [PR PATCH] [Updated] [RFC] gobject-introspection: used elfutils lldwraper instead of prelink-cross
2024-03-22 23:56 [PR PATCH] [RFC] gobject-introspection: used elfutils lldwraper instead of prelink-cross oreo639
@ 2024-03-22 23:57 ` oreo639
2024-03-23 0:06 ` [PR PATCH] [Updated] [RFC] gobject-introspection: use " oreo639
` (9 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: oreo639 @ 2024-03-22 23:57 UTC (permalink / raw)
To: ml
[-- Attachment #1: Type: text/plain, Size: 1581 bytes --]
There is an updated pull request by oreo639 against master on the void-packages repository
https://github.com/oreo639/void-packages gi-cross
https://github.com/void-linux/void-packages/pull/49468
[RFC] gobject-introspection: used elfutils lldwraper instead of prelink-cross
Replace lldwraper with one maintained by Debian using elfutils. elfutils is already a dependency of glib.
https://salsa.debian.org/gnome-team/gobject-introspection/-/blob/debian/latest/debian/elf-get-needed.c
https://gitlab.gnome.org/GNOME/gobject-introspection/-/issues/482
<!-- Uncomment relevant sections and delete options which are not applicable -->
#### Testing the changes
- I tested the changes in this PR: **briefly**
<!--
#### New package
- This new package conforms to the [package requirements](https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#package-requirements): **YES**|**NO**
-->
<!-- Note: If the build is likely to take more than 2 hours, please add ci skip tag as described in
https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#continuous-integration
and test at least one native build and, if supported, at least one cross build.
Ignore this section if this PR is not skipping CI.
-->
<!--
#### Local build testing
- I built this PR locally for my native architecture, (ARCH-LIBC)
- I built this PR locally for these architectures (if supported. mark crossbuilds):
- aarch64-musl
- armv7l
- armv6l-musl
-->
A patch file from https://github.com/void-linux/void-packages/pull/49468.patch is attached
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-gi-cross-49468.patch --]
[-- Type: text/x-diff, Size: 9033 bytes --]
From a0b38e2a9b45cbcb70fb42b4238e5867fdd5e0da Mon Sep 17 00:00:00 2001
From: oreo639 <oreo6391@gmail.com>
Date: Fri, 22 Mar 2024 16:47:54 -0700
Subject: [PATCH] gobject-introspection: use elfutils lldwraper instead of
prelink-cross
Replace lldwraper with one maintained by Debian using elfutils.
elfutils is already a dependency of glib.
https://salsa.debian.org/gnome-team/gobject-introspection/-/blob/debian/latest/debian/elf-get-needed.c
https://gitlab.gnome.org/GNOME/gobject-introspection/-/issues/482
---
.../files/elf-get-needed.c | 156 ++++++++++++++++++
.../files/g-ir-scanner-lddwrapper | 2 -
...-error-return-codes-from-ldd-wrapper.patch | 27 ---
srcpkgs/gobject-introspection/template | 14 +-
4 files changed, 165 insertions(+), 34 deletions(-)
create mode 100644 srcpkgs/gobject-introspection/files/elf-get-needed.c
delete mode 100755 srcpkgs/gobject-introspection/files/g-ir-scanner-lddwrapper
delete mode 100644 srcpkgs/gobject-introspection/patches/0006-giscanner-ignore-error-return-codes-from-ldd-wrapper.patch
diff --git a/srcpkgs/gobject-introspection/files/elf-get-needed.c b/srcpkgs/gobject-introspection/files/elf-get-needed.c
new file mode 100644
index 00000000000000..be78f3bdf2a925
--- /dev/null
+++ b/srcpkgs/gobject-introspection/files/elf-get-needed.c
@@ -0,0 +1,156 @@
+/*
+ * Copyright © 2019-2023 Collabora Ltd.
+ * SPDX-License-Identifier: MIT
+ *
+ * Use libelf to parse ELF headers for DT_NEEDED, and fake the output
+ * format of ldd closely enough that GObject-Introspection can parse it.
+ *
+ * Limitations when compared with real ldd:
+ * - Only direct dependencies are output: unlike ldd, this is not recursive.
+ * For GObject-Introspection this is what we ideally want anyway.
+ * - Only bare SONAMEs are output, no paths or other extraneous information.
+ *
+ * https://salsa.debian.org/gnome-team/gobject-introspection/-/blob/debian/latest/debian/elf-get-needed.c
+ * https://gitlab.gnome.org/GNOME/gobject-introspection/-/issues/482
+ */
+
+#include <fcntl.h>
+#include <stddef.h>
+#include <stdio.h>
+#include <unistd.h>
+
+#include <elf.h>
+#include <gelf.h>
+
+#if 0
+#define trace(...) fprintf(stderr, __VA_ARGS__)
+#else
+#define trace(...) do {} while (0)
+#endif
+
+int
+main (int argc,
+ char **argv)
+{
+ const char *library;
+ Elf *elf = NULL;
+ Elf_Scn *scn = NULL;
+ GElf_Shdr shdr_mem;
+ GElf_Shdr *shdr = NULL;
+ size_t phnum;
+ size_t i;
+ Elf_Data *data;
+ uintptr_t needed_offset = (uintptr_t) -1;
+ const char *needed;
+ size_t sh_entsize;
+ int fd;
+
+ if (argc != 2)
+ {
+ fprintf (stderr, "Usage: %s LIBRARY\n", argv[0]);
+ return 2;
+ }
+
+ library = argv[1];
+
+ if (elf_version (EV_CURRENT) == EV_NONE)
+ {
+ perror ("elf_version(EV_CURRENT)");
+ return 1;
+ }
+
+ if ((fd = open (library, O_RDONLY | O_CLOEXEC, 0)) < 0)
+ {
+ perror (library);
+ return 1;
+ }
+
+ if ((elf = elf_begin (fd, ELF_C_READ, NULL)) == NULL)
+ {
+ fprintf (stderr, "Error reading library %s: %s",
+ library, elf_errmsg (elf_errno ()));
+ return 1;
+ }
+
+ if (elf_getphdrnum (elf, &phnum) < 0)
+ {
+
+ fprintf (stderr, "Unable to determine the number of program headers: %s\n",
+ elf_errmsg (elf_errno ()));
+
+ return 1;
+ }
+
+ trace ("phnum=%zu\n", phnum);
+
+ for (i = 0; i < phnum; i++)
+ {
+ GElf_Phdr phdr_mem;
+ GElf_Phdr *phdr = gelf_getphdr (elf, i, &phdr_mem);
+
+ if (phdr != NULL && phdr->p_type == PT_DYNAMIC)
+ {
+ scn = gelf_offscn (elf, phdr->p_offset);
+ trace ("scn=%p\n", scn);
+
+ if (scn == NULL)
+ {
+ fprintf (stderr, "Unable to get the section: %s\n",
+
+ elf_errmsg (elf_errno ()));
+
+ return 1;
+ }
+
+ shdr = gelf_getshdr (scn, &shdr_mem);
+ trace ("shdr=%p, shdr_mem=%p\n", shdr, &shdr_mem);
+
+ if (shdr == NULL)
+ {
+ fprintf (stderr, "Unable to get the section header: %s\n",
+
+ elf_errmsg (elf_errno ()));
+
+ return 1;
+ }
+ break;
+ }
+ }
+
+ if (shdr == NULL)
+ {
+ fprintf (stderr, "Unable to find the section header\n");
+ return 1;
+ }
+
+ data = elf_getdata (scn, NULL);
+
+ if (data == NULL)
+ {
+ fprintf (stderr, "Unable to get the dynamic section data: %s\n",
+ elf_errmsg (elf_errno ()));
+
+ return 1;
+ }
+
+ trace ("data=%p\n", data);
+
+ sh_entsize = gelf_fsize (elf, ELF_T_DYN, 1, EV_CURRENT);
+ trace ("sh_entsize=%zu\n", sh_entsize);
+
+ for (i = 0; i < shdr->sh_size / sh_entsize; i++)
+ {
+ GElf_Dyn dyn_mem;
+ GElf_Dyn *dyn = gelf_getdyn (data, i, &dyn_mem);
+
+ if (dyn == NULL)
+ break;
+
+ if (dyn->d_tag == DT_NEEDED)
+ printf ("%s\n", elf_strptr (elf, shdr->sh_link, dyn->d_un.d_ptr));
+ }
+
+ elf_end (elf);
+ close (fd);
+ return 0;
+}
diff --git a/srcpkgs/gobject-introspection/files/g-ir-scanner-lddwrapper b/srcpkgs/gobject-introspection/files/g-ir-scanner-lddwrapper
deleted file mode 100755
index b969836b66422a..00000000000000
--- a/srcpkgs/gobject-introspection/files/g-ir-scanner-lddwrapper
+++ /dev/null
@@ -1,2 +0,0 @@
-#!/bin/sh
-/usr/bin/prelink-rtld --root=${XBPS_CROSS_BASE} "$@"
diff --git a/srcpkgs/gobject-introspection/patches/0006-giscanner-ignore-error-return-codes-from-ldd-wrapper.patch b/srcpkgs/gobject-introspection/patches/0006-giscanner-ignore-error-return-codes-from-ldd-wrapper.patch
deleted file mode 100644
index 9167f042e5b4e4..00000000000000
--- a/srcpkgs/gobject-introspection/patches/0006-giscanner-ignore-error-return-codes-from-ldd-wrapper.patch
+++ /dev/null
@@ -1,27 +0,0 @@
-From f128cbeead687bfc6532cc1f2cc3e2dc5a2b5b30 Mon Sep 17 00:00:00 2001
-From: Alexander Kanavin <alex.kanavin@gmail.com>
-Date: Wed, 5 Sep 2018 16:46:52 +0200
-Subject: [PATCH] giscanner: ignore error return codes from ldd-wrapper
-
-prelink-rtld, which we use instead of ldd returns 127 when it can't find a library.
-It is not an error per se, but it breaks subprocess.check_output().
-
-Upstream-Status: Inappropriate [oe-core specific]
-Signed-off-by: Alexander Kanavin <alex.kanavin@gmail.com>
----
- giscanner/shlibs.py | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/giscanner/shlibs.py b/giscanner/shlibs.py
-index 01d21a3..3bd3250 100644
---- a/giscanner/shlibs.py
-+++ b/giscanner/shlibs.py
-@@ -108,7 +108,7 @@ def _resolve_non_libtool(options, binary, libraries):
- args.extend(['otool', '-L', binary.args[0]])
- else:
- args.extend(['ldd', binary.args[0]])
-- output = subprocess.check_output(args)
-+ output = subprocess.run(args, check=False, stdout=subprocess.PIPE).stdout
- if isinstance(output, bytes):
- output = output.decode("utf-8", "replace")
-
diff --git a/srcpkgs/gobject-introspection/template b/srcpkgs/gobject-introspection/template
index 356646ced3117f..ed284572fc3f45 100644
--- a/srcpkgs/gobject-introspection/template
+++ b/srcpkgs/gobject-introspection/template
@@ -1,13 +1,13 @@
# Template file for 'gobject-introspection'
pkgname=gobject-introspection
version=1.76.1
-revision=3
+revision=4
build_style=meson
pycompile_dirs="usr/lib/${pkgname}/giscanner"
hostmakedepends="flex pkg-config"
# won't run tests with cairo to avoid cyclical deps
-makedepends="libffi-devel libglib-devel python3-devel python3-Mako
- python3-Markdown"
+makedepends="libffi-devel libglib-devel python3-devel elfutils-devel
+ python3-Mako python3-Markdown"
depends="libgirepository-devel python3-Mako python3-Markdown python3-setuptools"
short_desc="Introspection system for GObject-based libraries"
maintainer="Enno Boland <gottox@voidlinux.org>"
@@ -18,20 +18,24 @@ checksum=196178bf64345501dcdc4d8469b36aa6fe80489354efe71cb7cb8ab82a3738bf
python_version=3
if [ "$CROSS_BUILD" ]; then
- hostmakedepends+=" gobject-introspection qemu-user-static prelink-cross"
+ hostmakedepends+=" gobject-introspection qemu-user-static"
configure_args+=" -Dgi_cross_use_prebuilt_gi=true
-Dgi_cross_binary_wrapper=/usr/bin/g-ir-scanner-qemuwrapper
-Dgi_cross_ldd_wrapper=/usr/bin/g-ir-scanner-lddwrapper
-Dgi_cross_pkgconfig_sysroot_path=${XBPS_CROSS_BASE}"
fi
+post_build() {
+ $CC $CFLAGS $LDFLAGS ${FILESDIR}/elf-get-needed.c -lelf -o elf-get-needed
+}
+
post_install() {
rm ${DESTDIR}/usr/lib/gobject-introspection/giscanner/doctemplates/*/meson.build
# Install our wrappers system-wide, they are required for building all other
# gobject-based packages.
vbin ${FILESDIR}/g-ir-scanner-qemuwrapper
- vbin ${FILESDIR}/g-ir-scanner-lddwrapper
+ vbin elf-get-needed g-ir-scanner-lddwrapper
# Install g-ir-scanner-wrapper as g-ir-scanner, we need it with that name since
# we can't expect people to just not hardcode /usr/bin/g-ir-scanner, some packages
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PR PATCH] [Updated] [RFC] gobject-introspection: use elfutils lldwraper instead of prelink-cross
2024-03-22 23:56 [PR PATCH] [RFC] gobject-introspection: used elfutils lldwraper instead of prelink-cross oreo639
2024-03-22 23:57 ` [PR PATCH] [Updated] " oreo639
@ 2024-03-23 0:06 ` oreo639
2024-03-24 9:06 ` oreo639
` (8 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: oreo639 @ 2024-03-23 0:06 UTC (permalink / raw)
To: ml
[-- Attachment #1: Type: text/plain, Size: 1580 bytes --]
There is an updated pull request by oreo639 against master on the void-packages repository
https://github.com/oreo639/void-packages gi-cross
https://github.com/void-linux/void-packages/pull/49468
[RFC] gobject-introspection: use elfutils lldwraper instead of prelink-cross
Replace lldwraper with one maintained by Debian using elfutils. elfutils is already a dependency of glib.
https://salsa.debian.org/gnome-team/gobject-introspection/-/blob/debian/latest/debian/elf-get-needed.c
https://gitlab.gnome.org/GNOME/gobject-introspection/-/issues/482
<!-- Uncomment relevant sections and delete options which are not applicable -->
#### Testing the changes
- I tested the changes in this PR: **briefly**
<!--
#### New package
- This new package conforms to the [package requirements](https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#package-requirements): **YES**|**NO**
-->
<!-- Note: If the build is likely to take more than 2 hours, please add ci skip tag as described in
https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#continuous-integration
and test at least one native build and, if supported, at least one cross build.
Ignore this section if this PR is not skipping CI.
-->
<!--
#### Local build testing
- I built this PR locally for my native architecture, (ARCH-LIBC)
- I built this PR locally for these architectures (if supported. mark crossbuilds):
- aarch64-musl
- armv7l
- armv6l-musl
-->
A patch file from https://github.com/void-linux/void-packages/pull/49468.patch is attached
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-gi-cross-49468.patch --]
[-- Type: text/x-diff, Size: 12408 bytes --]
From 3a32cf6aa790885b8de265880fcc56a24e37656b Mon Sep 17 00:00:00 2001
From: oreo639 <oreo6391@gmail.com>
Date: Fri, 22 Mar 2024 16:47:54 -0700
Subject: [PATCH] gobject-introspection: use elfutils lldwraper instead of
prelink-cross
Replace lldwraper with one maintained by Debian using elfutils.
elfutils is already a dependency of glib.
https://salsa.debian.org/gnome-team/gobject-introspection/-/blob/debian/latest/debian/elf-get-needed.c
https://gitlab.gnome.org/GNOME/gobject-introspection/-/issues/482
---
.../files/elf-get-needed.c | 156 ++++++++++++++++++
.../files/g-ir-scanner-lddwrapper | 2 -
...-error-return-codes-from-ldd-wrapper.patch | 27 ---
...33082a42202c55dc3d5cbc984cc9b6b01629.patch | 73 ++++++++
srcpkgs/gobject-introspection/template | 14 +-
5 files changed, 238 insertions(+), 34 deletions(-)
create mode 100644 srcpkgs/gobject-introspection/files/elf-get-needed.c
delete mode 100755 srcpkgs/gobject-introspection/files/g-ir-scanner-lddwrapper
delete mode 100644 srcpkgs/gobject-introspection/patches/0006-giscanner-ignore-error-return-codes-from-ldd-wrapper.patch
create mode 100644 srcpkgs/gobject-introspection/patches/fb6f33082a42202c55dc3d5cbc984cc9b6b01629.patch
diff --git a/srcpkgs/gobject-introspection/files/elf-get-needed.c b/srcpkgs/gobject-introspection/files/elf-get-needed.c
new file mode 100644
index 00000000000000..be78f3bdf2a925
--- /dev/null
+++ b/srcpkgs/gobject-introspection/files/elf-get-needed.c
@@ -0,0 +1,156 @@
+/*
+ * Copyright © 2019-2023 Collabora Ltd.
+ * SPDX-License-Identifier: MIT
+ *
+ * Use libelf to parse ELF headers for DT_NEEDED, and fake the output
+ * format of ldd closely enough that GObject-Introspection can parse it.
+ *
+ * Limitations when compared with real ldd:
+ * - Only direct dependencies are output: unlike ldd, this is not recursive.
+ * For GObject-Introspection this is what we ideally want anyway.
+ * - Only bare SONAMEs are output, no paths or other extraneous information.
+ *
+ * https://salsa.debian.org/gnome-team/gobject-introspection/-/blob/debian/latest/debian/elf-get-needed.c
+ * https://gitlab.gnome.org/GNOME/gobject-introspection/-/issues/482
+ */
+
+#include <fcntl.h>
+#include <stddef.h>
+#include <stdio.h>
+#include <unistd.h>
+
+#include <elf.h>
+#include <gelf.h>
+
+#if 0
+#define trace(...) fprintf(stderr, __VA_ARGS__)
+#else
+#define trace(...) do {} while (0)
+#endif
+
+int
+main (int argc,
+ char **argv)
+{
+ const char *library;
+ Elf *elf = NULL;
+ Elf_Scn *scn = NULL;
+ GElf_Shdr shdr_mem;
+ GElf_Shdr *shdr = NULL;
+ size_t phnum;
+ size_t i;
+ Elf_Data *data;
+ uintptr_t needed_offset = (uintptr_t) -1;
+ const char *needed;
+ size_t sh_entsize;
+ int fd;
+
+ if (argc != 2)
+ {
+ fprintf (stderr, "Usage: %s LIBRARY\n", argv[0]);
+ return 2;
+ }
+
+ library = argv[1];
+
+ if (elf_version (EV_CURRENT) == EV_NONE)
+ {
+ perror ("elf_version(EV_CURRENT)");
+ return 1;
+ }
+
+ if ((fd = open (library, O_RDONLY | O_CLOEXEC, 0)) < 0)
+ {
+ perror (library);
+ return 1;
+ }
+
+ if ((elf = elf_begin (fd, ELF_C_READ, NULL)) == NULL)
+ {
+ fprintf (stderr, "Error reading library %s: %s",
+ library, elf_errmsg (elf_errno ()));
+ return 1;
+ }
+
+ if (elf_getphdrnum (elf, &phnum) < 0)
+ {
+
+ fprintf (stderr, "Unable to determine the number of program headers: %s\n",
+ elf_errmsg (elf_errno ()));
+
+ return 1;
+ }
+
+ trace ("phnum=%zu\n", phnum);
+
+ for (i = 0; i < phnum; i++)
+ {
+ GElf_Phdr phdr_mem;
+ GElf_Phdr *phdr = gelf_getphdr (elf, i, &phdr_mem);
+
+ if (phdr != NULL && phdr->p_type == PT_DYNAMIC)
+ {
+ scn = gelf_offscn (elf, phdr->p_offset);
+ trace ("scn=%p\n", scn);
+
+ if (scn == NULL)
+ {
+ fprintf (stderr, "Unable to get the section: %s\n",
+
+ elf_errmsg (elf_errno ()));
+
+ return 1;
+ }
+
+ shdr = gelf_getshdr (scn, &shdr_mem);
+ trace ("shdr=%p, shdr_mem=%p\n", shdr, &shdr_mem);
+
+ if (shdr == NULL)
+ {
+ fprintf (stderr, "Unable to get the section header: %s\n",
+
+ elf_errmsg (elf_errno ()));
+
+ return 1;
+ }
+ break;
+ }
+ }
+
+ if (shdr == NULL)
+ {
+ fprintf (stderr, "Unable to find the section header\n");
+ return 1;
+ }
+
+ data = elf_getdata (scn, NULL);
+
+ if (data == NULL)
+ {
+ fprintf (stderr, "Unable to get the dynamic section data: %s\n",
+ elf_errmsg (elf_errno ()));
+
+ return 1;
+ }
+
+ trace ("data=%p\n", data);
+
+ sh_entsize = gelf_fsize (elf, ELF_T_DYN, 1, EV_CURRENT);
+ trace ("sh_entsize=%zu\n", sh_entsize);
+
+ for (i = 0; i < shdr->sh_size / sh_entsize; i++)
+ {
+ GElf_Dyn dyn_mem;
+ GElf_Dyn *dyn = gelf_getdyn (data, i, &dyn_mem);
+
+ if (dyn == NULL)
+ break;
+
+ if (dyn->d_tag == DT_NEEDED)
+ printf ("%s\n", elf_strptr (elf, shdr->sh_link, dyn->d_un.d_ptr));
+ }
+
+ elf_end (elf);
+ close (fd);
+ return 0;
+}
diff --git a/srcpkgs/gobject-introspection/files/g-ir-scanner-lddwrapper b/srcpkgs/gobject-introspection/files/g-ir-scanner-lddwrapper
deleted file mode 100755
index b969836b66422a..00000000000000
--- a/srcpkgs/gobject-introspection/files/g-ir-scanner-lddwrapper
+++ /dev/null
@@ -1,2 +0,0 @@
-#!/bin/sh
-/usr/bin/prelink-rtld --root=${XBPS_CROSS_BASE} "$@"
diff --git a/srcpkgs/gobject-introspection/patches/0006-giscanner-ignore-error-return-codes-from-ldd-wrapper.patch b/srcpkgs/gobject-introspection/patches/0006-giscanner-ignore-error-return-codes-from-ldd-wrapper.patch
deleted file mode 100644
index 9167f042e5b4e4..00000000000000
--- a/srcpkgs/gobject-introspection/patches/0006-giscanner-ignore-error-return-codes-from-ldd-wrapper.patch
+++ /dev/null
@@ -1,27 +0,0 @@
-From f128cbeead687bfc6532cc1f2cc3e2dc5a2b5b30 Mon Sep 17 00:00:00 2001
-From: Alexander Kanavin <alex.kanavin@gmail.com>
-Date: Wed, 5 Sep 2018 16:46:52 +0200
-Subject: [PATCH] giscanner: ignore error return codes from ldd-wrapper
-
-prelink-rtld, which we use instead of ldd returns 127 when it can't find a library.
-It is not an error per se, but it breaks subprocess.check_output().
-
-Upstream-Status: Inappropriate [oe-core specific]
-Signed-off-by: Alexander Kanavin <alex.kanavin@gmail.com>
----
- giscanner/shlibs.py | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/giscanner/shlibs.py b/giscanner/shlibs.py
-index 01d21a3..3bd3250 100644
---- a/giscanner/shlibs.py
-+++ b/giscanner/shlibs.py
-@@ -108,7 +108,7 @@ def _resolve_non_libtool(options, binary, libraries):
- args.extend(['otool', '-L', binary.args[0]])
- else:
- args.extend(['ldd', binary.args[0]])
-- output = subprocess.check_output(args)
-+ output = subprocess.run(args, check=False, stdout=subprocess.PIPE).stdout
- if isinstance(output, bytes):
- output = output.decode("utf-8", "replace")
-
diff --git a/srcpkgs/gobject-introspection/patches/fb6f33082a42202c55dc3d5cbc984cc9b6b01629.patch b/srcpkgs/gobject-introspection/patches/fb6f33082a42202c55dc3d5cbc984cc9b6b01629.patch
new file mode 100644
index 00000000000000..0b32d8dcfa4d29
--- /dev/null
+++ b/srcpkgs/gobject-introspection/patches/fb6f33082a42202c55dc3d5cbc984cc9b6b01629.patch
@@ -0,0 +1,73 @@
+From fb6f33082a42202c55dc3d5cbc984cc9b6b01629 Mon Sep 17 00:00:00 2001
+From: Emmanuele Bassi <ebassi@gnome.org>
+Date: Mon, 25 Dec 2023 00:06:53 +0000
+Subject: [PATCH] tests: Do not use PYTHONPATH to import giscanner
+
+The PYTHONPATH environment variable will prepend its contents to
+sys.path; since giscanner contains an ast sub-module, we are going to
+cause a collision with Python's own ast module. In some cases, Python
+3.12's distutils compatibility shim will try to import Python's ast,
+which will end up trying to import giscanner.ast instead.
+
+Instead of prepending the giscanner build directory, we can append it,
+and keep the current project layout.
+
+See: #429
+---
+ tests/scanner/meson.build | 2 +-
+ tests/warn/meson.build | 5 +----
+ tests/warn/warningtester.py | 9 +++++++++
+ 3 files changed, 11 insertions(+), 5 deletions(-)
+
+diff --git a/tests/scanner/meson.build b/tests/scanner/meson.build
+index e77c2de03..c92ce6474 100644
+--- a/tests/scanner/meson.build
++++ b/tests/scanner/meson.build
+@@ -1,7 +1,7 @@
+ scanner_test_env = environment()
+ scanner_test_env.prepend('PYTHONPATH', test_env_common_pypath)
+ if test_env_common_path.length() > 0
+- scanner_test_env.prepend('PATH', test_env_common_path)
++ scanner_test_env.prepend('PATH', test_env_common_path)
+ endif
+
+ scanner_test_files = [
+diff --git a/tests/warn/meson.build b/tests/warn/meson.build
+index 9641787f7..c57268081 100644
+--- a/tests/warn/meson.build
++++ b/tests/warn/meson.build
+@@ -23,10 +23,7 @@ warn_tests = [
+ warn_test_env = environment()
+ warn_test_env.set('UNINSTALLED_INTROSPECTION_SRCDIR', source_root)
+ warn_test_env.set('TOP_BUILDDIR', build_root)
+-warn_test_env.set(
+- 'PYTHONPATH',
+- build_root,
+- join_paths(build_root, 'giscanner'))
++warn_test_env.set('GISCANNER_DIR', build_root, build_root / 'giscanner')
+
+ # FIXME: Glib as a subproject (used on Windows mostly).
+ if glib_dep.type_name() == 'pkgconfig'
+diff --git a/tests/warn/warningtester.py b/tests/warn/warningtester.py
+index acb271f23..cce2827b1 100644
+--- a/tests/warn/warningtester.py
++++ b/tests/warn/warningtester.py
+@@ -11,6 +11,15 @@ sys.path.insert(0, path)
+ builtins.__dict__['DATADIR'] = path
+ builtins.__dict__['GIR_DIR'] = path
+
++# We cannot use PYTHONPATH, because it would prepend the giscanner
++# root, and we have an "ast" module that conflicts with Python's
++# own ast. In some cases, Python's distutils ends up importing ast,
++# and that will end up trying to import giscanner.ast
++path = os.getenv('GISCANNER_DIR', None)
++assert path is not None
++for p in path.split(os.pathsep):
++ sys.path.append(p)
++
+ from giscanner.annotationparser import GtkDocCommentBlockParser
+ from giscanner.ast import Include, Namespace
+ from giscanner.introspectablepass import IntrospectablePass
+--
+GitLab
+
diff --git a/srcpkgs/gobject-introspection/template b/srcpkgs/gobject-introspection/template
index 356646ced3117f..ed284572fc3f45 100644
--- a/srcpkgs/gobject-introspection/template
+++ b/srcpkgs/gobject-introspection/template
@@ -1,13 +1,13 @@
# Template file for 'gobject-introspection'
pkgname=gobject-introspection
version=1.76.1
-revision=3
+revision=4
build_style=meson
pycompile_dirs="usr/lib/${pkgname}/giscanner"
hostmakedepends="flex pkg-config"
# won't run tests with cairo to avoid cyclical deps
-makedepends="libffi-devel libglib-devel python3-devel python3-Mako
- python3-Markdown"
+makedepends="libffi-devel libglib-devel python3-devel elfutils-devel
+ python3-Mako python3-Markdown"
depends="libgirepository-devel python3-Mako python3-Markdown python3-setuptools"
short_desc="Introspection system for GObject-based libraries"
maintainer="Enno Boland <gottox@voidlinux.org>"
@@ -18,20 +18,24 @@ checksum=196178bf64345501dcdc4d8469b36aa6fe80489354efe71cb7cb8ab82a3738bf
python_version=3
if [ "$CROSS_BUILD" ]; then
- hostmakedepends+=" gobject-introspection qemu-user-static prelink-cross"
+ hostmakedepends+=" gobject-introspection qemu-user-static"
configure_args+=" -Dgi_cross_use_prebuilt_gi=true
-Dgi_cross_binary_wrapper=/usr/bin/g-ir-scanner-qemuwrapper
-Dgi_cross_ldd_wrapper=/usr/bin/g-ir-scanner-lddwrapper
-Dgi_cross_pkgconfig_sysroot_path=${XBPS_CROSS_BASE}"
fi
+post_build() {
+ $CC $CFLAGS $LDFLAGS ${FILESDIR}/elf-get-needed.c -lelf -o elf-get-needed
+}
+
post_install() {
rm ${DESTDIR}/usr/lib/gobject-introspection/giscanner/doctemplates/*/meson.build
# Install our wrappers system-wide, they are required for building all other
# gobject-based packages.
vbin ${FILESDIR}/g-ir-scanner-qemuwrapper
- vbin ${FILESDIR}/g-ir-scanner-lddwrapper
+ vbin elf-get-needed g-ir-scanner-lddwrapper
# Install g-ir-scanner-wrapper as g-ir-scanner, we need it with that name since
# we can't expect people to just not hardcode /usr/bin/g-ir-scanner, some packages
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PR PATCH] [Updated] [RFC] gobject-introspection: use elfutils lldwraper instead of prelink-cross
2024-03-22 23:56 [PR PATCH] [RFC] gobject-introspection: used elfutils lldwraper instead of prelink-cross oreo639
2024-03-22 23:57 ` [PR PATCH] [Updated] " oreo639
2024-03-23 0:06 ` [PR PATCH] [Updated] [RFC] gobject-introspection: use " oreo639
@ 2024-03-24 9:06 ` oreo639
2024-04-10 7:06 ` [PR PATCH] [Updated] [RFC] gobject-introspection: use elfutils lddwraper " oreo639
` (7 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: oreo639 @ 2024-03-24 9:06 UTC (permalink / raw)
To: ml
[-- Attachment #1: Type: text/plain, Size: 1608 bytes --]
There is an updated pull request by oreo639 against master on the void-packages repository
https://github.com/oreo639/void-packages gi-cross
https://github.com/void-linux/void-packages/pull/49468
[RFC] gobject-introspection: use elfutils lldwraper instead of prelink-cross
Replace lldwraper with one maintained by Debian using elfutils. elfutils is already a dependency of glib.
https://salsa.debian.org/gnome-team/gobject-introspection/-/blob/debian/latest/debian/elf-get-needed.c
https://gitlab.gnome.org/GNOME/gobject-introspection/-/issues/482
This needs more testing.
<!-- Uncomment relevant sections and delete options which are not applicable -->
#### Testing the changes
- I tested the changes in this PR: **briefly**
<!--
#### New package
- This new package conforms to the [package requirements](https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#package-requirements): **YES**|**NO**
-->
<!-- Note: If the build is likely to take more than 2 hours, please add ci skip tag as described in
https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#continuous-integration
and test at least one native build and, if supported, at least one cross build.
Ignore this section if this PR is not skipping CI.
-->
<!--
#### Local build testing
- I built this PR locally for my native architecture, (ARCH-LIBC)
- I built this PR locally for these architectures (if supported. mark crossbuilds):
- aarch64-musl
- armv7l
- armv6l-musl
-->
A patch file from https://github.com/void-linux/void-packages/pull/49468.patch is attached
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-gi-cross-49468.patch --]
[-- Type: text/x-diff, Size: 13068 bytes --]
From ddbdbb445e6e98a8bdc3727bdc8b7e8cf1e6233b Mon Sep 17 00:00:00 2001
From: oreo639 <oreo6391@gmail.com>
Date: Fri, 22 Mar 2024 16:47:54 -0700
Subject: [PATCH] gobject-introspection: use elfutils lldwraper instead of
prelink-cross
Replace lldwraper with one maintained by Debian using elfutils.
elfutils is already a dependency of glib.
https://salsa.debian.org/gnome-team/gobject-introspection/-/blob/debian/latest/debian/elf-get-needed.c
https://gitlab.gnome.org/GNOME/gobject-introspection/-/issues/482
---
.../files/elf-get-needed.c | 156 ++++++++++++++++++
.../files/g-ir-scanner-lddwrapper | 2 -
.../files/g-ir-scanner-wrapper | 2 +-
...-error-return-codes-from-ldd-wrapper.patch | 27 ---
...33082a42202c55dc3d5cbc984cc9b6b01629.patch | 73 ++++++++
srcpkgs/gobject-introspection/template | 14 +-
6 files changed, 239 insertions(+), 35 deletions(-)
create mode 100644 srcpkgs/gobject-introspection/files/elf-get-needed.c
delete mode 100755 srcpkgs/gobject-introspection/files/g-ir-scanner-lddwrapper
delete mode 100644 srcpkgs/gobject-introspection/patches/0006-giscanner-ignore-error-return-codes-from-ldd-wrapper.patch
create mode 100644 srcpkgs/gobject-introspection/patches/fb6f33082a42202c55dc3d5cbc984cc9b6b01629.patch
diff --git a/srcpkgs/gobject-introspection/files/elf-get-needed.c b/srcpkgs/gobject-introspection/files/elf-get-needed.c
new file mode 100644
index 00000000000000..be78f3bdf2a925
--- /dev/null
+++ b/srcpkgs/gobject-introspection/files/elf-get-needed.c
@@ -0,0 +1,156 @@
+/*
+ * Copyright © 2019-2023 Collabora Ltd.
+ * SPDX-License-Identifier: MIT
+ *
+ * Use libelf to parse ELF headers for DT_NEEDED, and fake the output
+ * format of ldd closely enough that GObject-Introspection can parse it.
+ *
+ * Limitations when compared with real ldd:
+ * - Only direct dependencies are output: unlike ldd, this is not recursive.
+ * For GObject-Introspection this is what we ideally want anyway.
+ * - Only bare SONAMEs are output, no paths or other extraneous information.
+ *
+ * https://salsa.debian.org/gnome-team/gobject-introspection/-/blob/debian/latest/debian/elf-get-needed.c
+ * https://gitlab.gnome.org/GNOME/gobject-introspection/-/issues/482
+ */
+
+#include <fcntl.h>
+#include <stddef.h>
+#include <stdio.h>
+#include <unistd.h>
+
+#include <elf.h>
+#include <gelf.h>
+
+#if 0
+#define trace(...) fprintf(stderr, __VA_ARGS__)
+#else
+#define trace(...) do {} while (0)
+#endif
+
+int
+main (int argc,
+ char **argv)
+{
+ const char *library;
+ Elf *elf = NULL;
+ Elf_Scn *scn = NULL;
+ GElf_Shdr shdr_mem;
+ GElf_Shdr *shdr = NULL;
+ size_t phnum;
+ size_t i;
+ Elf_Data *data;
+ uintptr_t needed_offset = (uintptr_t) -1;
+ const char *needed;
+ size_t sh_entsize;
+ int fd;
+
+ if (argc != 2)
+ {
+ fprintf (stderr, "Usage: %s LIBRARY\n", argv[0]);
+ return 2;
+ }
+
+ library = argv[1];
+
+ if (elf_version (EV_CURRENT) == EV_NONE)
+ {
+ perror ("elf_version(EV_CURRENT)");
+ return 1;
+ }
+
+ if ((fd = open (library, O_RDONLY | O_CLOEXEC, 0)) < 0)
+ {
+ perror (library);
+ return 1;
+ }
+
+ if ((elf = elf_begin (fd, ELF_C_READ, NULL)) == NULL)
+ {
+ fprintf (stderr, "Error reading library %s: %s",
+ library, elf_errmsg (elf_errno ()));
+ return 1;
+ }
+
+ if (elf_getphdrnum (elf, &phnum) < 0)
+ {
+
+ fprintf (stderr, "Unable to determine the number of program headers: %s\n",
+ elf_errmsg (elf_errno ()));
+
+ return 1;
+ }
+
+ trace ("phnum=%zu\n", phnum);
+
+ for (i = 0; i < phnum; i++)
+ {
+ GElf_Phdr phdr_mem;
+ GElf_Phdr *phdr = gelf_getphdr (elf, i, &phdr_mem);
+
+ if (phdr != NULL && phdr->p_type == PT_DYNAMIC)
+ {
+ scn = gelf_offscn (elf, phdr->p_offset);
+ trace ("scn=%p\n", scn);
+
+ if (scn == NULL)
+ {
+ fprintf (stderr, "Unable to get the section: %s\n",
+
+ elf_errmsg (elf_errno ()));
+
+ return 1;
+ }
+
+ shdr = gelf_getshdr (scn, &shdr_mem);
+ trace ("shdr=%p, shdr_mem=%p\n", shdr, &shdr_mem);
+
+ if (shdr == NULL)
+ {
+ fprintf (stderr, "Unable to get the section header: %s\n",
+
+ elf_errmsg (elf_errno ()));
+
+ return 1;
+ }
+ break;
+ }
+ }
+
+ if (shdr == NULL)
+ {
+ fprintf (stderr, "Unable to find the section header\n");
+ return 1;
+ }
+
+ data = elf_getdata (scn, NULL);
+
+ if (data == NULL)
+ {
+ fprintf (stderr, "Unable to get the dynamic section data: %s\n",
+ elf_errmsg (elf_errno ()));
+
+ return 1;
+ }
+
+ trace ("data=%p\n", data);
+
+ sh_entsize = gelf_fsize (elf, ELF_T_DYN, 1, EV_CURRENT);
+ trace ("sh_entsize=%zu\n", sh_entsize);
+
+ for (i = 0; i < shdr->sh_size / sh_entsize; i++)
+ {
+ GElf_Dyn dyn_mem;
+ GElf_Dyn *dyn = gelf_getdyn (data, i, &dyn_mem);
+
+ if (dyn == NULL)
+ break;
+
+ if (dyn->d_tag == DT_NEEDED)
+ printf ("%s\n", elf_strptr (elf, shdr->sh_link, dyn->d_un.d_ptr));
+ }
+
+ elf_end (elf);
+ close (fd);
+ return 0;
+}
diff --git a/srcpkgs/gobject-introspection/files/g-ir-scanner-lddwrapper b/srcpkgs/gobject-introspection/files/g-ir-scanner-lddwrapper
deleted file mode 100755
index b969836b66422a..00000000000000
--- a/srcpkgs/gobject-introspection/files/g-ir-scanner-lddwrapper
+++ /dev/null
@@ -1,2 +0,0 @@
-#!/bin/sh
-/usr/bin/prelink-rtld --root=${XBPS_CROSS_BASE} "$@"
diff --git a/srcpkgs/gobject-introspection/files/g-ir-scanner-wrapper b/srcpkgs/gobject-introspection/files/g-ir-scanner-wrapper
index d5c426d3cc2e2b..23a66d03655490 100755
--- a/srcpkgs/gobject-introspection/files/g-ir-scanner-wrapper
+++ b/srcpkgs/gobject-introspection/files/g-ir-scanner-wrapper
@@ -15,4 +15,4 @@ if [ -n "$XBPS_CROSS_BASE" -a -n "$XBPS_TARGET_MACHINE" -a -n "$XBPS_VERSION" ];
"${@//-I\/usr\/include/-I${XBPS_CROSS_BASE}\/usr\/include}"
fi
-exec /usr/bin/g-ir-scanner.wrapped "$@"
+exec /usr/bin/g-ir-scanner.wrapped --use-ldd-wrapper=/usr/bin/g-ir-scanner-lddwrapper "$@"
diff --git a/srcpkgs/gobject-introspection/patches/0006-giscanner-ignore-error-return-codes-from-ldd-wrapper.patch b/srcpkgs/gobject-introspection/patches/0006-giscanner-ignore-error-return-codes-from-ldd-wrapper.patch
deleted file mode 100644
index 9167f042e5b4e4..00000000000000
--- a/srcpkgs/gobject-introspection/patches/0006-giscanner-ignore-error-return-codes-from-ldd-wrapper.patch
+++ /dev/null
@@ -1,27 +0,0 @@
-From f128cbeead687bfc6532cc1f2cc3e2dc5a2b5b30 Mon Sep 17 00:00:00 2001
-From: Alexander Kanavin <alex.kanavin@gmail.com>
-Date: Wed, 5 Sep 2018 16:46:52 +0200
-Subject: [PATCH] giscanner: ignore error return codes from ldd-wrapper
-
-prelink-rtld, which we use instead of ldd returns 127 when it can't find a library.
-It is not an error per se, but it breaks subprocess.check_output().
-
-Upstream-Status: Inappropriate [oe-core specific]
-Signed-off-by: Alexander Kanavin <alex.kanavin@gmail.com>
----
- giscanner/shlibs.py | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/giscanner/shlibs.py b/giscanner/shlibs.py
-index 01d21a3..3bd3250 100644
---- a/giscanner/shlibs.py
-+++ b/giscanner/shlibs.py
-@@ -108,7 +108,7 @@ def _resolve_non_libtool(options, binary, libraries):
- args.extend(['otool', '-L', binary.args[0]])
- else:
- args.extend(['ldd', binary.args[0]])
-- output = subprocess.check_output(args)
-+ output = subprocess.run(args, check=False, stdout=subprocess.PIPE).stdout
- if isinstance(output, bytes):
- output = output.decode("utf-8", "replace")
-
diff --git a/srcpkgs/gobject-introspection/patches/fb6f33082a42202c55dc3d5cbc984cc9b6b01629.patch b/srcpkgs/gobject-introspection/patches/fb6f33082a42202c55dc3d5cbc984cc9b6b01629.patch
new file mode 100644
index 00000000000000..0b32d8dcfa4d29
--- /dev/null
+++ b/srcpkgs/gobject-introspection/patches/fb6f33082a42202c55dc3d5cbc984cc9b6b01629.patch
@@ -0,0 +1,73 @@
+From fb6f33082a42202c55dc3d5cbc984cc9b6b01629 Mon Sep 17 00:00:00 2001
+From: Emmanuele Bassi <ebassi@gnome.org>
+Date: Mon, 25 Dec 2023 00:06:53 +0000
+Subject: [PATCH] tests: Do not use PYTHONPATH to import giscanner
+
+The PYTHONPATH environment variable will prepend its contents to
+sys.path; since giscanner contains an ast sub-module, we are going to
+cause a collision with Python's own ast module. In some cases, Python
+3.12's distutils compatibility shim will try to import Python's ast,
+which will end up trying to import giscanner.ast instead.
+
+Instead of prepending the giscanner build directory, we can append it,
+and keep the current project layout.
+
+See: #429
+---
+ tests/scanner/meson.build | 2 +-
+ tests/warn/meson.build | 5 +----
+ tests/warn/warningtester.py | 9 +++++++++
+ 3 files changed, 11 insertions(+), 5 deletions(-)
+
+diff --git a/tests/scanner/meson.build b/tests/scanner/meson.build
+index e77c2de03..c92ce6474 100644
+--- a/tests/scanner/meson.build
++++ b/tests/scanner/meson.build
+@@ -1,7 +1,7 @@
+ scanner_test_env = environment()
+ scanner_test_env.prepend('PYTHONPATH', test_env_common_pypath)
+ if test_env_common_path.length() > 0
+- scanner_test_env.prepend('PATH', test_env_common_path)
++ scanner_test_env.prepend('PATH', test_env_common_path)
+ endif
+
+ scanner_test_files = [
+diff --git a/tests/warn/meson.build b/tests/warn/meson.build
+index 9641787f7..c57268081 100644
+--- a/tests/warn/meson.build
++++ b/tests/warn/meson.build
+@@ -23,10 +23,7 @@ warn_tests = [
+ warn_test_env = environment()
+ warn_test_env.set('UNINSTALLED_INTROSPECTION_SRCDIR', source_root)
+ warn_test_env.set('TOP_BUILDDIR', build_root)
+-warn_test_env.set(
+- 'PYTHONPATH',
+- build_root,
+- join_paths(build_root, 'giscanner'))
++warn_test_env.set('GISCANNER_DIR', build_root, build_root / 'giscanner')
+
+ # FIXME: Glib as a subproject (used on Windows mostly).
+ if glib_dep.type_name() == 'pkgconfig'
+diff --git a/tests/warn/warningtester.py b/tests/warn/warningtester.py
+index acb271f23..cce2827b1 100644
+--- a/tests/warn/warningtester.py
++++ b/tests/warn/warningtester.py
+@@ -11,6 +11,15 @@ sys.path.insert(0, path)
+ builtins.__dict__['DATADIR'] = path
+ builtins.__dict__['GIR_DIR'] = path
+
++# We cannot use PYTHONPATH, because it would prepend the giscanner
++# root, and we have an "ast" module that conflicts with Python's
++# own ast. In some cases, Python's distutils ends up importing ast,
++# and that will end up trying to import giscanner.ast
++path = os.getenv('GISCANNER_DIR', None)
++assert path is not None
++for p in path.split(os.pathsep):
++ sys.path.append(p)
++
+ from giscanner.annotationparser import GtkDocCommentBlockParser
+ from giscanner.ast import Include, Namespace
+ from giscanner.introspectablepass import IntrospectablePass
+--
+GitLab
+
diff --git a/srcpkgs/gobject-introspection/template b/srcpkgs/gobject-introspection/template
index 356646ced3117f..ed284572fc3f45 100644
--- a/srcpkgs/gobject-introspection/template
+++ b/srcpkgs/gobject-introspection/template
@@ -1,13 +1,13 @@
# Template file for 'gobject-introspection'
pkgname=gobject-introspection
version=1.76.1
-revision=3
+revision=4
build_style=meson
pycompile_dirs="usr/lib/${pkgname}/giscanner"
hostmakedepends="flex pkg-config"
# won't run tests with cairo to avoid cyclical deps
-makedepends="libffi-devel libglib-devel python3-devel python3-Mako
- python3-Markdown"
+makedepends="libffi-devel libglib-devel python3-devel elfutils-devel
+ python3-Mako python3-Markdown"
depends="libgirepository-devel python3-Mako python3-Markdown python3-setuptools"
short_desc="Introspection system for GObject-based libraries"
maintainer="Enno Boland <gottox@voidlinux.org>"
@@ -18,20 +18,24 @@ checksum=196178bf64345501dcdc4d8469b36aa6fe80489354efe71cb7cb8ab82a3738bf
python_version=3
if [ "$CROSS_BUILD" ]; then
- hostmakedepends+=" gobject-introspection qemu-user-static prelink-cross"
+ hostmakedepends+=" gobject-introspection qemu-user-static"
configure_args+=" -Dgi_cross_use_prebuilt_gi=true
-Dgi_cross_binary_wrapper=/usr/bin/g-ir-scanner-qemuwrapper
-Dgi_cross_ldd_wrapper=/usr/bin/g-ir-scanner-lddwrapper
-Dgi_cross_pkgconfig_sysroot_path=${XBPS_CROSS_BASE}"
fi
+post_build() {
+ $CC $CFLAGS $LDFLAGS ${FILESDIR}/elf-get-needed.c -lelf -o elf-get-needed
+}
+
post_install() {
rm ${DESTDIR}/usr/lib/gobject-introspection/giscanner/doctemplates/*/meson.build
# Install our wrappers system-wide, they are required for building all other
# gobject-based packages.
vbin ${FILESDIR}/g-ir-scanner-qemuwrapper
- vbin ${FILESDIR}/g-ir-scanner-lddwrapper
+ vbin elf-get-needed g-ir-scanner-lddwrapper
# Install g-ir-scanner-wrapper as g-ir-scanner, we need it with that name since
# we can't expect people to just not hardcode /usr/bin/g-ir-scanner, some packages
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PR PATCH] [Updated] [RFC] gobject-introspection: use elfutils lddwraper instead of prelink-cross
2024-03-22 23:56 [PR PATCH] [RFC] gobject-introspection: used elfutils lldwraper instead of prelink-cross oreo639
` (2 preceding siblings ...)
2024-03-24 9:06 ` oreo639
@ 2024-04-10 7:06 ` oreo639
2024-04-16 9:17 ` oreo639
` (6 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: oreo639 @ 2024-04-10 7:06 UTC (permalink / raw)
To: ml
[-- Attachment #1: Type: text/plain, Size: 1608 bytes --]
There is an updated pull request by oreo639 against master on the void-packages repository
https://github.com/oreo639/void-packages gi-cross
https://github.com/void-linux/void-packages/pull/49468
[RFC] gobject-introspection: use elfutils lddwraper instead of prelink-cross
Replace lddwraper with one maintained by Debian using elfutils. elfutils is already a dependency of glib.
https://salsa.debian.org/gnome-team/gobject-introspection/-/blob/debian/latest/debian/elf-get-needed.c
https://gitlab.gnome.org/GNOME/gobject-introspection/-/issues/482
This needs more testing.
<!-- Uncomment relevant sections and delete options which are not applicable -->
#### Testing the changes
- I tested the changes in this PR: **briefly**
<!--
#### New package
- This new package conforms to the [package requirements](https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#package-requirements): **YES**|**NO**
-->
<!-- Note: If the build is likely to take more than 2 hours, please add ci skip tag as described in
https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#continuous-integration
and test at least one native build and, if supported, at least one cross build.
Ignore this section if this PR is not skipping CI.
-->
<!--
#### Local build testing
- I built this PR locally for my native architecture, (ARCH-LIBC)
- I built this PR locally for these architectures (if supported. mark crossbuilds):
- aarch64-musl
- armv7l
- armv6l-musl
-->
A patch file from https://github.com/void-linux/void-packages/pull/49468.patch is attached
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-gi-cross-49468.patch --]
[-- Type: text/x-diff, Size: 13140 bytes --]
From 234dea4394e6fb6e2fbdd2a66e7e2f560b15f829 Mon Sep 17 00:00:00 2001
From: oreo639 <oreo6391@gmail.com>
Date: Fri, 22 Mar 2024 16:47:54 -0700
Subject: [PATCH] gobject-introspection: use elfutils lldwraper instead of
prelink-cross
Replace lldwraper with one maintained by Debian using elfutils.
elfutils is already a dependency of glib.
Also, always use this lldwrapper by default for both native and cross.
https://salsa.debian.org/gnome-team/gobject-introspection/-/blob/debian/latest/debian/elf-get-needed.c
https://gitlab.gnome.org/GNOME/gobject-introspection/-/issues/482
---
.../files/elf-get-needed.c | 156 ++++++++++++++++++
.../files/g-ir-scanner-lddwrapper | 2 -
.../files/g-ir-scanner-wrapper | 2 +-
...-error-return-codes-from-ldd-wrapper.patch | 27 ---
...33082a42202c55dc3d5cbc984cc9b6b01629.patch | 73 ++++++++
srcpkgs/gobject-introspection/template | 14 +-
6 files changed, 239 insertions(+), 35 deletions(-)
create mode 100644 srcpkgs/gobject-introspection/files/elf-get-needed.c
delete mode 100755 srcpkgs/gobject-introspection/files/g-ir-scanner-lddwrapper
delete mode 100644 srcpkgs/gobject-introspection/patches/0006-giscanner-ignore-error-return-codes-from-ldd-wrapper.patch
create mode 100644 srcpkgs/gobject-introspection/patches/fb6f33082a42202c55dc3d5cbc984cc9b6b01629.patch
diff --git a/srcpkgs/gobject-introspection/files/elf-get-needed.c b/srcpkgs/gobject-introspection/files/elf-get-needed.c
new file mode 100644
index 00000000000000..be78f3bdf2a925
--- /dev/null
+++ b/srcpkgs/gobject-introspection/files/elf-get-needed.c
@@ -0,0 +1,156 @@
+/*
+ * Copyright © 2019-2023 Collabora Ltd.
+ * SPDX-License-Identifier: MIT
+ *
+ * Use libelf to parse ELF headers for DT_NEEDED, and fake the output
+ * format of ldd closely enough that GObject-Introspection can parse it.
+ *
+ * Limitations when compared with real ldd:
+ * - Only direct dependencies are output: unlike ldd, this is not recursive.
+ * For GObject-Introspection this is what we ideally want anyway.
+ * - Only bare SONAMEs are output, no paths or other extraneous information.
+ *
+ * https://salsa.debian.org/gnome-team/gobject-introspection/-/blob/debian/latest/debian/elf-get-needed.c
+ * https://gitlab.gnome.org/GNOME/gobject-introspection/-/issues/482
+ */
+
+#include <fcntl.h>
+#include <stddef.h>
+#include <stdio.h>
+#include <unistd.h>
+
+#include <elf.h>
+#include <gelf.h>
+
+#if 0
+#define trace(...) fprintf(stderr, __VA_ARGS__)
+#else
+#define trace(...) do {} while (0)
+#endif
+
+int
+main (int argc,
+ char **argv)
+{
+ const char *library;
+ Elf *elf = NULL;
+ Elf_Scn *scn = NULL;
+ GElf_Shdr shdr_mem;
+ GElf_Shdr *shdr = NULL;
+ size_t phnum;
+ size_t i;
+ Elf_Data *data;
+ uintptr_t needed_offset = (uintptr_t) -1;
+ const char *needed;
+ size_t sh_entsize;
+ int fd;
+
+ if (argc != 2)
+ {
+ fprintf (stderr, "Usage: %s LIBRARY\n", argv[0]);
+ return 2;
+ }
+
+ library = argv[1];
+
+ if (elf_version (EV_CURRENT) == EV_NONE)
+ {
+ perror ("elf_version(EV_CURRENT)");
+ return 1;
+ }
+
+ if ((fd = open (library, O_RDONLY | O_CLOEXEC, 0)) < 0)
+ {
+ perror (library);
+ return 1;
+ }
+
+ if ((elf = elf_begin (fd, ELF_C_READ, NULL)) == NULL)
+ {
+ fprintf (stderr, "Error reading library %s: %s",
+ library, elf_errmsg (elf_errno ()));
+ return 1;
+ }
+
+ if (elf_getphdrnum (elf, &phnum) < 0)
+ {
+
+ fprintf (stderr, "Unable to determine the number of program headers: %s\n",
+ elf_errmsg (elf_errno ()));
+
+ return 1;
+ }
+
+ trace ("phnum=%zu\n", phnum);
+
+ for (i = 0; i < phnum; i++)
+ {
+ GElf_Phdr phdr_mem;
+ GElf_Phdr *phdr = gelf_getphdr (elf, i, &phdr_mem);
+
+ if (phdr != NULL && phdr->p_type == PT_DYNAMIC)
+ {
+ scn = gelf_offscn (elf, phdr->p_offset);
+ trace ("scn=%p\n", scn);
+
+ if (scn == NULL)
+ {
+ fprintf (stderr, "Unable to get the section: %s\n",
+
+ elf_errmsg (elf_errno ()));
+
+ return 1;
+ }
+
+ shdr = gelf_getshdr (scn, &shdr_mem);
+ trace ("shdr=%p, shdr_mem=%p\n", shdr, &shdr_mem);
+
+ if (shdr == NULL)
+ {
+ fprintf (stderr, "Unable to get the section header: %s\n",
+
+ elf_errmsg (elf_errno ()));
+
+ return 1;
+ }
+ break;
+ }
+ }
+
+ if (shdr == NULL)
+ {
+ fprintf (stderr, "Unable to find the section header\n");
+ return 1;
+ }
+
+ data = elf_getdata (scn, NULL);
+
+ if (data == NULL)
+ {
+ fprintf (stderr, "Unable to get the dynamic section data: %s\n",
+ elf_errmsg (elf_errno ()));
+
+ return 1;
+ }
+
+ trace ("data=%p\n", data);
+
+ sh_entsize = gelf_fsize (elf, ELF_T_DYN, 1, EV_CURRENT);
+ trace ("sh_entsize=%zu\n", sh_entsize);
+
+ for (i = 0; i < shdr->sh_size / sh_entsize; i++)
+ {
+ GElf_Dyn dyn_mem;
+ GElf_Dyn *dyn = gelf_getdyn (data, i, &dyn_mem);
+
+ if (dyn == NULL)
+ break;
+
+ if (dyn->d_tag == DT_NEEDED)
+ printf ("%s\n", elf_strptr (elf, shdr->sh_link, dyn->d_un.d_ptr));
+ }
+
+ elf_end (elf);
+ close (fd);
+ return 0;
+}
diff --git a/srcpkgs/gobject-introspection/files/g-ir-scanner-lddwrapper b/srcpkgs/gobject-introspection/files/g-ir-scanner-lddwrapper
deleted file mode 100755
index b969836b66422a..00000000000000
--- a/srcpkgs/gobject-introspection/files/g-ir-scanner-lddwrapper
+++ /dev/null
@@ -1,2 +0,0 @@
-#!/bin/sh
-/usr/bin/prelink-rtld --root=${XBPS_CROSS_BASE} "$@"
diff --git a/srcpkgs/gobject-introspection/files/g-ir-scanner-wrapper b/srcpkgs/gobject-introspection/files/g-ir-scanner-wrapper
index d5c426d3cc2e2b..23a66d03655490 100755
--- a/srcpkgs/gobject-introspection/files/g-ir-scanner-wrapper
+++ b/srcpkgs/gobject-introspection/files/g-ir-scanner-wrapper
@@ -15,4 +15,4 @@ if [ -n "$XBPS_CROSS_BASE" -a -n "$XBPS_TARGET_MACHINE" -a -n "$XBPS_VERSION" ];
"${@//-I\/usr\/include/-I${XBPS_CROSS_BASE}\/usr\/include}"
fi
-exec /usr/bin/g-ir-scanner.wrapped "$@"
+exec /usr/bin/g-ir-scanner.wrapped --use-ldd-wrapper=/usr/bin/g-ir-scanner-lddwrapper "$@"
diff --git a/srcpkgs/gobject-introspection/patches/0006-giscanner-ignore-error-return-codes-from-ldd-wrapper.patch b/srcpkgs/gobject-introspection/patches/0006-giscanner-ignore-error-return-codes-from-ldd-wrapper.patch
deleted file mode 100644
index 9167f042e5b4e4..00000000000000
--- a/srcpkgs/gobject-introspection/patches/0006-giscanner-ignore-error-return-codes-from-ldd-wrapper.patch
+++ /dev/null
@@ -1,27 +0,0 @@
-From f128cbeead687bfc6532cc1f2cc3e2dc5a2b5b30 Mon Sep 17 00:00:00 2001
-From: Alexander Kanavin <alex.kanavin@gmail.com>
-Date: Wed, 5 Sep 2018 16:46:52 +0200
-Subject: [PATCH] giscanner: ignore error return codes from ldd-wrapper
-
-prelink-rtld, which we use instead of ldd returns 127 when it can't find a library.
-It is not an error per se, but it breaks subprocess.check_output().
-
-Upstream-Status: Inappropriate [oe-core specific]
-Signed-off-by: Alexander Kanavin <alex.kanavin@gmail.com>
----
- giscanner/shlibs.py | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/giscanner/shlibs.py b/giscanner/shlibs.py
-index 01d21a3..3bd3250 100644
---- a/giscanner/shlibs.py
-+++ b/giscanner/shlibs.py
-@@ -108,7 +108,7 @@ def _resolve_non_libtool(options, binary, libraries):
- args.extend(['otool', '-L', binary.args[0]])
- else:
- args.extend(['ldd', binary.args[0]])
-- output = subprocess.check_output(args)
-+ output = subprocess.run(args, check=False, stdout=subprocess.PIPE).stdout
- if isinstance(output, bytes):
- output = output.decode("utf-8", "replace")
-
diff --git a/srcpkgs/gobject-introspection/patches/fb6f33082a42202c55dc3d5cbc984cc9b6b01629.patch b/srcpkgs/gobject-introspection/patches/fb6f33082a42202c55dc3d5cbc984cc9b6b01629.patch
new file mode 100644
index 00000000000000..0b32d8dcfa4d29
--- /dev/null
+++ b/srcpkgs/gobject-introspection/patches/fb6f33082a42202c55dc3d5cbc984cc9b6b01629.patch
@@ -0,0 +1,73 @@
+From fb6f33082a42202c55dc3d5cbc984cc9b6b01629 Mon Sep 17 00:00:00 2001
+From: Emmanuele Bassi <ebassi@gnome.org>
+Date: Mon, 25 Dec 2023 00:06:53 +0000
+Subject: [PATCH] tests: Do not use PYTHONPATH to import giscanner
+
+The PYTHONPATH environment variable will prepend its contents to
+sys.path; since giscanner contains an ast sub-module, we are going to
+cause a collision with Python's own ast module. In some cases, Python
+3.12's distutils compatibility shim will try to import Python's ast,
+which will end up trying to import giscanner.ast instead.
+
+Instead of prepending the giscanner build directory, we can append it,
+and keep the current project layout.
+
+See: #429
+---
+ tests/scanner/meson.build | 2 +-
+ tests/warn/meson.build | 5 +----
+ tests/warn/warningtester.py | 9 +++++++++
+ 3 files changed, 11 insertions(+), 5 deletions(-)
+
+diff --git a/tests/scanner/meson.build b/tests/scanner/meson.build
+index e77c2de03..c92ce6474 100644
+--- a/tests/scanner/meson.build
++++ b/tests/scanner/meson.build
+@@ -1,7 +1,7 @@
+ scanner_test_env = environment()
+ scanner_test_env.prepend('PYTHONPATH', test_env_common_pypath)
+ if test_env_common_path.length() > 0
+- scanner_test_env.prepend('PATH', test_env_common_path)
++ scanner_test_env.prepend('PATH', test_env_common_path)
+ endif
+
+ scanner_test_files = [
+diff --git a/tests/warn/meson.build b/tests/warn/meson.build
+index 9641787f7..c57268081 100644
+--- a/tests/warn/meson.build
++++ b/tests/warn/meson.build
+@@ -23,10 +23,7 @@ warn_tests = [
+ warn_test_env = environment()
+ warn_test_env.set('UNINSTALLED_INTROSPECTION_SRCDIR', source_root)
+ warn_test_env.set('TOP_BUILDDIR', build_root)
+-warn_test_env.set(
+- 'PYTHONPATH',
+- build_root,
+- join_paths(build_root, 'giscanner'))
++warn_test_env.set('GISCANNER_DIR', build_root, build_root / 'giscanner')
+
+ # FIXME: Glib as a subproject (used on Windows mostly).
+ if glib_dep.type_name() == 'pkgconfig'
+diff --git a/tests/warn/warningtester.py b/tests/warn/warningtester.py
+index acb271f23..cce2827b1 100644
+--- a/tests/warn/warningtester.py
++++ b/tests/warn/warningtester.py
+@@ -11,6 +11,15 @@ sys.path.insert(0, path)
+ builtins.__dict__['DATADIR'] = path
+ builtins.__dict__['GIR_DIR'] = path
+
++# We cannot use PYTHONPATH, because it would prepend the giscanner
++# root, and we have an "ast" module that conflicts with Python's
++# own ast. In some cases, Python's distutils ends up importing ast,
++# and that will end up trying to import giscanner.ast
++path = os.getenv('GISCANNER_DIR', None)
++assert path is not None
++for p in path.split(os.pathsep):
++ sys.path.append(p)
++
+ from giscanner.annotationparser import GtkDocCommentBlockParser
+ from giscanner.ast import Include, Namespace
+ from giscanner.introspectablepass import IntrospectablePass
+--
+GitLab
+
diff --git a/srcpkgs/gobject-introspection/template b/srcpkgs/gobject-introspection/template
index 356646ced3117f..ed284572fc3f45 100644
--- a/srcpkgs/gobject-introspection/template
+++ b/srcpkgs/gobject-introspection/template
@@ -1,13 +1,13 @@
# Template file for 'gobject-introspection'
pkgname=gobject-introspection
version=1.76.1
-revision=3
+revision=4
build_style=meson
pycompile_dirs="usr/lib/${pkgname}/giscanner"
hostmakedepends="flex pkg-config"
# won't run tests with cairo to avoid cyclical deps
-makedepends="libffi-devel libglib-devel python3-devel python3-Mako
- python3-Markdown"
+makedepends="libffi-devel libglib-devel python3-devel elfutils-devel
+ python3-Mako python3-Markdown"
depends="libgirepository-devel python3-Mako python3-Markdown python3-setuptools"
short_desc="Introspection system for GObject-based libraries"
maintainer="Enno Boland <gottox@voidlinux.org>"
@@ -18,20 +18,24 @@ checksum=196178bf64345501dcdc4d8469b36aa6fe80489354efe71cb7cb8ab82a3738bf
python_version=3
if [ "$CROSS_BUILD" ]; then
- hostmakedepends+=" gobject-introspection qemu-user-static prelink-cross"
+ hostmakedepends+=" gobject-introspection qemu-user-static"
configure_args+=" -Dgi_cross_use_prebuilt_gi=true
-Dgi_cross_binary_wrapper=/usr/bin/g-ir-scanner-qemuwrapper
-Dgi_cross_ldd_wrapper=/usr/bin/g-ir-scanner-lddwrapper
-Dgi_cross_pkgconfig_sysroot_path=${XBPS_CROSS_BASE}"
fi
+post_build() {
+ $CC $CFLAGS $LDFLAGS ${FILESDIR}/elf-get-needed.c -lelf -o elf-get-needed
+}
+
post_install() {
rm ${DESTDIR}/usr/lib/gobject-introspection/giscanner/doctemplates/*/meson.build
# Install our wrappers system-wide, they are required for building all other
# gobject-based packages.
vbin ${FILESDIR}/g-ir-scanner-qemuwrapper
- vbin ${FILESDIR}/g-ir-scanner-lddwrapper
+ vbin elf-get-needed g-ir-scanner-lddwrapper
# Install g-ir-scanner-wrapper as g-ir-scanner, we need it with that name since
# we can't expect people to just not hardcode /usr/bin/g-ir-scanner, some packages
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [RFC] gobject-introspection: use elfutils lddwraper instead of prelink-cross
2024-03-22 23:56 [PR PATCH] [RFC] gobject-introspection: used elfutils lldwraper instead of prelink-cross oreo639
` (3 preceding siblings ...)
2024-04-10 7:06 ` [PR PATCH] [Updated] [RFC] gobject-introspection: use elfutils lddwraper " oreo639
@ 2024-04-16 9:17 ` oreo639
2024-05-15 20:01 ` [PR PATCH] [Updated] " oreo639
` (5 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: oreo639 @ 2024-04-16 9:17 UTC (permalink / raw)
To: ml
[-- Attachment #1: Type: text/plain, Size: 393 bytes --]
New comment by oreo639 on void-packages repository
https://github.com/void-linux/void-packages/pull/49468#issuecomment-2058625975
Comment:
I re-marked this as a draft because after testing I realize that ldd was being used to resolve manually specified library names to their sonames (based on the ones pulled in by the executable).
This also breaks typelib generation for e.g. ibus-anthy.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PR PATCH] [Updated] [RFC] gobject-introspection: use elfutils lddwraper instead of prelink-cross
2024-03-22 23:56 [PR PATCH] [RFC] gobject-introspection: used elfutils lldwraper instead of prelink-cross oreo639
` (4 preceding siblings ...)
2024-04-16 9:17 ` oreo639
@ 2024-05-15 20:01 ` oreo639
2024-05-15 20:25 ` oreo639
` (4 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: oreo639 @ 2024-05-15 20:01 UTC (permalink / raw)
To: ml
[-- Attachment #1: Type: text/plain, Size: 1608 bytes --]
There is an updated pull request by oreo639 against master on the void-packages repository
https://github.com/oreo639/void-packages gi-cross
https://github.com/void-linux/void-packages/pull/49468
[RFC] gobject-introspection: use elfutils lddwraper instead of prelink-cross
Replace lddwraper with one maintained by Debian using elfutils. elfutils is already a dependency of glib.
https://salsa.debian.org/gnome-team/gobject-introspection/-/blob/debian/latest/debian/elf-get-needed.c
https://gitlab.gnome.org/GNOME/gobject-introspection/-/issues/482
This needs more testing.
<!-- Uncomment relevant sections and delete options which are not applicable -->
#### Testing the changes
- I tested the changes in this PR: **briefly**
<!--
#### New package
- This new package conforms to the [package requirements](https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#package-requirements): **YES**|**NO**
-->
<!-- Note: If the build is likely to take more than 2 hours, please add ci skip tag as described in
https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#continuous-integration
and test at least one native build and, if supported, at least one cross build.
Ignore this section if this PR is not skipping CI.
-->
<!--
#### Local build testing
- I built this PR locally for my native architecture, (ARCH-LIBC)
- I built this PR locally for these architectures (if supported. mark crossbuilds):
- aarch64-musl
- armv7l
- armv6l-musl
-->
A patch file from https://github.com/void-linux/void-packages/pull/49468.patch is attached
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-gi-cross-49468.patch --]
[-- Type: text/x-diff, Size: 14717 bytes --]
From 86796e33d0da347606784d06cbf7083a9c34e1ba Mon Sep 17 00:00:00 2001
From: oreo639 <oreo6391@gmail.com>
Date: Fri, 22 Mar 2024 16:47:54 -0700
Subject: [PATCH] gobject-introspection: use elfutils lldwraper instead of
prelink-cross
Replace lldwraper with one maintained by Debian using elfutils.
elfutils is already a dependency of glib.
Also, always use this lldwrapper by default for both native and cross.
https://salsa.debian.org/gnome-team/gobject-introspection/-/blob/debian/latest/debian/elf-get-needed.c
https://gitlab.gnome.org/GNOME/gobject-introspection/-/issues/482
---
.../files/elf-get-needed.c | 156 ++++++++++++++++++
.../files/g-ir-scanner-lddwrapper | 2 -
.../files/g-ir-scanner-wrapper | 2 +-
...-error-return-codes-from-ldd-wrapper.patch | 27 ---
...a6d482eab44da9d58b7eebf6dddc6cdf2912.patch | 108 ++++++++++++
srcpkgs/gobject-introspection/template | 14 +-
6 files changed, 274 insertions(+), 35 deletions(-)
create mode 100644 srcpkgs/gobject-introspection/files/elf-get-needed.c
delete mode 100755 srcpkgs/gobject-introspection/files/g-ir-scanner-lddwrapper
delete mode 100644 srcpkgs/gobject-introspection/patches/0006-giscanner-ignore-error-return-codes-from-ldd-wrapper.patch
create mode 100644 srcpkgs/gobject-introspection/patches/401ca6d482eab44da9d58b7eebf6dddc6cdf2912.patch
diff --git a/srcpkgs/gobject-introspection/files/elf-get-needed.c b/srcpkgs/gobject-introspection/files/elf-get-needed.c
new file mode 100644
index 00000000000000..be78f3bdf2a925
--- /dev/null
+++ b/srcpkgs/gobject-introspection/files/elf-get-needed.c
@@ -0,0 +1,156 @@
+/*
+ * Copyright © 2019-2023 Collabora Ltd.
+ * SPDX-License-Identifier: MIT
+ *
+ * Use libelf to parse ELF headers for DT_NEEDED, and fake the output
+ * format of ldd closely enough that GObject-Introspection can parse it.
+ *
+ * Limitations when compared with real ldd:
+ * - Only direct dependencies are output: unlike ldd, this is not recursive.
+ * For GObject-Introspection this is what we ideally want anyway.
+ * - Only bare SONAMEs are output, no paths or other extraneous information.
+ *
+ * https://salsa.debian.org/gnome-team/gobject-introspection/-/blob/debian/latest/debian/elf-get-needed.c
+ * https://gitlab.gnome.org/GNOME/gobject-introspection/-/issues/482
+ */
+
+#include <fcntl.h>
+#include <stddef.h>
+#include <stdio.h>
+#include <unistd.h>
+
+#include <elf.h>
+#include <gelf.h>
+
+#if 0
+#define trace(...) fprintf(stderr, __VA_ARGS__)
+#else
+#define trace(...) do {} while (0)
+#endif
+
+int
+main (int argc,
+ char **argv)
+{
+ const char *library;
+ Elf *elf = NULL;
+ Elf_Scn *scn = NULL;
+ GElf_Shdr shdr_mem;
+ GElf_Shdr *shdr = NULL;
+ size_t phnum;
+ size_t i;
+ Elf_Data *data;
+ uintptr_t needed_offset = (uintptr_t) -1;
+ const char *needed;
+ size_t sh_entsize;
+ int fd;
+
+ if (argc != 2)
+ {
+ fprintf (stderr, "Usage: %s LIBRARY\n", argv[0]);
+ return 2;
+ }
+
+ library = argv[1];
+
+ if (elf_version (EV_CURRENT) == EV_NONE)
+ {
+ perror ("elf_version(EV_CURRENT)");
+ return 1;
+ }
+
+ if ((fd = open (library, O_RDONLY | O_CLOEXEC, 0)) < 0)
+ {
+ perror (library);
+ return 1;
+ }
+
+ if ((elf = elf_begin (fd, ELF_C_READ, NULL)) == NULL)
+ {
+ fprintf (stderr, "Error reading library %s: %s",
+ library, elf_errmsg (elf_errno ()));
+ return 1;
+ }
+
+ if (elf_getphdrnum (elf, &phnum) < 0)
+ {
+
+ fprintf (stderr, "Unable to determine the number of program headers: %s\n",
+ elf_errmsg (elf_errno ()));
+
+ return 1;
+ }
+
+ trace ("phnum=%zu\n", phnum);
+
+ for (i = 0; i < phnum; i++)
+ {
+ GElf_Phdr phdr_mem;
+ GElf_Phdr *phdr = gelf_getphdr (elf, i, &phdr_mem);
+
+ if (phdr != NULL && phdr->p_type == PT_DYNAMIC)
+ {
+ scn = gelf_offscn (elf, phdr->p_offset);
+ trace ("scn=%p\n", scn);
+
+ if (scn == NULL)
+ {
+ fprintf (stderr, "Unable to get the section: %s\n",
+
+ elf_errmsg (elf_errno ()));
+
+ return 1;
+ }
+
+ shdr = gelf_getshdr (scn, &shdr_mem);
+ trace ("shdr=%p, shdr_mem=%p\n", shdr, &shdr_mem);
+
+ if (shdr == NULL)
+ {
+ fprintf (stderr, "Unable to get the section header: %s\n",
+
+ elf_errmsg (elf_errno ()));
+
+ return 1;
+ }
+ break;
+ }
+ }
+
+ if (shdr == NULL)
+ {
+ fprintf (stderr, "Unable to find the section header\n");
+ return 1;
+ }
+
+ data = elf_getdata (scn, NULL);
+
+ if (data == NULL)
+ {
+ fprintf (stderr, "Unable to get the dynamic section data: %s\n",
+ elf_errmsg (elf_errno ()));
+
+ return 1;
+ }
+
+ trace ("data=%p\n", data);
+
+ sh_entsize = gelf_fsize (elf, ELF_T_DYN, 1, EV_CURRENT);
+ trace ("sh_entsize=%zu\n", sh_entsize);
+
+ for (i = 0; i < shdr->sh_size / sh_entsize; i++)
+ {
+ GElf_Dyn dyn_mem;
+ GElf_Dyn *dyn = gelf_getdyn (data, i, &dyn_mem);
+
+ if (dyn == NULL)
+ break;
+
+ if (dyn->d_tag == DT_NEEDED)
+ printf ("%s\n", elf_strptr (elf, shdr->sh_link, dyn->d_un.d_ptr));
+ }
+
+ elf_end (elf);
+ close (fd);
+ return 0;
+}
diff --git a/srcpkgs/gobject-introspection/files/g-ir-scanner-lddwrapper b/srcpkgs/gobject-introspection/files/g-ir-scanner-lddwrapper
deleted file mode 100755
index b969836b66422a..00000000000000
--- a/srcpkgs/gobject-introspection/files/g-ir-scanner-lddwrapper
+++ /dev/null
@@ -1,2 +0,0 @@
-#!/bin/sh
-/usr/bin/prelink-rtld --root=${XBPS_CROSS_BASE} "$@"
diff --git a/srcpkgs/gobject-introspection/files/g-ir-scanner-wrapper b/srcpkgs/gobject-introspection/files/g-ir-scanner-wrapper
index d5c426d3cc2e2b..23a66d03655490 100755
--- a/srcpkgs/gobject-introspection/files/g-ir-scanner-wrapper
+++ b/srcpkgs/gobject-introspection/files/g-ir-scanner-wrapper
@@ -15,4 +15,4 @@ if [ -n "$XBPS_CROSS_BASE" -a -n "$XBPS_TARGET_MACHINE" -a -n "$XBPS_VERSION" ];
"${@//-I\/usr\/include/-I${XBPS_CROSS_BASE}\/usr\/include}"
fi
-exec /usr/bin/g-ir-scanner.wrapped "$@"
+exec /usr/bin/g-ir-scanner.wrapped --use-ldd-wrapper=/usr/bin/g-ir-scanner-lddwrapper "$@"
diff --git a/srcpkgs/gobject-introspection/patches/0006-giscanner-ignore-error-return-codes-from-ldd-wrapper.patch b/srcpkgs/gobject-introspection/patches/0006-giscanner-ignore-error-return-codes-from-ldd-wrapper.patch
deleted file mode 100644
index 9167f042e5b4e4..00000000000000
--- a/srcpkgs/gobject-introspection/patches/0006-giscanner-ignore-error-return-codes-from-ldd-wrapper.patch
+++ /dev/null
@@ -1,27 +0,0 @@
-From f128cbeead687bfc6532cc1f2cc3e2dc5a2b5b30 Mon Sep 17 00:00:00 2001
-From: Alexander Kanavin <alex.kanavin@gmail.com>
-Date: Wed, 5 Sep 2018 16:46:52 +0200
-Subject: [PATCH] giscanner: ignore error return codes from ldd-wrapper
-
-prelink-rtld, which we use instead of ldd returns 127 when it can't find a library.
-It is not an error per se, but it breaks subprocess.check_output().
-
-Upstream-Status: Inappropriate [oe-core specific]
-Signed-off-by: Alexander Kanavin <alex.kanavin@gmail.com>
----
- giscanner/shlibs.py | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/giscanner/shlibs.py b/giscanner/shlibs.py
-index 01d21a3..3bd3250 100644
---- a/giscanner/shlibs.py
-+++ b/giscanner/shlibs.py
-@@ -108,7 +108,7 @@ def _resolve_non_libtool(options, binary, libraries):
- args.extend(['otool', '-L', binary.args[0]])
- else:
- args.extend(['ldd', binary.args[0]])
-- output = subprocess.check_output(args)
-+ output = subprocess.run(args, check=False, stdout=subprocess.PIPE).stdout
- if isinstance(output, bytes):
- output = output.decode("utf-8", "replace")
-
diff --git a/srcpkgs/gobject-introspection/patches/401ca6d482eab44da9d58b7eebf6dddc6cdf2912.patch b/srcpkgs/gobject-introspection/patches/401ca6d482eab44da9d58b7eebf6dddc6cdf2912.patch
new file mode 100644
index 00000000000000..4dfd02614ff085
--- /dev/null
+++ b/srcpkgs/gobject-introspection/patches/401ca6d482eab44da9d58b7eebf6dddc6cdf2912.patch
@@ -0,0 +1,108 @@
+From 401ca6d482eab44da9d58b7eebf6dddc6cdf2912 Mon Sep 17 00:00:00 2001
+From: Simon McVittie <smcv@debian.org>
+Date: Sun, 12 May 2024 18:03:17 +0100
+Subject: [PATCH] giscanner: Be more thorough about applying -Wl,--no-as-needed
+ option
+
+Some Linux distributions routinely build all executables and libraries
+with -Wl,--as-needed, either by adding it to LDFLAGS or by making it the
+compiler or linker default.
+
+For installed executables and libraries this is a desirable way to
+drop unnecessary transitive dependencies, minimizing the number of
+rebuilds required if a lower-level library breaks ABI, but for our
+dump executable it's counterproductive and can prevent us from finding
+the SONAMEs of libraries that were passed as explicit -l arguments,
+especially if we use a ldd replacement that is not recursive
+(like the one in gobject-introspection#482).
+
+We already had a special case to add -Wl,--no-as-needed to the linker
+arguments, but only for "internal" libraries and only when not using
+libtool. Extend that to cover "external" libraries and libtool as well,
+and filter out any -Wl,--as-needed from LDFLAGS to avoid it from being
+defeated.
+
+Resolves: GNOME/gobject-introspection#505
+Signed-off-by: Simon McVittie <smcv@debian.org>
+---
+ giscanner/ccompiler.py | 28 ++++++++++++++++++++++------
+ giscanner/dumper.py | 3 ++-
+ 2 files changed, 24 insertions(+), 7 deletions(-)
+
+diff --git a/giscanner/ccompiler.py b/giscanner/ccompiler.py
+index d0ed70a3c..1938a842c 100644
+--- a/giscanner/ccompiler.py
++++ b/giscanner/ccompiler.py
+@@ -35,6 +35,17 @@ from distutils.sysconfig import customize_compiler as orig_customize_compiler
+ from . import utils
+
+
++def no_as_needed(linker):
++ """\
++ Filter out -Wl,--as-needed from the shell-quoted arguments in linker.
++ """
++ return ' '.join(
++ [shlex.quote(arg)
++ for arg in shlex.split(linker)
++ if arg != '-Wl,--as-needed']
++ )
++
++
+ def customize_compiler(compiler):
+ """This is a version of distutils.sysconfig.customize_compiler, without
+ any macOS specific bits and which tries to avoid using any Python specific
+@@ -88,8 +99,8 @@ def customize_compiler(compiler):
+ compiler=cc_cmd,
+ compiler_so=cc_cmd,
+ compiler_cxx=cxx,
+- linker_so=ldshared,
+- linker_exe=cc,
++ linker_so=no_as_needed(ldshared),
++ linker_exe=no_as_needed(cc),
+ archiver=archiver)
+
+ compiler.shared_lib_extension = shlib_suffix
+@@ -230,10 +241,10 @@ class CCompiler(object):
+ # https://bugzilla.gnome.org/show_bug.cgi?id=625195
+ args.append('-Wl,-rpath,.')
+
+- # Ensure libraries are always linked as we are going to use ldd to work
+- # out their names later
+- if sys.platform != 'darwin':
+- args.append('-Wl,--no-as-needed')
++ # Ensure libraries are always linked as we are going to use ldd to work
++ # out their names later
++ if sys.platform != 'darwin':
++ args.append('-Wl,--no-as-needed')
+
+ for library_path in libpaths:
+ # The dumper program needs to look for dynamic libraries
+@@ -279,6 +290,11 @@ class CCompiler(object):
+ # is installed on the system; this case is used for the scanning
+ # of GLib in gobject-introspection itself.
+
++ # Ensure libraries are always linked as we are going to use ldd to work
++ # out their names later
++ if os.name != 'nt' and sys.platform != 'darwin':
++ args.append('-Wl,--no-as-needed')
++
+ for library in libraries:
+ if os.path.isfile(library):
+ # If we get a real filename, just use it as-is
+diff --git a/giscanner/dumper.py b/giscanner/dumper.py
+index 74a494b8b..e2e7eeed0 100644
+--- a/giscanner/dumper.py
++++ b/giscanner/dumper.py
+@@ -254,7 +254,8 @@ class DumpCompiler(object):
+
+ if not self._compiler.check_is_msvc():
+ for ldflag in shlex.split(os.environ.get('LDFLAGS', '')):
+- args.append(ldflag)
++ if ldflag != '-Wl,--as-needed':
++ args.append(ldflag)
+
+ dll_dirs = utils.dll_dirs()
+ dll_dirs.add_dll_dirs(self._packages)
+--
+GitLab
+
diff --git a/srcpkgs/gobject-introspection/template b/srcpkgs/gobject-introspection/template
index 60b4b05178e227..1e6aa8e6ef2b9d 100644
--- a/srcpkgs/gobject-introspection/template
+++ b/srcpkgs/gobject-introspection/template
@@ -2,13 +2,13 @@
# keep in sync with gobject-introspection-bootstrap
pkgname=gobject-introspection
version=1.80.1
-revision=1
+revision=2
build_style=meson
pycompile_dirs="usr/lib/gobject-introspection/giscanner"
hostmakedepends="flex pkg-config"
# won't run tests with cairo to avoid cyclical deps
-makedepends="libffi-devel libglib-devel python3-devel python3-Mako
- python3-Markdown"
+makedepends="libffi-devel libglib-devel python3-devel elfutils-devel
+ python3-Mako python3-Markdown"
depends="libgirepository-devel python3-Mako python3-Markdown python3-setuptools"
short_desc="Introspection system for GObject-based libraries"
maintainer="Enno Boland <gottox@voidlinux.org>"
@@ -20,20 +20,24 @@ checksum=a1df7c424e15bda1ab639c00e9051b9adf5cea1a9e512f8a603b53cd199bc6d8
python_version=3
if [ "$CROSS_BUILD" ]; then
- hostmakedepends+=" gobject-introspection qemu-user-static prelink-cross"
+ hostmakedepends+=" gobject-introspection qemu-user-static"
configure_args+=" -Dgi_cross_use_prebuilt_gi=true
-Dgi_cross_binary_wrapper=/usr/bin/g-ir-scanner-qemuwrapper
-Dgi_cross_ldd_wrapper=/usr/bin/g-ir-scanner-lddwrapper
-Dgi_cross_pkgconfig_sysroot_path=${XBPS_CROSS_BASE}"
fi
+post_build() {
+ $CC $CFLAGS $LDFLAGS ${FILESDIR}/elf-get-needed.c -lelf -o elf-get-needed
+}
+
post_install() {
rm ${DESTDIR}/usr/lib/gobject-introspection/giscanner/doctemplates/*/meson.build
# Install our wrappers system-wide, they are required for building all other
# gobject-based packages.
vbin ${FILESDIR}/g-ir-scanner-qemuwrapper
- vbin ${FILESDIR}/g-ir-scanner-lddwrapper
+ vbin elf-get-needed g-ir-scanner-lddwrapper
# Install g-ir-scanner-wrapper as g-ir-scanner, we need it with that name since
# we can't expect people to just not hardcode /usr/bin/g-ir-scanner, some packages
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [RFC] gobject-introspection: use elfutils lddwraper instead of prelink-cross
2024-03-22 23:56 [PR PATCH] [RFC] gobject-introspection: used elfutils lldwraper instead of prelink-cross oreo639
` (5 preceding siblings ...)
2024-05-15 20:01 ` [PR PATCH] [Updated] " oreo639
@ 2024-05-15 20:25 ` oreo639
2024-05-15 20:25 ` oreo639
` (3 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: oreo639 @ 2024-05-15 20:25 UTC (permalink / raw)
To: ml
[-- Attachment #1: Type: text/plain, Size: 416 bytes --]
New comment by oreo639 on void-packages repository
https://github.com/void-linux/void-packages/pull/49468#issuecomment-2058625975
Comment:
I re-marked this as a draft because after testing I realize that ldd was being used to resolve manually specified library names to their sonames (based on the ones pulled in by the executable).
~~This also breaks typelib generation for e.g. ibus-anthy.~~ Has been resolved.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [RFC] gobject-introspection: use elfutils lddwraper instead of prelink-cross
2024-03-22 23:56 [PR PATCH] [RFC] gobject-introspection: used elfutils lldwraper instead of prelink-cross oreo639
` (6 preceding siblings ...)
2024-05-15 20:25 ` oreo639
@ 2024-05-15 20:25 ` oreo639
2024-08-14 1:52 ` github-actions
` (2 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: oreo639 @ 2024-05-15 20:25 UTC (permalink / raw)
To: ml
[-- Attachment #1: Type: text/plain, Size: 422 bytes --]
New comment by oreo639 on void-packages repository
https://github.com/void-linux/void-packages/pull/49468#issuecomment-2058625975
Comment:
I re-marked this as a draft because after testing I realize that ldd was being used to resolve manually specified library names to their sonames (based on the ones pulled in by the executable).
~~This also breaks typelib generation for e.g. ibus-anthy.~~ Edit: Has been resolved.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [RFC] gobject-introspection: use elfutils lddwraper instead of prelink-cross
2024-03-22 23:56 [PR PATCH] [RFC] gobject-introspection: used elfutils lldwraper instead of prelink-cross oreo639
` (7 preceding siblings ...)
2024-05-15 20:25 ` oreo639
@ 2024-08-14 1:52 ` github-actions
2024-08-21 6:09 ` [PR PATCH] [Updated] " oreo639
2024-11-20 2:02 ` github-actions
10 siblings, 0 replies; 12+ messages in thread
From: github-actions @ 2024-08-14 1:52 UTC (permalink / raw)
To: ml
[-- Attachment #1: Type: text/plain, Size: 305 bytes --]
New comment by github-actions[bot] on void-packages repository
https://github.com/void-linux/void-packages/pull/49468#issuecomment-2287682665
Comment:
Pull Requests become stale 90 days after last activity and are closed 14 days after that. If this pull request is still relevant bump it or assign it.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PR PATCH] [Updated] [RFC] gobject-introspection: use elfutils lddwraper instead of prelink-cross
2024-03-22 23:56 [PR PATCH] [RFC] gobject-introspection: used elfutils lldwraper instead of prelink-cross oreo639
` (8 preceding siblings ...)
2024-08-14 1:52 ` github-actions
@ 2024-08-21 6:09 ` oreo639
2024-11-20 2:02 ` github-actions
10 siblings, 0 replies; 12+ messages in thread
From: oreo639 @ 2024-08-21 6:09 UTC (permalink / raw)
To: ml
[-- Attachment #1: Type: text/plain, Size: 1608 bytes --]
There is an updated pull request by oreo639 against master on the void-packages repository
https://github.com/oreo639/void-packages gi-cross
https://github.com/void-linux/void-packages/pull/49468
[RFC] gobject-introspection: use elfutils lddwraper instead of prelink-cross
Replace lddwraper with one maintained by Debian using elfutils. elfutils is already a dependency of glib.
https://salsa.debian.org/gnome-team/gobject-introspection/-/blob/debian/latest/debian/elf-get-needed.c
https://gitlab.gnome.org/GNOME/gobject-introspection/-/issues/482
This needs more testing.
<!-- Uncomment relevant sections and delete options which are not applicable -->
#### Testing the changes
- I tested the changes in this PR: **briefly**
<!--
#### New package
- This new package conforms to the [package requirements](https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#package-requirements): **YES**|**NO**
-->
<!-- Note: If the build is likely to take more than 2 hours, please add ci skip tag as described in
https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#continuous-integration
and test at least one native build and, if supported, at least one cross build.
Ignore this section if this PR is not skipping CI.
-->
<!--
#### Local build testing
- I built this PR locally for my native architecture, (ARCH-LIBC)
- I built this PR locally for these architectures (if supported. mark crossbuilds):
- aarch64-musl
- armv7l
- armv6l-musl
-->
A patch file from https://github.com/void-linux/void-packages/pull/49468.patch is attached
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-gi-cross-49468.patch --]
[-- Type: text/x-diff, Size: 14224 bytes --]
From fe5a66122c2bfbdccb7ebf202a23666df4607f2b Mon Sep 17 00:00:00 2001
From: oreo639 <oreo6391@gmail.com>
Date: Fri, 22 Mar 2024 16:47:54 -0700
Subject: [PATCH] gobject-introspection: use elfutils lldwraper instead of
prelink-cross
Replace lldwraper with one maintained by Debian using elfutils.
elfutils is already a dependency of glib.
Also, always use this lldwrapper by default for both native and cross.
https://salsa.debian.org/gnome-team/gobject-introspection/-/blob/debian/latest/debian/elf-get-needed.c
https://gitlab.gnome.org/GNOME/gobject-introspection/-/issues/482
---
.../files/elf-get-needed.c | 156 ++++++++++++++++++
.../files/g-ir-scanner-wrapper | 2 +-
...-error-return-codes-from-ldd-wrapper.patch | 27 ---
...a6d482eab44da9d58b7eebf6dddc6cdf2912.patch | 108 ++++++++++++
srcpkgs/gobject-introspection/template | 14 +-
5 files changed, 274 insertions(+), 33 deletions(-)
create mode 100644 srcpkgs/gobject-introspection/files/elf-get-needed.c
delete mode 100644 srcpkgs/gobject-introspection/patches/0006-giscanner-ignore-error-return-codes-from-ldd-wrapper.patch
create mode 100644 srcpkgs/gobject-introspection/patches/401ca6d482eab44da9d58b7eebf6dddc6cdf2912.patch
diff --git a/srcpkgs/gobject-introspection/files/elf-get-needed.c b/srcpkgs/gobject-introspection/files/elf-get-needed.c
new file mode 100644
index 00000000000000..be78f3bdf2a925
--- /dev/null
+++ b/srcpkgs/gobject-introspection/files/elf-get-needed.c
@@ -0,0 +1,156 @@
+/*
+ * Copyright © 2019-2023 Collabora Ltd.
+ * SPDX-License-Identifier: MIT
+ *
+ * Use libelf to parse ELF headers for DT_NEEDED, and fake the output
+ * format of ldd closely enough that GObject-Introspection can parse it.
+ *
+ * Limitations when compared with real ldd:
+ * - Only direct dependencies are output: unlike ldd, this is not recursive.
+ * For GObject-Introspection this is what we ideally want anyway.
+ * - Only bare SONAMEs are output, no paths or other extraneous information.
+ *
+ * https://salsa.debian.org/gnome-team/gobject-introspection/-/blob/debian/latest/debian/elf-get-needed.c
+ * https://gitlab.gnome.org/GNOME/gobject-introspection/-/issues/482
+ */
+
+#include <fcntl.h>
+#include <stddef.h>
+#include <stdio.h>
+#include <unistd.h>
+
+#include <elf.h>
+#include <gelf.h>
+
+#if 0
+#define trace(...) fprintf(stderr, __VA_ARGS__)
+#else
+#define trace(...) do {} while (0)
+#endif
+
+int
+main (int argc,
+ char **argv)
+{
+ const char *library;
+ Elf *elf = NULL;
+ Elf_Scn *scn = NULL;
+ GElf_Shdr shdr_mem;
+ GElf_Shdr *shdr = NULL;
+ size_t phnum;
+ size_t i;
+ Elf_Data *data;
+ uintptr_t needed_offset = (uintptr_t) -1;
+ const char *needed;
+ size_t sh_entsize;
+ int fd;
+
+ if (argc != 2)
+ {
+ fprintf (stderr, "Usage: %s LIBRARY\n", argv[0]);
+ return 2;
+ }
+
+ library = argv[1];
+
+ if (elf_version (EV_CURRENT) == EV_NONE)
+ {
+ perror ("elf_version(EV_CURRENT)");
+ return 1;
+ }
+
+ if ((fd = open (library, O_RDONLY | O_CLOEXEC, 0)) < 0)
+ {
+ perror (library);
+ return 1;
+ }
+
+ if ((elf = elf_begin (fd, ELF_C_READ, NULL)) == NULL)
+ {
+ fprintf (stderr, "Error reading library %s: %s",
+ library, elf_errmsg (elf_errno ()));
+ return 1;
+ }
+
+ if (elf_getphdrnum (elf, &phnum) < 0)
+ {
+
+ fprintf (stderr, "Unable to determine the number of program headers: %s\n",
+ elf_errmsg (elf_errno ()));
+
+ return 1;
+ }
+
+ trace ("phnum=%zu\n", phnum);
+
+ for (i = 0; i < phnum; i++)
+ {
+ GElf_Phdr phdr_mem;
+ GElf_Phdr *phdr = gelf_getphdr (elf, i, &phdr_mem);
+
+ if (phdr != NULL && phdr->p_type == PT_DYNAMIC)
+ {
+ scn = gelf_offscn (elf, phdr->p_offset);
+ trace ("scn=%p\n", scn);
+
+ if (scn == NULL)
+ {
+ fprintf (stderr, "Unable to get the section: %s\n",
+
+ elf_errmsg (elf_errno ()));
+
+ return 1;
+ }
+
+ shdr = gelf_getshdr (scn, &shdr_mem);
+ trace ("shdr=%p, shdr_mem=%p\n", shdr, &shdr_mem);
+
+ if (shdr == NULL)
+ {
+ fprintf (stderr, "Unable to get the section header: %s\n",
+
+ elf_errmsg (elf_errno ()));
+
+ return 1;
+ }
+ break;
+ }
+ }
+
+ if (shdr == NULL)
+ {
+ fprintf (stderr, "Unable to find the section header\n");
+ return 1;
+ }
+
+ data = elf_getdata (scn, NULL);
+
+ if (data == NULL)
+ {
+ fprintf (stderr, "Unable to get the dynamic section data: %s\n",
+ elf_errmsg (elf_errno ()));
+
+ return 1;
+ }
+
+ trace ("data=%p\n", data);
+
+ sh_entsize = gelf_fsize (elf, ELF_T_DYN, 1, EV_CURRENT);
+ trace ("sh_entsize=%zu\n", sh_entsize);
+
+ for (i = 0; i < shdr->sh_size / sh_entsize; i++)
+ {
+ GElf_Dyn dyn_mem;
+ GElf_Dyn *dyn = gelf_getdyn (data, i, &dyn_mem);
+
+ if (dyn == NULL)
+ break;
+
+ if (dyn->d_tag == DT_NEEDED)
+ printf ("%s\n", elf_strptr (elf, shdr->sh_link, dyn->d_un.d_ptr));
+ }
+
+ elf_end (elf);
+ close (fd);
+ return 0;
+}
diff --git a/srcpkgs/gobject-introspection/files/g-ir-scanner-wrapper b/srcpkgs/gobject-introspection/files/g-ir-scanner-wrapper
index d5c426d3cc2e2b..23a66d03655490 100644
--- a/srcpkgs/gobject-introspection/files/g-ir-scanner-wrapper
+++ b/srcpkgs/gobject-introspection/files/g-ir-scanner-wrapper
@@ -15,4 +15,4 @@ if [ -n "$XBPS_CROSS_BASE" -a -n "$XBPS_TARGET_MACHINE" -a -n "$XBPS_VERSION" ];
"${@//-I\/usr\/include/-I${XBPS_CROSS_BASE}\/usr\/include}"
fi
-exec /usr/bin/g-ir-scanner.wrapped "$@"
+exec /usr/bin/g-ir-scanner.wrapped --use-ldd-wrapper=/usr/bin/g-ir-scanner-lddwrapper "$@"
diff --git a/srcpkgs/gobject-introspection/patches/0006-giscanner-ignore-error-return-codes-from-ldd-wrapper.patch b/srcpkgs/gobject-introspection/patches/0006-giscanner-ignore-error-return-codes-from-ldd-wrapper.patch
deleted file mode 100644
index 9167f042e5b4e4..00000000000000
--- a/srcpkgs/gobject-introspection/patches/0006-giscanner-ignore-error-return-codes-from-ldd-wrapper.patch
+++ /dev/null
@@ -1,27 +0,0 @@
-From f128cbeead687bfc6532cc1f2cc3e2dc5a2b5b30 Mon Sep 17 00:00:00 2001
-From: Alexander Kanavin <alex.kanavin@gmail.com>
-Date: Wed, 5 Sep 2018 16:46:52 +0200
-Subject: [PATCH] giscanner: ignore error return codes from ldd-wrapper
-
-prelink-rtld, which we use instead of ldd returns 127 when it can't find a library.
-It is not an error per se, but it breaks subprocess.check_output().
-
-Upstream-Status: Inappropriate [oe-core specific]
-Signed-off-by: Alexander Kanavin <alex.kanavin@gmail.com>
----
- giscanner/shlibs.py | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/giscanner/shlibs.py b/giscanner/shlibs.py
-index 01d21a3..3bd3250 100644
---- a/giscanner/shlibs.py
-+++ b/giscanner/shlibs.py
-@@ -108,7 +108,7 @@ def _resolve_non_libtool(options, binary, libraries):
- args.extend(['otool', '-L', binary.args[0]])
- else:
- args.extend(['ldd', binary.args[0]])
-- output = subprocess.check_output(args)
-+ output = subprocess.run(args, check=False, stdout=subprocess.PIPE).stdout
- if isinstance(output, bytes):
- output = output.decode("utf-8", "replace")
-
diff --git a/srcpkgs/gobject-introspection/patches/401ca6d482eab44da9d58b7eebf6dddc6cdf2912.patch b/srcpkgs/gobject-introspection/patches/401ca6d482eab44da9d58b7eebf6dddc6cdf2912.patch
new file mode 100644
index 00000000000000..4dfd02614ff085
--- /dev/null
+++ b/srcpkgs/gobject-introspection/patches/401ca6d482eab44da9d58b7eebf6dddc6cdf2912.patch
@@ -0,0 +1,108 @@
+From 401ca6d482eab44da9d58b7eebf6dddc6cdf2912 Mon Sep 17 00:00:00 2001
+From: Simon McVittie <smcv@debian.org>
+Date: Sun, 12 May 2024 18:03:17 +0100
+Subject: [PATCH] giscanner: Be more thorough about applying -Wl,--no-as-needed
+ option
+
+Some Linux distributions routinely build all executables and libraries
+with -Wl,--as-needed, either by adding it to LDFLAGS or by making it the
+compiler or linker default.
+
+For installed executables and libraries this is a desirable way to
+drop unnecessary transitive dependencies, minimizing the number of
+rebuilds required if a lower-level library breaks ABI, but for our
+dump executable it's counterproductive and can prevent us from finding
+the SONAMEs of libraries that were passed as explicit -l arguments,
+especially if we use a ldd replacement that is not recursive
+(like the one in gobject-introspection#482).
+
+We already had a special case to add -Wl,--no-as-needed to the linker
+arguments, but only for "internal" libraries and only when not using
+libtool. Extend that to cover "external" libraries and libtool as well,
+and filter out any -Wl,--as-needed from LDFLAGS to avoid it from being
+defeated.
+
+Resolves: GNOME/gobject-introspection#505
+Signed-off-by: Simon McVittie <smcv@debian.org>
+---
+ giscanner/ccompiler.py | 28 ++++++++++++++++++++++------
+ giscanner/dumper.py | 3 ++-
+ 2 files changed, 24 insertions(+), 7 deletions(-)
+
+diff --git a/giscanner/ccompiler.py b/giscanner/ccompiler.py
+index d0ed70a3c..1938a842c 100644
+--- a/giscanner/ccompiler.py
++++ b/giscanner/ccompiler.py
+@@ -35,6 +35,17 @@ from distutils.sysconfig import customize_compiler as orig_customize_compiler
+ from . import utils
+
+
++def no_as_needed(linker):
++ """\
++ Filter out -Wl,--as-needed from the shell-quoted arguments in linker.
++ """
++ return ' '.join(
++ [shlex.quote(arg)
++ for arg in shlex.split(linker)
++ if arg != '-Wl,--as-needed']
++ )
++
++
+ def customize_compiler(compiler):
+ """This is a version of distutils.sysconfig.customize_compiler, without
+ any macOS specific bits and which tries to avoid using any Python specific
+@@ -88,8 +99,8 @@ def customize_compiler(compiler):
+ compiler=cc_cmd,
+ compiler_so=cc_cmd,
+ compiler_cxx=cxx,
+- linker_so=ldshared,
+- linker_exe=cc,
++ linker_so=no_as_needed(ldshared),
++ linker_exe=no_as_needed(cc),
+ archiver=archiver)
+
+ compiler.shared_lib_extension = shlib_suffix
+@@ -230,10 +241,10 @@ class CCompiler(object):
+ # https://bugzilla.gnome.org/show_bug.cgi?id=625195
+ args.append('-Wl,-rpath,.')
+
+- # Ensure libraries are always linked as we are going to use ldd to work
+- # out their names later
+- if sys.platform != 'darwin':
+- args.append('-Wl,--no-as-needed')
++ # Ensure libraries are always linked as we are going to use ldd to work
++ # out their names later
++ if sys.platform != 'darwin':
++ args.append('-Wl,--no-as-needed')
+
+ for library_path in libpaths:
+ # The dumper program needs to look for dynamic libraries
+@@ -279,6 +290,11 @@ class CCompiler(object):
+ # is installed on the system; this case is used for the scanning
+ # of GLib in gobject-introspection itself.
+
++ # Ensure libraries are always linked as we are going to use ldd to work
++ # out their names later
++ if os.name != 'nt' and sys.platform != 'darwin':
++ args.append('-Wl,--no-as-needed')
++
+ for library in libraries:
+ if os.path.isfile(library):
+ # If we get a real filename, just use it as-is
+diff --git a/giscanner/dumper.py b/giscanner/dumper.py
+index 74a494b8b..e2e7eeed0 100644
+--- a/giscanner/dumper.py
++++ b/giscanner/dumper.py
+@@ -254,7 +254,8 @@ class DumpCompiler(object):
+
+ if not self._compiler.check_is_msvc():
+ for ldflag in shlex.split(os.environ.get('LDFLAGS', '')):
+- args.append(ldflag)
++ if ldflag != '-Wl,--as-needed':
++ args.append(ldflag)
+
+ dll_dirs = utils.dll_dirs()
+ dll_dirs.add_dll_dirs(self._packages)
+--
+GitLab
+
diff --git a/srcpkgs/gobject-introspection/template b/srcpkgs/gobject-introspection/template
index 60b4b05178e227..1e6aa8e6ef2b9d 100644
--- a/srcpkgs/gobject-introspection/template
+++ b/srcpkgs/gobject-introspection/template
@@ -2,13 +2,13 @@
# keep in sync with gobject-introspection-bootstrap
pkgname=gobject-introspection
version=1.80.1
-revision=1
+revision=2
build_style=meson
pycompile_dirs="usr/lib/gobject-introspection/giscanner"
hostmakedepends="flex pkg-config"
# won't run tests with cairo to avoid cyclical deps
-makedepends="libffi-devel libglib-devel python3-devel python3-Mako
- python3-Markdown"
+makedepends="libffi-devel libglib-devel python3-devel elfutils-devel
+ python3-Mako python3-Markdown"
depends="libgirepository-devel python3-Mako python3-Markdown python3-setuptools"
short_desc="Introspection system for GObject-based libraries"
maintainer="Enno Boland <gottox@voidlinux.org>"
@@ -20,20 +20,24 @@ checksum=a1df7c424e15bda1ab639c00e9051b9adf5cea1a9e512f8a603b53cd199bc6d8
python_version=3
if [ "$CROSS_BUILD" ]; then
- hostmakedepends+=" gobject-introspection qemu-user-static prelink-cross"
+ hostmakedepends+=" gobject-introspection qemu-user-static"
configure_args+=" -Dgi_cross_use_prebuilt_gi=true
-Dgi_cross_binary_wrapper=/usr/bin/g-ir-scanner-qemuwrapper
-Dgi_cross_ldd_wrapper=/usr/bin/g-ir-scanner-lddwrapper
-Dgi_cross_pkgconfig_sysroot_path=${XBPS_CROSS_BASE}"
fi
+post_build() {
+ $CC $CFLAGS $LDFLAGS ${FILESDIR}/elf-get-needed.c -lelf -o elf-get-needed
+}
+
post_install() {
rm ${DESTDIR}/usr/lib/gobject-introspection/giscanner/doctemplates/*/meson.build
# Install our wrappers system-wide, they are required for building all other
# gobject-based packages.
vbin ${FILESDIR}/g-ir-scanner-qemuwrapper
- vbin ${FILESDIR}/g-ir-scanner-lddwrapper
+ vbin elf-get-needed g-ir-scanner-lddwrapper
# Install g-ir-scanner-wrapper as g-ir-scanner, we need it with that name since
# we can't expect people to just not hardcode /usr/bin/g-ir-scanner, some packages
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [RFC] gobject-introspection: use elfutils lddwraper instead of prelink-cross
2024-03-22 23:56 [PR PATCH] [RFC] gobject-introspection: used elfutils lldwraper instead of prelink-cross oreo639
` (9 preceding siblings ...)
2024-08-21 6:09 ` [PR PATCH] [Updated] " oreo639
@ 2024-11-20 2:02 ` github-actions
10 siblings, 0 replies; 12+ messages in thread
From: github-actions @ 2024-11-20 2:02 UTC (permalink / raw)
To: ml
[-- Attachment #1: Type: text/plain, Size: 305 bytes --]
New comment by github-actions[bot] on void-packages repository
https://github.com/void-linux/void-packages/pull/49468#issuecomment-2487163430
Comment:
Pull Requests become stale 90 days after last activity and are closed 14 days after that. If this pull request is still relevant bump it or assign it.
^ permalink raw reply [flat|nested] 12+ messages in thread