* [Qemu-devel] [PATCH 0/2][RESENT-INLINE] Resolve link errors on Mac OS X @ 2016-05-03 1:01 Christopher Friedt 2016-05-03 1:01 ` [Qemu-devel] [PATCH 1/2] [RESENT-INLINE] Use libtool instead of ar to create static libraries on Darwin Christopher Friedt 2016-05-03 1:01 ` [Qemu-devel] [PATCH 2/2] [RESENT-INLINE] Remove unnecessary CONFIG_EVENTFD preprocessor conditional to satisfy link Christopher Friedt 0 siblings, 2 replies; 4+ messages in thread From: Christopher Friedt @ 2016-05-03 1:01 UTC (permalink / raw) To: famz, mst; +Cc: Christopher Friedt, qemu-devel, qemu-trivial Hi list, I recently tried to build Qemu on Mac and ran into a couple of trivial issues that I've provided patches for. I suppose that normally people just use 'brew install qemu', but there is really no reason that it can't be built from source, particularly for those modifying Qemu regularly. In any case, the first change moves to using 'libtool -static' to create libraries on Mac OS X. If one attempts to use ar and ranlib, then the final link will fail with error messages resembling the following: ld: warning: ignoring file libqemuutil.a, file was built for archive which is not the architecture being linked (x86_64): libqemuutil.a Undefined symbols for architecture x86_64: ... Notice ld (Apple's ld64) presumes the static library is a relocatable with architecture 'archive' rather than x86_64, in this case. A similar fix is required for dtc - again quite trivial, but I can provide that if necessary. The second patch removes the preprocessor conditional around the function event_notifier_init_fd() in util/event_notifier-posix.c so that the link does not fail on systems where CONFIG_POSIX is defined but CONFIG_EVENTFD is not (such as under Mac OS X). There is more information in each of the commits that follows. Please feel free to comment. Cheers, C Christopher Friedt (2): Use libtool instead of ar to create static libraries on Darwin. Remove unnecessary CONFIG_EVENTFD preprocessor conditional to satisfy link rules.mak | 4 ++++ util/event_notifier-posix.c | 2 -- 2 files changed, 4 insertions(+), 2 deletions(-) -- 2.6.4 (Apple Git-63) ^ permalink raw reply [flat|nested] 4+ messages in thread
* [Qemu-devel] [PATCH 1/2] [RESENT-INLINE] Use libtool instead of ar to create static libraries on Darwin. 2016-05-03 1:01 [Qemu-devel] [PATCH 0/2][RESENT-INLINE] Resolve link errors on Mac OS X Christopher Friedt @ 2016-05-03 1:01 ` Christopher Friedt 2016-05-03 1:01 ` [Qemu-devel] [PATCH 2/2] [RESENT-INLINE] Remove unnecessary CONFIG_EVENTFD preprocessor conditional to satisfy link Christopher Friedt 1 sibling, 0 replies; 4+ messages in thread From: Christopher Friedt @ 2016-05-03 1:01 UTC (permalink / raw) To: famz, mst; +Cc: Christopher Friedt, qemu-devel, qemu-trivial Currently, at least on Mac OS X 10.11.4 (El Capitan), Qemu fails to build for a few reasons. One of those reasons is that Apple's ld (at least ld64) does not properly process archive files created with ar (even Apple's ar). After some RTFM'ing, I came upon this tidbit, which is unfortunate. Luckily, autotools packages are not broken. "Libtool with -static is intended to replace ar(5) and ranlib." http://www.manpages.info/macosx/libtool.1.html In any case, this change takes Apple's recommendations into account and allows Qemu to build on Mac OS X El Capitan. Signed-off-by: Christopher Friedt <chrisfriedt@gmail.com> --- rules.mak | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/rules.mak b/rules.mak index d1ff311..44421af 100644 --- a/rules.mak +++ b/rules.mak @@ -105,7 +105,11 @@ modules: $(call LINK,$(filter %.o %.a %.mo, $^)) %.a: +ifeq ($(shell uname),Darwin) + $(call quiet-command,rm -f $@ && libtool -static -o $@ $^," libtool $(TARGET_DIR)$@") +else $(call quiet-command,rm -f $@ && $(AR) rcs $@ $^," AR $(TARGET_DIR)$@") +endif quiet-command = $(if $(V),$1,$(if $(2),@echo $2 && $1, @$1)) -- 2.6.4 (Apple Git-63) ^ permalink raw reply related [flat|nested] 4+ messages in thread
* [Qemu-devel] [PATCH 2/2] [RESENT-INLINE] Remove unnecessary CONFIG_EVENTFD preprocessor conditional to satisfy link 2016-05-03 1:01 [Qemu-devel] [PATCH 0/2][RESENT-INLINE] Resolve link errors on Mac OS X Christopher Friedt 2016-05-03 1:01 ` [Qemu-devel] [PATCH 1/2] [RESENT-INLINE] Use libtool instead of ar to create static libraries on Darwin Christopher Friedt @ 2016-05-03 1:01 ` Christopher Friedt 2016-05-03 6:59 ` Markus Armbruster 1 sibling, 1 reply; 4+ messages in thread From: Christopher Friedt @ 2016-05-03 1:01 UTC (permalink / raw) To: famz, mst; +Cc: Christopher Friedt, qemu-devel, qemu-trivial The file ivshmem.c unconditionally references event_notifier_init_fd() in util/event_notifier-posix.c, even if CONFIG_EVENTFD is not defined. On platforms where CONFIG_POSIX is defined, but CONFIG_EVENTFD is not defined, that results in an undefined symbol referenced from ivshmem.c and the link fails. That applies to Mac OS X, but possibly other BSD-based distros. Note: there is nothing specific to eventfd inside and event_notifier_init() also fails unconditionally if CONFIG_EVENTFD is not defined. Signed-off-by: Christopher Friedt <chrisfriedt@gmail.com> --- util/event_notifier-posix.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/util/event_notifier-posix.c b/util/event_notifier-posix.c index c1f0d79..c9bb34d 100644 --- a/util/event_notifier-posix.c +++ b/util/event_notifier-posix.c @@ -21,7 +21,6 @@ #include <sys/eventfd.h> #endif -#ifdef CONFIG_EVENTFD /* * Initialize @e with existing file descriptor @fd. * @fd must be a genuine eventfd object, emulation with pipe won't do. @@ -31,7 +30,6 @@ void event_notifier_init_fd(EventNotifier *e, int fd) e->rfd = fd; e->wfd = fd; } -#endif int event_notifier_init(EventNotifier *e, int active) { -- 2.6.4 (Apple Git-63) ^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH 2/2] [RESENT-INLINE] Remove unnecessary CONFIG_EVENTFD preprocessor conditional to satisfy link 2016-05-03 1:01 ` [Qemu-devel] [PATCH 2/2] [RESENT-INLINE] Remove unnecessary CONFIG_EVENTFD preprocessor conditional to satisfy link Christopher Friedt @ 2016-05-03 6:59 ` Markus Armbruster 0 siblings, 0 replies; 4+ messages in thread From: Markus Armbruster @ 2016-05-03 6:59 UTC (permalink / raw) To: Christopher Friedt; +Cc: famz, mst, qemu-trivial, qemu-devel Christopher Friedt <chrisfriedt@gmail.com> writes: > The file ivshmem.c unconditionally references event_notifier_init_fd() in util/event_notifier-posix.c, even if CONFIG_EVENTFD is not defined. On platforms where CONFIG_POSIX is defined, but CONFIG_EVENTFD is not defined, that results in an undefined symbol referenced from ivshmem.c and the link fails. That applies to Mac OS X, but possibly other BSD-based distros. ivshmem.c cannot work without CONFIG_EVENTFD, and therefore is not compiled without it. A link error for event_notifier_init_fd() from ivshmem.o indicates you got CONFIG_EVENTFD=y for make (since ivshmem.o gets linked), but !defined(CONFIG_EVENTFD) for C (or else event_notifier_init_fd() would exist). Your build tree is messed up, or the makefiles are broken. Try starting over with a fresh build tree. See also http://lists.nongnu.org/archive/html/qemu-devel/2016-04/msg01437.html > Note: there is nothing specific to eventfd inside and event_notifier_init() also fails unconditionally if CONFIG_EVENTFD is not defined. I'm afraid you're misreading the code. event_notifier_init() has a working fallback: if the host doesn't support eventfd (!defined(CONFIG_EVENTFD) or eventfd() fails with ENOSYS), then we emulate eventfd with a pair of pipes. Possible only because pipes have special properties. To support the emulation, we have two file descriptors, @rfd for reading and @wfd for writing. Design invariant: if they are the same file descriptor, it must be a proper eventfd, and if they are different, they must be a pair of pipes. The only way to establish the invariant with event_notifier_init_fd() is passing it an eventfd, as the function's contract says. Without CONFIG_EVENTFD, there is no way to use the function correctly, so defining it would be nothing but a trap. See also commit 330b583, which added the ifdef. > Signed-off-by: Christopher Friedt <chrisfriedt@gmail.com> > --- > util/event_notifier-posix.c | 2 -- > 1 file changed, 2 deletions(-) > > diff --git a/util/event_notifier-posix.c b/util/event_notifier-posix.c > index c1f0d79..c9bb34d 100644 > --- a/util/event_notifier-posix.c > +++ b/util/event_notifier-posix.c > @@ -21,7 +21,6 @@ > #include <sys/eventfd.h> > #endif > > -#ifdef CONFIG_EVENTFD > /* > * Initialize @e with existing file descriptor @fd. > * @fd must be a genuine eventfd object, emulation with pipe won't do. > @@ -31,7 +30,6 @@ void event_notifier_init_fd(EventNotifier *e, int fd) > e->rfd = fd; > e->wfd = fd; > } > -#endif > > int event_notifier_init(EventNotifier *e, int active) > { NAK ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2016-05-03 7:00 UTC | newest] Thread overview: 4+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2016-05-03 1:01 [Qemu-devel] [PATCH 0/2][RESENT-INLINE] Resolve link errors on Mac OS X Christopher Friedt 2016-05-03 1:01 ` [Qemu-devel] [PATCH 1/2] [RESENT-INLINE] Use libtool instead of ar to create static libraries on Darwin Christopher Friedt 2016-05-03 1:01 ` [Qemu-devel] [PATCH 2/2] [RESENT-INLINE] Remove unnecessary CONFIG_EVENTFD preprocessor conditional to satisfy link Christopher Friedt 2016-05-03 6:59 ` Markus Armbruster
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).