Opened 5 years ago

Closed 4 years ago

#59257 closed defect (fixed)

qemu @4.1.0 Undefined symbols _clock_gettime

Reported by: dubiousjim Owned by: raimue (Rainer Müller)
Priority: Normal Milestone:
Component: ports Version:
Keywords: legacy-os Cc: Ionic (Mihai Moldovan), kencu (Ken)
Port: qemu

Description

Really the failure is during the destroot stage, with the log message:

make[1]: Entering directory `/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_emulators_qemu/qemu/work/qemu-4.1.0/slirp'
make[1]: Nothing to be done for `all'.
make[1]: Leaving directory `/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_emulators_qemu/qemu/work/qemu-4.1.0/slirp'
  CC      block.o
no symbols
  LINK    qemu-nbd
Undefined symbols for architecture x86_64:
  "_clock_gettime", referenced from:
      _read_f in qemu-io-cmds.o
      _readv_f in qemu-io-cmds.o
      _write_f in qemu-io-cmds.o
      _writev_f in qemu-io-cmds.o
      _aio_read_f in qemu-io-cmds.o
      _aio_read_done in qemu-io-cmds.o
      _aio_write_f in qemu-io-cmds.o
      ...
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [qemu-nbd] Error 1
make: Leaving directory `/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_emulators_qemu/qemu/work/qemu-4.1.0'
Command failed:  cd "/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_emulators_qemu/qemu/work/qemu-4.1.0" && /usr/bin/make -w install DESTDIR=/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_emulators_qemu/qemu/work/destroot 
Exit code: 2
Error: Failed to destroot qemu: command execution failed

Log attached.

Attachments (2)

qemu.log (2.6 MB) - added by dubiousjim 5 years ago.
qemu-out-of-source.patch (3.8 KB) - added by Ionic (Mihai Moldovan) 4 years ago.
Switch to out-of-source builds to work around reconfiguration problems.

Change History (18)

Changed 5 years ago by dubiousjim

Attachment: qemu.log added

comment:1 Changed 5 years ago by kencu (Ken)

I have this sorted out back to Snow Leopard at least. I'll post up a link shortly for you to try out.

comment:2 Changed 5 years ago by kencu (Ken)

here you are, if you'd like to try it. some tweaking for exactly what systems need what fixes might be helpful.

<https://github.com/kencu/macports-ports/commit/b303e51d04c7ef481176bb2ea1c775625d208252>

$ port -v installed | grep qemu
  qemu @4.1.0_0+cocoa+ssh+target_arm+target_i386+target_m68k+target_ppc+target_x86_64+usb+vnc (active) platform='darwin 10' archs='x86_64' date='2019-10-12T14:50:06-0700'

comment:3 Changed 5 years ago by dubiousjim

Thanks! This built and installed fine. Haven't yet tested the result.

comment:4 Changed 5 years ago by kencu (Ken)

has duplicate 59328

comment:5 Changed 5 years ago by kencu (Ken)

Summary: qemu @4.1.0 build failure with +target_x86_64qemu @4.1.0 Undefined symbols _clock_gettime

comment:6 in reply to:  2 Changed 4 years ago by Ionic (Mihai Moldovan)

Cc: Ionic added

I don't like your commit, though, for these reasons:

  • adding linker flags to C{,XX} compiler calls sounds just plain wrong on many levels
  • the thread-local-storage change looks interesting, but isn't qemu special in that it can use emulated TLS, for which base has no support? You're essentially just replacing the black-/fallback list with that base feature, but not adding the special flag (which may not actually be needed if it worked for you, so... maybe not an issue after all? Have you tested the resulting binaries?)
  • mktemp isn't globally too old, only on some platforms AFAICT, so we could avoid a useless dependency on most (newer) systems
  • same for the cocoa interface change

Let's analyze this issue a bit further: funnily, the legacysupport PG does work! qemu builds fine.

However, it's reconfiguring and rebuilding in the destroot (install) stage and I guess that the flags are lost during the reconfiguration. That's what we actually have to fix - why would we need to rebuild the software after it was already built? The timestamping detection seems to be buggy for some reason.

Changed 4 years ago by Ionic (Mihai Moldovan)

Attachment: qemu-out-of-source.patch added

Switch to out-of-source builds to work around reconfiguration problems.

comment:7 Changed 4 years ago by Ionic (Mihai Moldovan)

Cc: kencu added

I've looked around and noticed that Linux distros generally build qemu out-of-source.

The reason for this is that the qemu build system is essentially buggy when it comes to in-source-tree builds and always reconfigures (wrongly) at install/destroot time. I've tried to work around that issue and touch the file that is getting "too old" for its Makefile dependencies, but that didn't fix the actual problem because updating its timestamp just causes a different set of rebuilds (since it's being used as a prerequisite in other rules).

Switching to out-of-source builds fixes that problem in a pretty nice way.

I've also added Ken's fix for older mktemp versions on 10.10-. Can someone on 10.10 and 10.11 tell me what a simple call to /usr/bin/mktemp does? I know that it fails with a usage message on 10.9 and works on 10.12, but I have no data for either 10.10 or 10.11.

comment:8 Changed 4 years ago by kencu (Ken)

Yes, I hacked in a fix and moved on. That's why I didn't try to PR it. The legacysupport PG did not work for me, but that was then and this is now and who knows? maybe I flubbed something. Good luck! look forward to your product.

comment:9 Changed 4 years ago by Ionic (Mihai Moldovan)

The legacysupport PG worked fine for the initial build. The issue is that the software reconfigured itself in a bad way during destrooting when calling make install and everything went haywire after that.

Just using an out-of-source build works fine on that front without requiring weird and ugly hacks.

I'll let Raim take over as the package maintainer. :)

comment:10 Changed 4 years ago by kencu (Ken)

That -femultedtls business is a clang-specific flag that is automatically added by default by my clang +emulatedtls variant when needed.

It's not something that qemu pays attention to, AFAIK.

So go with my change, I would say.

comment:11 Changed 4 years ago by Ionic (Mihai Moldovan)

Okay, makes sense to me. This said, that change is irrelevant to this bug report but an improvement to the port, and I hence think that Raim should apply it in a separate commit later on.

comment:12 Changed 4 years ago by kencu (Ken)

sure. BTW, that current femulatedtls flag actually doesn't work on it's own any more. The implementation was moved into llvm, as of maybe clang 7, so it just won't function anyway.

comment:13 Changed 4 years ago by dubiousjim

@Ionic asked about bare invocations of mktemp on OSX 10.10 (and 10.11, but I'm using 10.10). Not sure if that info is still needed, but in case it is:

$ /usr/bin/mktemp
usage: mktemp [-d] [-q] [-t prefix] [-u] template ...
       mktemp [-d] [-q] [-u] -t prefix

comment:14 Changed 4 years ago by raimue (Rainer Müller)

Keywords: legacy-os added

comment:15 Changed 4 years ago by Ionic (Mihai Moldovan)

Yep, thanks, so it's the usage message as well.

I'm just gonna push the changes, this kept on lingering for way too long.

comment:16 Changed 4 years ago by Mihai Moldovan <ionic@…>

Resolution: fixed
Status: assignedclosed

In 5712d8aa9fc6201579ccee81782fbc6fcd7c1776/macports-ports (master):

emulators/qemu: fix builds using out-of-source builds. Revbump.

This targets mostly older platforms, but also generally changes behavior
to a more correct one.

The qemu build system is buggy when it comes to in-source-builds. Due to
Makefile dependencies, it always tries to reconfigure using a special
generated file at install time and also re-compiles the whole project.
This would normally be just an annoyance, but because not all parameters
are passed through (exported) correctly, the second build diverges from
the correct first one.

It shouldn't come as a surprise that Linux distros seem to use
out-of-source builds for qemu, which nicely work around that problem.

Additionally, older platforms have an mktemp implementation that always
expects a template as its parameter, but the Makefile doesn't provide
one in some cases. Hence, switch to GNU coreutils's on 10.10-, but keep
using mktemp on more recent platforms because it seems to work fine
there.

Fixes: #59257

Note: See TracTickets for help on using tickets.