Bug 273479 - devel/glib20: silent grab libelf.so.1 from devel/elfutils
Summary: devel/glib20: silent grab libelf.so.1 from devel/elfutils
Status: Open
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Some People
Assignee: freebsd-ports-bugs (Nobody)
URL:
Keywords:
: 273800 (view as bug list)
Depends on:
Blocks:
 
Reported: 2023-08-31 13:43 UTC by Vladimir Druzenko
Modified: 2023-12-30 16:36 UTC (History)
4 users (show)

See Also:
vvd: maintainer-feedback? (desktop)


Attachments
patch (1.15 KB, patch)
2023-12-26 03:28 UTC, Ivan Rozhuk
rozhuk.im: maintainer-approval?
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Vladimir Druzenko freebsd_committer freebsd_triage 2023-08-31 13:43:28 UTC
13.2 amd64.
devel/glib20 silent grab libelf.so.1 if devel/elfutils installed.
MESON_ARGS+= -Dlibelf=disabled didn't help.

This upstream issue look like it's related:
https://gitlab.gnome.org/GNOME/glib/-/merge_requests/3335
Comment 1 Vladimir Druzenko freebsd_committer freebsd_triage 2023-09-15 01:32:54 UTC
*** Bug 273800 has been marked as a duplicate of this bug. ***
Comment 2 Ivan Rozhuk 2023-09-15 21:08:28 UTC
Why not cut this out, like: https://bugs.freebsd.org/bugzilla/attachment.cgi?id=244903&action=diff ?
Comment 4 Ivan Rozhuk 2023-12-26 03:28:17 UTC
Created attachment 247253 [details]
patch
Comment 5 Ivan Rozhuk 2023-12-26 03:29:14 UTC
(In reply to Vladimir Druzenko from comment #0)
Try this.
I do not disable libelf linking, but force use system libelf.
Comment 6 Vladimir Druzenko freebsd_committer freebsd_triage 2023-12-26 14:34:52 UTC
(In reply to Ivan Rozhuk from comment #5)
[ 84% 503/592] cc -Igio/gresource.p -Igio -I../gio -I. -I.. -Iglib -I../glib -Igmodule -I../gmodule -Igobject -I../gobject -fdiagnostics-color=never -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wextra -Wpedantic -std=gnu99 -D_GNU_SOURCE -fno-strict-aliasing -DG_ENABLE_DEBUG -Wimplicit-fallthrough -Wmisleading-indentation -Wmissing-field-initializers -Wnonnull -Wunused -Wno-unused-parameter -Wno-cast-function-type -Wno-pedantic -Wno-format-zero-length -Wno-variadic-macros -Werror=format=2 -Werror=init-self -Werror=missing-include-dirs -Werror=pointer-arith -Werror=unused-result -Wstrict-prototypes -Wno-bad-function-cast -Werror=implicit-function-declaration -Werror=missing-prototypes -Werror=pointer-sign -Wno-string-plus-int -O2 -pipe -march=core2 -fstack-protector-strong -isystem /usr/local/include -fno-strict-aliasing -isystem /usr/local/include -MD -MQ gio/gresource.p/gresource-tool.c.o -MF gio/gresource.p/gresource-tool.c.o.d -o gio/gresource.p/gresource-tool.c.o -c ../gio/gresource-tool.c
FAILED: gio/gresource.p/gresource-tool.c.o
cc -Igio/gresource.p -Igio -I../gio -I. -I.. -Iglib -I../glib -Igmodule -I../gmodule -Igobject -I../gobject -fdiagnostics-color=never -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wextra -Wpedantic -std=gnu99 -D_GNU_SOURCE -fno-strict-aliasing -DG_ENABLE_DEBUG -Wimplicit-fallthrough -Wmisleading-indentation -Wmissing-field-initializers -Wnonnull -Wunused -Wno-unused-parameter -Wno-cast-function-type -Wno-pedantic -Wno-format-zero-length -Wno-variadic-macros -Werror=format=2 -Werror=init-self -Werror=missing-include-dirs -Werror=pointer-arith -Werror=unused-result -Wstrict-prototypes -Wno-bad-function-cast -Werror=implicit-function-declaration -Werror=missing-prototypes -Werror=pointer-sign -Wno-string-plus-int -O2 -pipe -march=core2 -fstack-protector-strong -isystem /usr/local/include -fno-strict-aliasing -isystem /usr/local/include -MD -MQ gio/gresource.p/gresource-tool.c.o -MF gio/gresource.p/gresource-tool.c.o.d -o gio/gresource.p/gresource-tool.c.o -c ../gio/gresource-tool.c
../gio/gresource-tool.c:176:38: error: unknown type name 'GElf_Shdr'; did you mean 'Elf_Nhdr'?
typedef gboolean (*SectionCallback) (GElf_Shdr   *shdr,
                                     ^~~~~~~~~
                                     Elf_Nhdr
/usr/include/sys/elf_common.h:55:18: note: 'Elf_Nhdr' declared here
typedef Elf_Note Elf_Nhdr;
                 ^
../gio/gresource-tool.c:189:3: error: unknown type name 'GElf_Shdr'; did you mean 'Elf_Nhdr'?
  GElf_Shdr *shdr, shdr_mem;
  ^~~~~~~~~
  Elf_Nhdr
/usr/include/sys/elf_common.h:55:18: note: 'Elf_Nhdr' declared here
typedef Elf_Note Elf_Nhdr;
                 ^
../gio/gresource-tool.c:204:14: error: implicit declaration of function 'gelf_getshdr' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
      shdr = gelf_getshdr (scn, &shdr_mem);
             ^
../gio/gresource-tool.c:204:12: warning: incompatible integer to pointer conversion assigning to 'Elf_Nhdr *' (aka 'Elf_Note *') from 'int' [-Wint-conversion]
      shdr = gelf_getshdr (scn, &shdr_mem);
           ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../gio/gresource-tool.c:208:17: error: no member named 'sh_type' in 'Elf_Note'; did you mean 'n_type'?
      if (shdr->sh_type != SHT_PROGBITS)
                ^~~~~~~
                n_type
/usr/include/sys/elf_common.h:53:12: note: 'n_type' declared here
        u_int32_t       n_type;         /* Type of this note. */
                        ^
../gio/gresource-tool.c:211:55: error: no member named 'sh_name' in 'Elf_Note'
      section_name = elf_strptr (elf, shstrndx, shdr->sh_name);
                                                ~~~~  ^
../gio/gresource-tool.c:222:24: error: unknown type name 'GElf_Shdr'; did you mean 'Elf_Nhdr'?
resource_from_section (GElf_Shdr *shdr,
                       ^~~~~~~~~
                       Elf_Nhdr
/usr/include/sys/elf_common.h:55:18: note: 'Elf_Nhdr' declared here
typedef Elf_Note Elf_Nhdr;
                 ^
../gio/gresource-tool.c:232:23: error: no member named 'sh_offset' in 'Elf_Note'
  page_offset = shdr->sh_offset % page_size;
                ~~~~  ^
../gio/gresource-tool.c:233:33: error: no member named 'sh_size' in 'Elf_Note'
  contents = mmap (NULL,  shdr->sh_size + page_offset,
                          ~~~~  ^
../gio/gresource-tool.c:234:54: error: no member named 'sh_offset' in 'Elf_Note'
                   PROT_READ, MAP_PRIVATE, fd, shdr->sh_offset - page_offset);
                                               ~~~~  ^
../gio/gresource-tool.c:240:65: error: no member named 'sh_size' in 'Elf_Note'
      bytes = g_bytes_new_static (contents + page_offset, shdr->sh_size);
                                                          ~~~~  ^
../gio/gresource-tool.c:267:20: error: unknown type name 'GElf_Shdr'; did you mean 'Elf_Nhdr'?
list_resources_cb (GElf_Shdr   *shdr,
                   ^~~~~~~~~
                   Elf_Nhdr
/usr/include/sys/elf_common.h:55:18: note: 'Elf_Nhdr' declared here
typedef Elf_Note Elf_Nhdr;
                 ^
../gio/gresource-tool.c:314:22: error: unknown type name 'GElf_Shdr'; did you mean 'Elf_Nhdr'?
extract_resource_cb (GElf_Shdr   *shdr,
                     ^~~~~~~~~
                     Elf_Nhdr
/usr/include/sys/elf_common.h:55:18: note: 'Elf_Nhdr' declared here
typedef Elf_Note Elf_Nhdr;
                 ^
../gio/gresource-tool.c:356:21: error: unknown type name 'GElf_Shdr'; did you mean 'Elf_Nhdr'?
print_section_name (GElf_Shdr   *shdr,
                    ^~~~~~~~~
                    Elf_Nhdr
/usr/include/sys/elf_common.h:55:18: note: 'Elf_Nhdr' declared here
typedef Elf_Note Elf_Nhdr;
                 ^
1 warning and 13 errors generated.
Comment 7 Vladimir Druzenko freebsd_committer freebsd_triage 2023-12-26 14:43:42 UTC
Ignore last message - it was without 1st patch of the patch.

But why do you need 2nd part of the patch if 1st part turns off libelf completely?
Comment 8 Ivan Rozhuk 2023-12-30 16:36:23 UTC
(In reply to Vladimir Druzenko from comment #7)

It does not.
gio/meson.build:
============================================================================================
# Dependencies used by executables below
have_libelf = false
libelf = dependency('libelf', version : '>= 0.8.12', required : false)
if libelf.found() and get_option('libelf').allowed()
  have_libelf = true
else
  # This fallback is necessary on *BSD. elfutils isn't the only libelf
  # implementation, and *BSD usually includes their own libelf as a system
  # library which doesn't have a corresponding .pc file.
  libelf = cc.find_library('elf', required : get_option ('libelf'))
  have_libelf = libelf.found()
  have_libelf = have_libelf and cc.has_function('elf_begin', dependencies : libelf)
  have_libelf = have_libelf and cc.has_function('elf_getshdrstrndx', dependencies : libelf)
  have_libelf = have_libelf and cc.has_function('elf_getshdrnum', dependencies : libelf)
  have_libelf = have_libelf and cc.has_header('libelf.h')
endif

if have_libelf
  glib_conf.set('HAVE_LIBELF', 1)
else
  libelf = []
endif
============================================================================================