[Bug 273845] emulators/qemu-user-static: ld: error: undefined symbol: elf_getphnum

From: <bugzilla-noreply_at_freebsd.org>
Date: Sun, 24 Sep 2023 15:55:24 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=273845

John Hein <jcfyecrayz@liamekaens.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
 Attachment #245188|                            |maintainer-approval?
              Flags|                            |

--- Comment #10 from John Hein <jcfyecrayz@liamekaens.com> ---
Created attachment 245188
  --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=245188&action=edit
[patch] fix build failure linking elfutils version of libelf (and missing dep)

Attached is a patch to fix this build failure.

(1) It now includes an ELFUTILS option to use the devel/elfutils version of
libelf.
(2) It uses -L/usr/lib otherwise (default is to use base libelf).
(3) While here, shuffle a few variables per portclippy's recommendations.
(4) Bump PORTREVISION - the package changes with the ELFUTILS option addition.

This will link with the base libelf if ELFUTILS is off (which is the default). 
And if someone chooses to enable ELFUTILS, the dependency will be recorded.

I considered marking the ELFUTILS option broken if enabled, but there is a fix
already committed (bug 273966) in base libprocstat to use elf_getphdrnum()
instead of the deprecated elf_getphnum() - with pending MFCs.  That will fix
this build failure as it makes its way into FreeBSD releases. Since ELFUTILS is
not enabled by default and the "fix is coming soon" in base, I decided against
marking it broken at this time.  I leave it to the committer to decide to add
that, if desired.  If we get a lot more bug reports due to people trying to
enable ELFUTILS, we can then change course, and mark it broken for appropriate
FreeBSD versions.  I suspect most qemu ports users will be perfectly happy
linking with the base version of libelf.

Now in case elfutils is installed, there will no longer be an unrecorded link
dependency on <localbase>/lib/libelf.so.  Either it will link with
/usr/lib/libelf.so or it will link with <localbase>/lib/libelf.so and the
dependency will be recorded (needs an updated libprocstat to be able to link
with elfutils' libelf).

QA: portlint, portclippy, poudriere builds - OK

======

I did also check emulators/qemu ports to see if it needs a similar treatment to
build in case devel/elfutils is installed.  It appears that it does not.  'make
configure' finds /usr/lib/libelf.so even if elfutils is installed:

-- Found LIBOMPTARGET_DEP_LIBELF: /usr/lib/libelf.so

If we want to support using libelf from devel/elfutils for emulators/qemu, then
an ELFUTILS options could be added separately, but it's not needed to fix a
build problem and therefore not directly relevant to resolve this bug 273845.

-- 
You are receiving this mail because:
You are the assignee for the bug.