Skip to contentSkip to conversation

fix win32 compilation

PATCH In review Paolo Bonzini 2 participants 10 messages Apr 27, 2013 Kbuild

lore
Share & tools
lore
#0 lore raw

v5 cover fix win32 compilation

Here is a fix for the Win32 compilation problem that Blue reported, and another two nits I found while testing. After these patches, a cross libtool is not needed anymore to build on Win32.

Paolo Bonzini (5):
win32: add generic RC rules to rules.mak
win32: move Makefile dependencies on version-obj-y to rules.mak
win32: generate console executable again
add missing inclusions of config-host.h
win32: add readv/writev emulation

 Makefile                    |  5 +----
 Makefile.target             |  2 +-
 include/qemu-common.h       | 22 ++--------------------
 include/qemu/osdep.h        | 16 ++++++++++++++++
 qga/channel-posix.c         |  1 +
 rules.mak                   |  7 +++++++
 tests/libi2c-omap.c         |  1 +
 tests/libqtest.c            |  1 +
 tests/tcg/test-i386-fprem.c |  1 +
 tests/test-mul64.c          |  1 +
 ui/sdl_zoom.c               |  1 +
 ui/vnc.c                    |  1 +
 util/hbitmap.c              |  1 +
 util/iov.c                  |  2 +-
 util/osdep.c                | 43 +++++++++++++++++++++++++++++++++++++++++++
 15 files changed, 79 insertions(+), 26 deletions(-)
Signature · 1 line
1.8.2
#1 lore raw

PATCH v5 1/5 win32: add generic RC rules to rules.mak

---
 Makefile  | 2 --
 rules.mak | 4 ++++
 2 files changed, 4 insertions(+), 2 deletions(-)
Makefile +0 -2
index 8aca92f..58e3527 100644
@@ -167,9 +167,7 @@ recurse-all: $(SUBDIR_RULES) $(ROMSUBDIR_RULES)
 bt-host.o: QEMU_CFLAGS += $(BLUEZ_CFLAGS)
 
 version.o: $(SRC_PATH)/version.rc config-host.h | version.lo
-	$(call quiet-command,$(WINDRES) -I. -o $@ $<,"  RC    $(TARGET_DIR)$@")
 version.lo: $(SRC_PATH)/version.rc config-host.h
-	$(call quiet-command,$(LIBTOOL) --mode=compile --tag=RC $(WINDRES) -I. -o $@ $<,"lt RC   $(TARGET_DIR)$@")
 
 version-obj-$(CONFIG_WIN32) += version.o
 version-lobj-$(CONFIG_WIN32) += $(if $(LIBTOOL),version.lo)
rules.mak +4 -0
index 292a422..279525d 100644
@@ -19,6 +19,8 @@ QEMU_CFLAGS += -I$(<D) -I$(@D)
 
 %.o: %.c
 	$(call quiet-command,$(CC) $(QEMU_INCLUDES) $(QEMU_CFLAGS) $(QEMU_DGFLAGS) $(CFLAGS) -c -o $@ $<,"  CC    $(TARGET_DIR)$@")
+%.o: %.rc
+	$(call quiet-command,$(WINDRES) -I. -o $@ $<,"  RC    $(TARGET_DIR)$@")
 
 ifeq ($(LIBTOOL),)
 LIBTOOL = /bin/false
@@ -29,6 +31,8 @@ else
 LIBTOOL += $(if $(V),,--quiet)
 %.lo: %.c
 	$(call quiet-command,$(LIBTOOL) --mode=compile --tag=CC $(CC) $(QEMU_INCLUDES) $(QEMU_CFLAGS) $(QEMU_DGFLAGS) $(CFLAGS) -c -o $@ $<,"  lt CC $@")
+%.lo: %.rc
+	$(call quiet-command,$(LIBTOOL) --mode=compile --tag=RC $(WINDRES) -I. -o $@ $<,"lt RC   $(TARGET_DIR)$@")
 %.lo: %.dtrace
 	$(call quiet-command,$(LIBTOOL) --mode=compile --tag=CC dtrace -o $@ -G -s $<, " lt GEN $(TARGET_DIR)$@")
 
Signature · 1 line
1.8.2
#2 lore raw

PATCH v5 2/5 win32: move Makefile dependencies on version-obj-y to rules.mak

In reply to Paolo Bonzini

This makes the test on $(LIBTOOL) work. Otherwise, LIBTOOL is /bin/false by the time the test is done.

Fixes Win32 compilation without a working cross-libtool.

---
 Makefile  | 3 +--
 rules.mak | 3 +++
 2 files changed, 4 insertions(+), 2 deletions(-)
Makefile +1 -2
index 58e3527..f91f3b0 100644
@@ -170,8 +170,7 @@ version.o: $(SRC_PATH)/version.rc config-host.h | version.lo
 version.lo: $(SRC_PATH)/version.rc config-host.h
 
 version-obj-$(CONFIG_WIN32) += version.o
-version-lobj-$(CONFIG_WIN32) += $(if $(LIBTOOL),version.lo)
-Makefile: $(version-obj-y) $(version-lobj-y)
+version-lobj-$(CONFIG_WIN32) += version.lo
 
 
 ######################################################################
rules.mak +3 -0
index 279525d..197a9d7 100644
@@ -22,12 +22,15 @@ QEMU_CFLAGS += -I$(<D) -I$(@D)
 %.o: %.rc
 	$(call quiet-command,$(WINDRES) -I. -o $@ $<,"  RC    $(TARGET_DIR)$@")
 
+Makefile: $(version-obj-y)
+
 ifeq ($(LIBTOOL),)
 LIBTOOL = /bin/false
 LINK = $(call quiet-command,$(CC) $(QEMU_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ \
        $(sort $(filter %.o, $1)) $(filter-out %.o, $1) $(version-obj-y) \
        $(LIBS),"  LINK  $(TARGET_DIR)$@")
 else
+Makefile: $(version-lobj-y)
 LIBTOOL += $(if $(V),,--quiet)
 %.lo: %.c
 	$(call quiet-command,$(LIBTOOL) --mode=compile --tag=CC $(CC) $(QEMU_INCLUDES) $(QEMU_CFLAGS) $(QEMU_DGFLAGS) $(CFLAGS) -c -o $@ $<,"  lt CC $@")
Signature · 1 line
1.8.2
#3 lore raw

PATCH v5 3/5 win32: generate console executable again

In reply to Paolo Bonzini

The -mwindows option is not anymore in LIBS at this point of the Makefile, it is only in libs_softmmu. Check the right variable.

---
 Makefile.target | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Makefile.target +1 -1
index 7e4c77a..6583b05 100644
@@ -18,7 +18,7 @@ ifdef CONFIG_USER_ONLY
 QEMU_PROG=qemu-$(TARGET_ARCH2)
 else
 # system emulator name
-ifneq (,$(findstring -mwindows,$(LIBS)))
+ifneq (,$(findstring -mwindows,$(libs_softmmu)))
 # Terminate program name with a 'w' because the linker builds a windows executable.
 QEMU_PROGW=qemu-system-$(TARGET_ARCH2)w$(EXESUF)
 endif # windows executable
Signature · 1 line
1.8.2
#4 lore raw

PATCH v5 4/5 add missing inclusions of config-host.h

In reply to Paolo Bonzini

The next patch will add a dependency of qemu/osdep.h on config-host.h. It could be nicer to use qemu-common.h, but I prefer to be safer this close to hard feature freeze.

---
 qga/channel-posix.c         | 1 +
 tests/libi2c-omap.c         | 1 +
 tests/libqtest.c            | 1 +
 tests/tcg/test-i386-fprem.c | 1 +
 tests/test-mul64.c          | 1 +
 ui/sdl_zoom.c               | 1 +
 ui/vnc.c                    | 1 +
 util/hbitmap.c              | 1 +
 8 files changed, 8 insertions(+)
qga/channel-posix.c +1 -0
index e65dda3..30d978e 100644
@@ -5,6 +5,7 @@
 #include <fcntl.h>
 #include <stdlib.h>
 #include <string.h>
+#include "config-host.h"
 #include "qemu/osdep.h"
 #include "qemu/sockets.h"
 #include "qga/channel.h"
tests/libi2c-omap.c +1 -0
index c52458c..68d40f3 100644
@@ -11,6 +11,7 @@
 #include <glib.h>
 #include <string.h>
 
+#include "config-host.h"
 #include "qemu/osdep.h"
 #include "qemu/bswap.h"
 #include "libqtest.h"
tests/libqtest.c +1 -0
index 884f959..b40269e 100644
@@ -28,6 +28,7 @@
 #include <unistd.h>
 #include <string.h>
 
+#include "config-host.h"
 #include "qemu/compiler.h"
 #include "qemu/osdep.h"
 
tests/tcg/test-i386-fprem.c +1 -0
index e91fb1a..b64e842 100644
@@ -22,6 +22,7 @@
  *  You should have received a copy of the GNU General Public License
  *  along with this program; if not, see <http://www.gnu.org/licenses/>.
  */
+#include "config-host.h"
 #include "qemu/compiler.h"
 #include "qemu/osdep.h"
 #include <stdio.h>
tests/test-mul64.c +1 -0
index a0a17f7..9a6a1ec 100644
@@ -8,6 +8,7 @@
 
 #include <glib.h>
 #include <stdint.h>
+#include "config-host.h"
 #include "qemu/host-utils.h"
 #include "qemu/osdep.h"
 
ui/sdl_zoom.c +1 -0
index 2625c45..b9b7322 100644
@@ -11,6 +11,7 @@
  *
  */
 
+#include "config-host.h"
 #include "sdl_zoom.h"
 #include "qemu/osdep.h"
 #include <glib.h>
ui/vnc.c +1 -0
index 86fe1dd..4216579 100644
@@ -24,6 +24,7 @@
  * THE SOFTWARE.
  */
 
+#include "config-host.h"
 #include "vnc.h"
 #include "vnc-jobs.h"
 #include "sysemu/sysemu.h"
util/hbitmap.c +1 -0
index d936831..fc04d3b 100644
@@ -9,6 +9,7 @@
  * later.  See the COPYING file in the top-level directory.
  */
 
+#include "config-host.h"
 #include <string.h>
 #include <glib.h>
 #include <assert.h>
Signature · 1 line
1.8.2
#5 lore raw

Re: [Qemu-devel] [PATCH 4/5] add missing inclusions of config-host.h

Quoted 3 lines · Paolo Bonzini

The next patch will add a dependency of qemu/osdep.h on config-host.h. It could be nicer to use qemu-common.h, but I prefer to be safer this close to hard feature freeze.

Can't we just include config-host.h from osdep.h ?

-- PMM

#6 lore raw

Re: [Qemu-devel] [PATCH 4/5] add missing inclusions of config-host.h

Il 27/04/2013 15:11, Peter Maydell ha scritto:

Quoted 5 lines · Paolo Bonzini
Quoted 3 lines

The next patch will add a dependency of qemu/osdep.h on config-host.h. It could be nicer to use qemu-common.h, but I prefer to be safer this close to hard feature freeze.

Can't we just include config-host.h from osdep.h ?

Yes, but that is also a bit more risky than I think we can afford at this point.

Paolo

#7 lore raw

Re: [Qemu-devel] [PATCH 4/5] add missing inclusions of config-host.h

Quoted 9 lines · Paolo Bonzini

Il 27/04/2013 15:11, Peter Maydell ha scritto:

Quoted 5 lines · Paolo Bonzini
Quoted 3 lines

The next patch will add a dependency of qemu/osdep.h on config-host.h. It could be nicer to use qemu-common.h, but I prefer to be safer this close to hard feature freeze.

Can't we just include config-host.h from osdep.h ?

Yes, but that is also a bit more risky than I think we can afford at this point.

Not sure I understand where the risk is -- all it does is define a pile of CONFIG_* macros, right?

-- PMM

#8 lore raw

Re: [Qemu-devel] [PATCH 4/5] add missing inclusions of config-host.h

Il 27/04/2013 15:19, Peter Maydell ha scritto:

Quoted 9 lines
Quoted 7 lines
Quoted 7 lines
Quoted 4 lines
Quoted 4 lines
Quoted 3 lines
Quoted 3 lines

The next patch will add a dependency of qemu/osdep.h on config-host.h. It could be nicer to use qemu-common.h, but I prefer to be safer this close to hard feature freeze.

Can't we just include config-host.h from osdep.h ?

Yes, but that is also a bit more risky than I think we can afford at this point.

Not sure I understand where the risk is -- all it does is define a pile of CONFIG_* macros, right?

Yeah, I was unsure about triggering changes in all files that include osdep.h, but there aren't that many actually. Most files get it via qemu-common.h, and qemu-common.h includes config-host.h.

Paolo

#9 lore raw

PATCH v5 5/5 win32: add readv/writev emulation

In reply to Paolo Bonzini

Commit e9d8fbf (qemu-file: do not use stdio for qemu_fdopen, 2013-03-27) introduced a usage of writev, which mingw32 does not have. Even though qemu_fdopen itself is not used on mingw32, the future-proof solution is to add an implementation of it. This is simple and similar to how we emulate sendmsg/recvmsg in util/iov.c.

Some files include osdep.h without qemu-common.h, so move the definition of iovec to osdep.h too, and include osdep.h from qemu-common.h unconditionally (protection against including files when NEED_CPU_H is defined is not needed since the removal of AREG0).

---
 include/qemu-common.h | 22 ++--------------------
 include/qemu/osdep.h  | 16 ++++++++++++++++
 util/iov.c            |  2 +-
 util/osdep.c          | 43 +++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 62 insertions(+), 21 deletions(-)
include/qemu-common.h +2 -20
index a39cdba..b399d85 100644
@@ -84,20 +84,6 @@
 # error Unknown pointer size
 #endif
 
-#ifndef CONFIG_IOVEC
-#define CONFIG_IOVEC
-struct iovec {
-    void *iov_base;
-    size_t iov_len;
-};
-/*
- * Use the same value as Linux for now.
- */
-#define IOV_MAX		1024
-#else
-#include <sys/uio.h>
-#endif
-
 typedef int (*fprintf_function)(FILE *f, const char *fmt, ...)
     GCC_FMT_ATTR(2, 3);
 
@@ -122,16 +108,12 @@ static inline char *realpath(const char *path, char *resolved_path)
 void configure_icount(const char *option);
 extern int use_icount;
 
-/* FIXME: Remove NEED_CPU_H.  */
-#ifndef NEED_CPU_H
-
 #include "qemu/osdep.h"
 #include "qemu/bswap.h"
 
-#else
-
+/* FIXME: Remove NEED_CPU_H.  */
+#ifdef NEED_CPU_H
 #include "cpu.h"
-
 #endif /* !defined(NEED_CPU_H) */
 
 /* main function, renamed */
include/qemu/osdep.h +16 -0
index 8b465fd..9a1b8a3 100644
@@ -161,6 +161,22 @@ int qemu_close(int fd);
 int qemu_create_pidfile(const char *filename);
 int qemu_get_thread_id(void);
 
+#ifndef CONFIG_IOVEC
+struct iovec {
+    void *iov_base;
+    size_t iov_len;
+};
+/*
+ * Use the same value as Linux for now.
+ */
+#define IOV_MAX 1024
+
+ssize_t readv(int fd, const struct iovec *iov, int iov_cnt);
+ssize_t writev(int fd, const struct iovec *iov, int iov_cnt);
+#else
+#include <sys/uio.h>
+#endif
+
 #ifdef _WIN32
 static inline void qemu_timersub(const struct timeval *val1,
                                  const struct timeval *val2,
util/iov.c +1 -1
index d32226d..78bbbe1 100644
@@ -99,7 +99,7 @@ size_t iov_size(const struct iovec *iov, const unsigned int iov_cnt)
 static ssize_t
 do_send_recv(int sockfd, struct iovec *iov, unsigned iov_cnt, bool do_send)
 {
-#if defined CONFIG_IOVEC && defined CONFIG_POSIX
+#ifdef CONFIG_POSIX
     ssize_t ret;
     struct msghdr msg;
     memset(&msg, 0, sizeof(msg));
util/osdep.c +43 -0

46 lines not on this page · raw message

Signature · 1 line
1.8.2