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
*** Bug 273800 has been marked as a duplicate of this bug. ***
Why not cut this out, like: https://bugs.freebsd.org/bugzilla/attachment.cgi?id=244903&action=diff ?
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=273839#c1
Created attachment 247253 [details] patch
(In reply to Vladimir Druzenko from comment #0) Try this. I do not disable libelf linking, but force use system libelf.
(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.
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?
(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 ============================================================================================