Skip to contentSkip to conversation

Drop --whole-archive and static libraries

PATCH Applied Blue Swirl 7 participants 16 messages Jan 3, 2010 – Mar 8, 2010 1 message not in the archive Kbuild

lore
Share & tools
lore

Blue Swirl

author
#1 lore raw
In reply to a message not in the archive

2009/12/31 Andreas Färber <[email protected]>:

Quoted 12 lines

From: Andreas Färber <[email protected]>

Juan has contributed a cool Makefile infrastructure that enables us to drop static libraries completely:

Move shared obj-y definitions to Makefile.objs, prefixed {common-,hw-,user-}, and link those object files directly into the executables.

Replace HWLIB by HWDIR, specifying only the directory.

Drop --whole-archive and ARLIBS in Makefiles and configure.

Quoted 8 lines

Drop GENERATED_HEADERS dependency in rules.mak, since this rebuilds all common objects after generating a target-specific header; add dependency rules to Makefile and Makefile.target instead.

v2:
- Don't try to include /config.mak for user emulators
- Changes to user object paths ("Quickfix for libuser.a drop") were obsoleted by "user_only: compile everything with -fpie" (Kirill A. Shutemov)

Breaks build:
CC i386-softmmu/i386-dis.o
make[1]: *** No rule to make target /loader.o', needed by qemu'. Stop.

#16 lore raw
In reply to a message not in the archive
Quoted 5 lines · Andreas F?rber

v2:
- Don't try to include /config.mak for user emulators
- Changes to user object paths ("Quickfix for libuser.a drop") were obsoleted by "user_only: compile everything with -fpie" (Kirill A. Shutemov)

Hi,

I have succesfully used the v2 patch on my OpenSolaris/SPARC host and it seems to fix the Solaris linking issue.

/Palle

author
#2 lore raw
In reply to Blue Swirl
Quoted 17 lines · Blue Swirl

2009/12/31 Andreas Färber <[email protected]>:

Quoted 16 lines

From: Andreas Färber <[email protected]>

Juan has contributed a cool Makefile infrastructure that enables us to drop static libraries completely:

Move shared obj-y definitions to Makefile.objs, prefixed {common-,hw-,user-}, and link those object files directly into the executables.

Replace HWLIB by HWDIR, specifying only the directory.

Drop --whole-archive and ARLIBS in Makefiles and configure.

Drop GENERATED_HEADERS dependency in rules.mak, since this rebuilds all common objects after generating a target-specific header; add dependency rules to Makefile and Makefile.target instead.

Quoted 8 lines
Quoted 4 lines

v2:
- Don't try to include /config.mak for user emulators
- Changes to user object paths ("Quickfix for libuser.a drop") were obsoleted by "user_only: compile everything with -fpie" (Kirill A. Shutemov)

Breaks build:
 CC    i386-softmmu/i386-dis.o
make[1]: *** No rule to make target /loader.o', needed by qemu'.  Stop.

I found out that completely removing the object directory and recreating it from scratch helps. This sucks bisectability-wise, is there any way to avoid it?

There is still one problem, tools need config-host.h but the dependencies are not correct:
CC qemu-nbd.o
In file included from /src/qemu/qemu-nbd.c:19:
/src/qemu/qemu-common.h:32:25: error: config-host.h: No such file or directory

#3 lore raw

Am 04.01.2010 um 21:47 schrieb Blue Swirl:

Quoted 24 lines · Blue Swirl
Quoted 23 lines

2009/12/31 Andreas Färber <[email protected]>:

Quoted 21 lines

From: Andreas Färber <[email protected]>

Juan has contributed a cool Makefile infrastructure that enables us to drop static libraries completely:

Move shared obj-y definitions to Makefile.objs, prefixed {common-,hw-,user-}, and link those object files directly into the executables.

Replace HWLIB by HWDIR, specifying only the directory.

Drop --whole-archive and ARLIBS in Makefiles and configure.

Drop GENERATED_HEADERS dependency in rules.mak, since this rebuilds all common objects after generating a target-specific header; add dependency rules to Makefile and Makefile.target instead.

v2:
- Don't try to include /config.mak for user emulators
- Changes to user object paths ("Quickfix for libuser.a drop") were obsoleted
by "user_only: compile everything with -fpie" (Kirill A. Shutemov)

Quoted 7 lines
Quoted 3 lines

Breaks build:
CC i386-softmmu/i386-dis.o
make[1]: *** No rule to make target /loader.o', needed by qemu'. Stop.

I found out that completely removing the object directory and recreating it from scratch helps. This sucks bisectability-wise, is there any way to avoid it?

Sounds as if configure was not re-run and thus $(HWDIR) not set in config-target.mak. No idea why, more likely a general issue. Do you have a way to reproduce? What about make clean or make distclean?

Quoted 5 lines

There is still one problem, tools need config-host.h but the dependencies are not correct:
CC qemu-nbd.o
In file included from /src/qemu/qemu-nbd.c:19:
/src/qemu/qemu-common.h:32:25: error: config-host.h: No such file or directory

Fix coming up. Basically, $(GENERATED_HEADERS) were previously used on _all_ object files via rules.mak. That does not work when referencing objects from another Makefile, so the modelling needs to be done explicitly.

Andreas

#4 lore raw

PATCH v3 1/1 Drop --whole-archive and static libraries

From: Andreas Färber <[email protected]>

Juan has contributed a cool Makefile infrastructure that enables us to drop static libraries completely:

Move shared obj-y definitions to Makefile.objs, prefixed {common-,hw-,user-}, and link those object files directly into the executables.

Replace HWLIB by HWDIR, specifying only the directory.

Drop --whole-archive and ARLIBS in Makefiles and configure.

Drop GENERATED_HEADERS dependency in rules.mak, since this rebuilds all common objects after generating a target-specific header; add dependency rules to Makefile and Makefile.target instead.

v2:
- Don't try to include /config.mak for user emulators
- Changes to user object paths ("Quickfix for libuser.a drop") were obsoleted by "user_only: compile everything with -fpie" (Kirill A. Shutemov)

v3:
- Fix dependency modelling for tools
- Remove comment on GENERATED_HEADERS obsoleted by this patch

Cc Blue Swirl <[email protected]>
Cc Palle Lyckegaard <[email protected]>
Cc Ben Taylor <[email protected]>
Cc Juan Quintela <[email protected]>
Cc Kirill A. Shutemov <[email protected]>
Cc Paolo Bonzini <[email protected]>
---
 Makefile        |  138 +++++-------------------------------------------
 Makefile.hw     |   33 +-----------
 Makefile.objs   |  155 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 Makefile.target |   33 +++++++++---
 Makefile.user   |    9 +---
 configure       |   34 +------------
 rules.mak       |    4 +-
 7 files changed, 202 insertions(+), 204 deletions(-)
 create mode 100644 Makefile.objs
Makefile +15 -123
index c1fa08c..2ca341b 100644
@@ -1,6 +1,5 @@
 # Makefile for QEMU.
 
-# This needs to be defined before rules.mak
 GENERATED_HEADERS = config-host.h
 
 ifneq ($(wildcard config-host.mak),)
@@ -66,7 +65,10 @@ SUBDIR_RULES=$(patsubst %,subdir-%, $(TARGET_DIRS))
 subdir-%: $(GENERATED_HEADERS)
 	$(call quiet-command,$(MAKE) $(SUBDIR_MAKEFLAGS) -C $* V="$(V)" TARGET_DIR="$*/" all,)
 
-$(filter %-softmmu,$(SUBDIR_RULES)): libqemu_common.a
+include $(SRC_PATH)/Makefile.objs
+
+$(common-obj-y): $(GENERATED_HEADERS)
+$(filter %-softmmu,$(SUBDIR_RULES)): $(common-obj-y)
 
 $(filter %-user,$(SUBDIR_RULES)): libuser.a
 
@@ -81,124 +83,8 @@ ALL_SUBDIRS=$(TARGET_DIRS) $(patsubst %,pc-bios/%, $(ROMS))
 
 recurse-all: $(SUBDIR_RULES) $(ROMSUBDIR_RULES)
 
-#######################################################################
-# QObject
-qobject-obj-y = qint.o qstring.o qdict.o qlist.o qfloat.o qbool.o
-qobject-obj-y += qjson.o json-lexer.o json-streamer.o json-parser.o
-qobject-obj-y += qerror.o
-
-#######################################################################
-# block-obj-y is code used by both qemu system emulation and qemu-img
-
-block-obj-y = cutils.o cache-utils.o qemu-malloc.o qemu-option.o module.o
-block-obj-y += nbd.o block.o aio.o aes.o osdep.o
-block-obj-$(CONFIG_POSIX) += posix-aio-compat.o
-block-obj-$(CONFIG_LINUX_AIO) += linux-aio.o
-
-block-nested-y += cow.o qcow.o vdi.o vmdk.o cloop.o dmg.o bochs.o vpc.o vvfat.o
-block-nested-y += qcow2.o qcow2-refcount.o qcow2-cluster.o qcow2-snapshot.o
-block-nested-y += parallels.o nbd.o
-block-nested-$(CONFIG_WIN32) += raw-win32.o
-block-nested-$(CONFIG_POSIX) += raw-posix.o
-block-nested-$(CONFIG_CURL) += curl.o
-
-block-obj-y +=  $(addprefix block/, $(block-nested-y))
-
-net-obj-y = net.o
-net-nested-y = queue.o checksum.o util.o
-net-nested-y += socket.o
-net-nested-y += dump.o
-net-nested-$(CONFIG_POSIX) += tap.o
-net-nested-$(CONFIG_LINUX) += tap-linux.o
-net-nested-$(CONFIG_WIN32) += tap-win32.o
-net-nested-$(CONFIG_BSD) += tap-bsd.o
-net-nested-$(CONFIG_SOLARIS) += tap-solaris.o
-net-nested-$(CONFIG_AIX) += tap-aix.o
-net-nested-$(CONFIG_SLIRP) += slirp.o
-net-nested-$(CONFIG_VDE) += vde.o
-net-obj-y += $(addprefix net/, $(net-nested-y))
-
-######################################################################
-# libqemu_common.a: Target independent part of system emulation. The
-# long term path is to suppress *all* target specific code in case of
-# system emulation, i.e. a single QEMU executable should support all
-# CPUs and machines.
-
-obj-y = $(block-obj-y)
-obj-y += $(net-obj-y)
-obj-y += $(qobject-obj-y)
-obj-y += readline.o console.o
-
-obj-y += tcg-runtime.o host-utils.o
-obj-y += irq.o ioport.o
-obj-$(CONFIG_PTIMER) += ptimer.o
-obj-$(CONFIG_MAX7310) += max7310.o
-obj-$(CONFIG_WM8750) += wm8750.o
-obj-$(CONFIG_TWL92230) += twl92230.o
-obj-$(CONFIG_TSC2005) += tsc2005.o
-obj-$(CONFIG_LM832X) += lm832x.o
-obj-$(CONFIG_TMP105) += tmp105.o
-obj-$(CONFIG_STELLARIS_INPUT) += stellaris_input.o
-obj-$(CONFIG_SSD0303) += ssd0303.o
-obj-$(CONFIG_SSD0323) += ssd0323.o
-obj-$(CONFIG_ADS7846) += ads7846.o
-obj-$(CONFIG_MAX111X) += max111x.o
-obj-$(CONFIG_DS1338) += ds1338.o
-obj-y += i2c.o smbus.o smbus_eeprom.o
-obj-y += eeprom93xx.o
-obj-y += scsi-disk.o cdrom.o
-obj-y += scsi-generic.o scsi-bus.o
-obj-y += usb.o usb-hub.o usb-$(HOST_USB).o usb-hid.o usb-msd.o usb-wacom.o
-obj-y += usb-serial.o usb-net.o usb-bus.o
-obj-$(CONFIG_SSI) += ssi.o
-obj-$(CONFIG_SSI_SD) += ssi-sd.o
-obj-$(CONFIG_SD) += sd.o
-obj-y += bt.o bt-host.o bt-vhci.o bt-l2cap.o bt-sdp.o bt-hci.o bt-hid.o usb-bt.o
-obj-y += bt-hci-csr.o
-obj-y += buffered_file.o migration.o migration-tcp.o qemu-sockets.o
-obj-y += qemu-char.o aio.o savevm.o
-obj-y += msmouse.o ps2.o
-obj-y += qdev.o qdev-properties.o
-obj-y += qemu-config.o block-migration.o
-
-obj-$(CONFIG_BRLAPI) += baum.o
-obj-$(CONFIG_POSIX) += migration-exec.o migration-unix.o migration-fd.o
-
 audio/audio.o audio/fmodaudio.o: QEMU_CFLAGS += $(FMOD_CFLAGS)
 
-audio-obj-y = audio.o noaudio.o wavaudio.o mixeng.o
-audio-obj-$(CONFIG_SDL) += sdlaudio.o
-audio-obj-$(CONFIG_OSS) += ossaudio.o
-audio-obj-$(CONFIG_COREAUDIO) += coreaudio.o
-audio-obj-$(CONFIG_ALSA) += alsaaudio.o
-audio-obj-$(CONFIG_DSOUND) += dsoundaudio.o
-audio-obj-$(CONFIG_FMOD) += fmodaudio.o
-audio-obj-$(CONFIG_ESD) += esdaudio.o
-audio-obj-$(CONFIG_PA) += paaudio.o
-audio-obj-$(CONFIG_WINWAVE) += winwaveaudio.o
-audio-obj-$(CONFIG_AUDIO_PT_INT) += audio_pt_int.o
-audio-obj-$(CONFIG_AUDIO_WIN_INT) += audio_win_int.o
-audio-obj-y += wavcapture.o
-obj-y += $(addprefix audio/, $(audio-obj-y))
-
-obj-y += keymaps.o
-obj-$(CONFIG_SDL) += sdl.o sdl_zoom.o x_keymap.o
-obj-$(CONFIG_CURSES) += curses.o
-obj-y += vnc.o acl.o d3des.o
-obj-$(CONFIG_VNC_TLS) += vnc-tls.o vnc-auth-vencrypt.o
-obj-$(CONFIG_VNC_SASL) += vnc-auth-sasl.o
-obj-$(CONFIG_COCOA) += cocoa.o
-obj-$(CONFIG_IOTHREAD) += qemu-thread.o
-
-slirp-obj-y = cksum.o if.o ip_icmp.o ip_input.o ip_output.o
-slirp-obj-y += slirp.o mbuf.o misc.o sbuf.o socket.o tcp_input.o tcp_output.o
-slirp-obj-y += tcp_subr.o tcp_timer.o udp.o bootp.o tftp.o
-obj-$(CONFIG_SLIRP) += $(addprefix slirp/, $(slirp-obj-y))
-
-# xen backend driver support
-obj-$(CONFIG_XEN) += xen_backend.o xen_devconfig.o
-obj-$(CONFIG_XEN) += xen_console.o xenfb.o xen_disk.o xen_nic.o
-
 QEMU_CFLAGS+=$(CURL_CFLAGS)
 
 cocoa.o: cocoa.m
@@ -229,17 +115,23 @@ curses.o: curses.c keymaps.h curses_keys.h
 
 bt-host.o: QEMU_CFLAGS += $(BLUEZ_CFLAGS)
 
-libqemu_common.a: $(obj-y)
-
 ######################################################################
 
 qemu-img.o: qemu-img-cmds.h
 
-qemu-img$(EXESUF): qemu-img.o qemu-tool.o $(block-obj-y) $(qobject-obj-y)
+obj-y = qemu-img.o qemu-tool.o $(block-obj-y) $(qobject-obj-y)
+
+qemu-img$(EXESUF): $(obj-y)
+
+obj-y = qemu-nbd.o qemu-tool.o $(block-obj-y) $(qobject-obj-y)
+$(obj-y): $(GENERATED_HEADERS)
+
+qemu-nbd$(EXESUF): $(obj-y)
 
-qemu-nbd$(EXESUF):  qemu-nbd.o qemu-tool.o $(block-obj-y) $(qobject-obj-y)
+obj-y = qemu-io.o qemu-tool.o cmd.o $(block-obj-y) $(qobject-obj-y)
+$(obj-y): $(GENERATED_HEADERS)
 
-qemu-io$(EXESUF):  qemu-io.o qemu-tool.o cmd.o $(block-obj-y) $(qobject-obj-y)
+qemu-io$(EXESUF): $(obj-y)
 
 qemu-img-cmds.h: $(SRC_PATH)/qemu-img-cmds.hx
 	$(call quiet-command,sh $(SRC_PATH)/hxtool -h < $< > $@,"  GEN   $@")
Makefile.hw +2 -31
index bd252f5..ff87ae4 100644
@@ -11,41 +11,12 @@ VPATH=$(SRC_PATH):$(SRC_PATH)/hw
 
 QEMU_CFLAGS+=-I.. -I$(SRC_PATH)/fpu
 
-obj-y =
-obj-y += loader.o
-obj-y += virtio.o
-obj-y += fw_cfg.o
-obj-y += watchdog.o
-obj-$(CONFIG_ECC) += ecc.o
-obj-$(CONFIG_NAND) += nand.o
+include $(SRC_PATH)/Makefile.objs
 
-obj-$(CONFIG_M48T59) += m48t59.o
-obj-$(CONFIG_ESCC) += escc.o
-
-# PCI watchdog devices
-obj-y += wdt_i6300esb.o
-
-obj-y += msix.o
-
-# PCI network cards
-obj-y += ne2000.o
-
-obj-$(CONFIG_SMC91C111) += smc91c111.o
-obj-$(CONFIG_LAN9118) += lan9118.o
-
-# SCSI layer
-obj-y += lsi53c895a.o
-obj-$(CONFIG_ESP) += esp.o
-
-obj-y += dma-helpers.o sysbus.o isa-bus.o
-obj-$(CONFIG_QDEV_ADDR) += qdev-addr.o
-
-all: $(HWLIB)
+all: $(hw-obj-y)
 # Dummy command so that make thinks it has done something
 	@true
 
-$(HWLIB): $(obj-y)
-
 clean:
 	rm -f *.o *.d *.a *~
 
Makefile.objs new file +155 -0

155 lines not on this page · raw message

Makefile.target +25 -8
index 7c1f30c..543e8cd 100644
@@ -1,17 +1,21 @@
 # -*- Mode: makefile -*-
 
-# This needs to be defined before rules.mak
 GENERATED_HEADERS = config-target.h
 
 include ../config-host.mak
 include config-devices.mak
 include config-target.mak
 include $(SRC_PATH)/rules.mak
+ifneq ($(HWDIR),)
+include $(HWDIR)/config.mak
+endif
 
 TARGET_PATH=$(SRC_PATH)/target-$(TARGET_BASE_ARCH)
 VPATH=$(SRC_PATH):$(TARGET_PATH):$(SRC_PATH)/hw
 QEMU_CFLAGS+= -I.. -I$(TARGET_PATH) -DNEED_CPU_H
 
+include $(SRC_PATH)/Makefile.objs
+
 ifdef CONFIG_USER_ONLY
 # user emulator name
 QEMU_PROG=qemu-$(TARGET_ARCH2)
@@ -64,9 +68,9 @@ libobj-$(CONFIG_S390_DIS) += s390-dis.o
 libobj-$(CONFIG_SH4_DIS) += sh4-dis.o
 libobj-$(CONFIG_SPARC_DIS) += sparc-dis.o
 
-# libqemu
+$(libobj-y): $(GENERATED_HEADERS)
 
-libqemu.a: $(libobj-y)
+# libqemu
 
 translate.o: translate.c cpu.h
 
@@ -106,7 +110,10 @@ obj-arm-y += arm-semi.o
 
 obj-m68k-y += m68k-sim.o m68k-semi.o
 
-ARLIBS=../libuser/libuser.a libqemu.a
+$(obj-y) $(obj-$(TARGET_BASE_ARCH)-y): $(GENERATED_HEADERS)
+
+obj-y += $(addprefix ../libuser/, $(user-obj-y))
+obj-y += $(libobj-y)
 
 endif #CONFIG_LINUX_USER
 
@@ -128,7 +135,10 @@ obj-y = main.o commpage.o machload.o mmap.o signal.o syscall.o thunk.o \
 
 obj-i386-y += ioport-user.o
 
-ARLIBS=../libuser/libuser.a libqemu.a
+$(obj-y) $(obj-$(TARGET_BASE_ARCH)-y): $(GENERATED_HEADERS)
+
+obj-y += $(addprefix ../libuser/, $(user-obj-y))
+obj-y += $(libobj-y)
 
 endif #CONFIG_DARWIN_USER
 
@@ -145,7 +155,10 @@ obj-y = main.o bsdload.o elfload.o mmap.o signal.o strace.o syscall.o \
 
 obj-i386-y += ioport-user.o
 
-ARLIBS=../libuser/libuser.a libqemu.a
+$(obj-y) $(obj-$(TARGET_BASE_ARCH)-y): $(GENERATED_HEADERS)
+
+obj-y += $(addprefix ../libuser/, $(user-obj-y))
+obj-y += $(libobj-y)
 
 endif #CONFIG_BSD_USER
 
@@ -303,13 +316,17 @@ vl.o: qemu-options.h
 
 monitor.o: qemu-monitor.h
 
-ARLIBS=../libqemu_common.a libqemu.a $(HWLIB)
+$(obj-y) $(obj-$(TARGET_BASE_ARCH)-y): $(GENERATED_HEADERS)
+
+obj-y += $(addprefix ../, $(common-obj-y))
+obj-y += $(libobj-y)
+obj-y += $(addprefix $(HWDIR)/, $(hw-obj-y))
 
 endif # CONFIG_SOFTMMU
 
 obj-$(CONFIG_GDBSTUB_XML) += gdbstub-xml.o
 
-$(QEMU_PROG): $(obj-y) $(obj-$(TARGET_BASE_ARCH)-y) $(ARLIBS)
+$(QEMU_PROG): $(obj-y) $(obj-$(TARGET_BASE_ARCH)-y)
 	$(call LINK,$(obj-y) $(obj-$(TARGET_BASE_ARCH)-y))
 
 
Makefile.user +2 -7
index 7daedef..c6ac509 100644
@@ -14,17 +14,12 @@ vpath %.c %.h $(SRC_PATH)
 
 QEMU_CFLAGS+=-I..
 
-obj-y =
-obj-y += envlist.o path.o
-obj-y += tcg-runtime.o host-utils.o
-obj-y += cutils.o cache-utils.o
+include $(SRC_PATH)/Makefile.objs
 
-all: libuser.a
+all: $(user-obj-y)
 # Dummy command so that make thinks it has done something
 	@true
 
-libuser.a: $(obj-y)
-
 clean:
 	rm -f *.o *.d *.a *~
 
configure +1 -33
index 18aed43..1e9dd04 100755
@@ -1707,37 +1707,6 @@ elif compile_prog "" "-lrt" ; then
   LIBS="-lrt $LIBS"
 fi
 
-# Determine what linker flags to use to force archive inclusion
-check_linker_flags()
-{
-    w2=
-    if test "$2" ; then
-	w2=-Wl,$2
-    fi
-    compile_prog "" "-Wl,$1 ${w2}"
-}
-
-cat > $TMPC << EOF
-int main(void) { }
-EOF
-if check_linker_flags --whole-archive --no-whole-archive ; then
-    # GNU ld
-    arlibs_begin="-Wl,--whole-archive"
-    arlibs_end="-Wl,--no-whole-archive"
-elif check_linker_flags -z,allextract -z,defaultextract ; then
-    # Solaris ld
-    arlibs_begin="-Wl,-z,allextract"
-    arlibs_end="-Wl,-z,defaultextract"
-elif check_linker_flags -all_load ; then
-    # Mac OS X
-    arlibs_begin="-all_load"
-    arlibs_end=""
-else
-    echo "Error: your linker does not support --whole-archive or -z."
-    echo "Please report to [email protected]"
-    exit 1
-fi
-
 if test "$darwin" != "yes" -a "$mingw32" != "yes" -a "$solaris" != yes -a \
         "$aix" != "yes" ; then
     libs_softmmu="-lutil $libs_softmmu"
@@ -2427,7 +2396,7 @@ fi
 if test "$target_softmmu" = "yes" ; then
   echo "CONFIG_SOFTMMU=y" >> $config_target_mak
   echo "LIBS+=$libs_softmmu" >> $config_target_mak
-  echo "HWLIB=../libhw$target_phys_bits/libqemuhw$target_phys_bits.a" >> $config_target_mak
+  echo "HWDIR=../libhw$target_phys_bits" >> $config_target_mak
   echo "subdir-$target: subdir-libhw$target_phys_bits" >> $config_host_mak
 fi
 if test "$target_user_only" = "yes" ; then
@@ -2644,7 +2613,6 @@ for hwlib in 32 64; do
   mkdir -p $d
   rm -f $d/Makefile
   ln -s $source_path/Makefile.hw $d/Makefile
-  echo "HWLIB=libqemuhw$hwlib.a" > $d/config.mak
   echo "QEMU_CFLAGS+=-DTARGET_PHYS_ADDR_BITS=$hwlib" >> $d/config.mak
 done
 
rules.mak +2 -2
index 5d9f684..9bcf9af 100644
@@ -14,7 +14,7 @@ MAKEFLAGS += -rR
 # Flags for dependency generation
 QEMU_DGFLAGS += -MMD -MP -MT $@
 
-%.o: %.c $(GENERATED_HEADERS)
+%.o: %.c
 	$(call quiet-command,$(CC) $(QEMU_CFLAGS) $(QEMU_DGFLAGS) $(CFLAGS) -c -o $@ $<,"  CC    $(TARGET_DIR)$@")
 
 %.o: %.S
@@ -23,7 +23,7 @@ QEMU_DGFLAGS += -MMD -MP -MT $@
 %.o: %.m
 	$(call quiet-command,$(CC) $(QEMU_CFLAGS) $(QEMU_DGFLAGS) $(CFLAGS) -c -o $@ $<,"  OBJC  $(TARGET_DIR)$@")
 
-LINK = $(call quiet-command,$(CC) $(QEMU_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ $(1) $(ARLIBS_BEGIN) $(ARLIBS) $(ARLIBS_END) $(LIBS),"  LINK  $(TARGET_DIR)$@")
+LINK = $(call quiet-command,$(CC) $(QEMU_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ $(1) $(LIBS),"  LINK  $(TARGET_DIR)$@")
 
 %$(EXESUF): %.o
 	$(call LINK,$^)
Signature · 1 line
1.6.5.3
author
#13 lore raw
In reply to Andreas Färber
Quoted 35 lines · Andreas Färber

Am 04.01.2010 um 21:47 schrieb Blue Swirl:

Quoted 32 lines · Blue Swirl
Quoted 30 lines

2009/12/31 Andreas Färber <[email protected]>:

Quoted 19 lines

From: Andreas Färber <[email protected]>

Juan has contributed a cool Makefile infrastructure that enables us to drop
static libraries completely:

Move shared obj-y definitions to Makefile.objs, prefixed {common-,hw-,user-},
and link those object files directly into the executables.

Replace HWLIB by HWDIR, specifying only the directory.

Drop --whole-archive and ARLIBS in Makefiles and configure.

Drop GENERATED_HEADERS dependency in rules.mak, since this rebuilds all common objects after generating a target-specific header; add dependency rules to Makefile and Makefile.target instead.

Quoted 5 lines

v2:
- Don't try to include /config.mak for user emulators
- Changes to user object paths ("Quickfix for libuser.a drop") were obsoleted
 by "user_only: compile everything with -fpie" (Kirill A. Shutemov)

Breaks build:
 CC    i386-softmmu/i386-dis.o
make[1]: *** No rule to make target /loader.o', needed by qemu'.  Stop.

Quoted 7 lines
Quoted 3 lines

I found out that completely removing the object directory and recreating it from scratch helps. This sucks bisectability-wise, is there any way to avoid it?

Sounds as if configure was not re-run and thus $(HWDIR) not set in config-target.mak. No idea why, more likely a general issue.
Do you have a way to reproduce? What about make clean or make distclean?

Strange, now that I try to reproduce it with a new directory, everything works. Also my normal compile directory does not show the problem anymore. Maybe there were some old files lying around.

Quoted 10 lines
Quoted 6 lines

There is still one problem, tools need config-host.h but the dependencies are not correct:
 CC    qemu-nbd.o
In file included from /src/qemu/qemu-nbd.c:19:
/src/qemu/qemu-common.h:32:25: error: config-host.h: No such file or directory

Fix coming up. Basically, $(GENERATED_HEADERS) were previously used on _all_ object files via rules.mak. That does not work when referencing objects from another Makefile, so the modelling needs to be done explicitly.

OK. Since there have been no objections, I'd like to apply this soon.

#14 lore raw

Am 06.01.2010 um 20:24 schrieb Blue Swirl:

Quoted 41 lines · Andreas Färber
Quoted 40 lines

Am 04.01.2010 um 21:47 schrieb Blue Swirl:

Quoted 36 lines · Blue Swirl
Quoted 28 lines

2009/12/31 Andreas Färber <[email protected]>:

Quoted 26 lines

From: Andreas Färber <[email protected]>

Juan has contributed a cool Makefile infrastructure that enables us to drop
static libraries completely:

Move shared obj-y definitions to Makefile.objs, prefixed {common-,hw-,user-},
and link those object files directly into the executables.

Replace HWLIB by HWDIR, specifying only the directory.

Drop --whole-archive and ARLIBS in Makefiles and configure.

Drop GENERATED_HEADERS dependency in rules.mak, since this rebuilds all common objects after generating a target-specific header; add dependency rules to Makefile and Makefile.target instead.

v2:
- Don't try to include /config.mak for user emulators
- Changes to user object paths ("Quickfix for libuser.a drop") were
obsoleted
by "user_only: compile everything with -fpie" (Kirill A.
Shutemov)

There is still one problem, tools need config-host.h but the dependencies are not correct:
CC qemu-nbd.o
In file included from /src/qemu/qemu-nbd.c:19:
/src/qemu/qemu-common.h:32:25: error: config-host.h: No such file or directory

Quoted 5 lines
Quoted 3 lines

Fix coming up. Basically, $(GENERATED_HEADERS) were previously used on _all_ object files via rules.mak. That does not work when referencing objects from another Makefile, so the modelling needs to be done explicitly.

OK. Since there have been no objections, I'd like to apply this soon.

That would be very much appreciated.

I have not tested bsd-user. Could you please check that on your BSD setup?

Thanks,

Andreas

author
#15 lore raw
Quoted 52 lines · Andreas Färber

Am 06.01.2010 um 20:24 schrieb Blue Swirl:

Quoted 49 lines
Quoted 46 lines · Andreas Färber

Am 04.01.2010 um 21:47 schrieb Blue Swirl:

Quoted 31 lines
Quoted 28 lines · Blue Swirl

2009/12/31 Andreas Färber <[email protected]>:

Quoted 26 lines

From: Andreas Färber <[email protected]>

Juan has contributed a cool Makefile infrastructure that enables us to drop
static libraries completely:

Move shared obj-y definitions to Makefile.objs, prefixed {common-,hw-,user-},
and link those object files directly into the executables.

Replace HWLIB by HWDIR, specifying only the directory.

Drop --whole-archive and ARLIBS in Makefiles and configure.

Drop GENERATED_HEADERS dependency in rules.mak, since this rebuilds all
common objects after generating a target-specific header; add dependency
rules to Makefile and Makefile.target instead.

v2:
- Don't try to include /config.mak for user emulators
- Changes to user object paths ("Quickfix for libuser.a drop") were obsoleted
 by "user_only: compile everything with -fpie" (Kirill A. Shutemov)

Quoted 6 lines

There is still one problem, tools need config-host.h but the dependencies are not correct:
 CC    qemu-nbd.o
In file included from /src/qemu/qemu-nbd.c:19:
/src/qemu/qemu-common.h:32:25: error: config-host.h: No such file or directory

Fix coming up. Basically, $(GENERATED_HEADERS) were previously used on _all_
object files via rules.mak. That does not work when referencing objects from
another Makefile, so the modelling needs to be done explicitly.

Quoted 5 lines
Quoted 1 line

OK. Since there have been no objections, I'd like to apply this soon.

That would be very much appreciated.

I have not tested bsd-user. Could you please check that on your BSD setup?

Seems to work, as do Milax and mingw32.

author Applied
#5 lore raw
In reply to Andreas Färber

Thanks, applied.

Quoted 633 lines · Andreas Färber

From: Andreas Färber <[email protected]>

Juan has contributed a cool Makefile infrastructure that enables us to drop static libraries completely:

Move shared obj-y definitions to Makefile.objs, prefixed {common-,hw-,user-}, and link those object files directly into the executables.

Replace HWLIB by HWDIR, specifying only the directory.

Drop --whole-archive and ARLIBS in Makefiles and configure.

Drop GENERATED_HEADERS dependency in rules.mak, since this rebuilds all common objects after generating a target-specific header; add dependency rules to Makefile and Makefile.target instead.

v2:
- Don't try to include /config.mak for user emulators
- Changes to user object paths ("Quickfix for libuser.a drop") were obsoleted by "user_only: compile everything with -fpie" (Kirill A. Shutemov)

v3:
- Fix dependency modelling for tools
- Remove comment on GENERATED_HEADERS obsoleted by this patch

Cc Blue Swirl <[email protected]>
Cc Palle Lyckegaard <[email protected]>
Cc Ben Taylor <[email protected]>
Cc Juan Quintela <[email protected]>
Cc Kirill A. Shutemov <[email protected]>
Cc Paolo Bonzini <[email protected]>

---
 Makefile        |  138 +++++------------------------------------------- Makefile.hw     |   33 +-----------
 Makefile.objs   |  155 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ Makefile.target |   33 +++++++++---
 Makefile.user   |    9 +---
 configure       |   34 +------------
 rules.mak       |    4 +-

 7 files changed, 202 insertions(+), 204 deletions(-)

 create mode 100644 Makefile.objs

Makefile +0 -1
index c1fa08c..2ca341b 100644
@@ -1,6 +1,5 @@
  # Makefile for QEMU.
 
-# This needs to be defined before rules.mak

 GENERATED_HEADERS = config-host.h

 ifneq ($(wildcard config-host.mak),)

Makefile +4 -1
@@ -66,7 +65,10 @@ SUBDIR_RULES=$(patsubst %,subdir-%, $(TARGET_DIRS))
  subdir-%: $(GENERATED_HEADERS)
        $(call quiet-command,$(MAKE) $(SUBDIR_MAKEFLAGS) -C $* V="$(V)" TARGET_DIR="$*/" all,)
 
-$(filter %-softmmu,$(SUBDIR_RULES)): libqemu_common.a
+include $(SRC_PATH)/Makefile.objs
+
+$(common-obj-y): $(GENERATED_HEADERS)
+$(filter %-softmmu,$(SUBDIR_RULES)): $(common-obj-y)
 

 $(filter %-user,$(SUBDIR_RULES)): libuser.a

Makefile +0 -116
@@ -81,124 +83,8 @@ ALL_SUBDIRS=$(TARGET_DIRS) $(patsubst %,pc-bios/%, $(ROMS))
 
  recurse-all: $(SUBDIR_RULES) $(ROMSUBDIR_RULES)
 
-#######################################################################
-# QObject
-qobject-obj-y = qint.o qstring.o qdict.o qlist.o qfloat.o qbool.o
-qobject-obj-y += qjson.o json-lexer.o json-streamer.o json-parser.o
-qobject-obj-y += qerror.o
-
-#######################################################################
-# block-obj-y is code used by both qemu system emulation and qemu-img
-
-block-obj-y = cutils.o cache-utils.o qemu-malloc.o qemu-option.o module.o
-block-obj-y += nbd.o block.o aio.o aes.o osdep.o
-block-obj-$(CONFIG_POSIX) += posix-aio-compat.o
-block-obj-$(CONFIG_LINUX_AIO) += linux-aio.o
-
-block-nested-y += cow.o qcow.o vdi.o vmdk.o cloop.o dmg.o bochs.o vpc.o vvfat.o
-block-nested-y += qcow2.o qcow2-refcount.o qcow2-cluster.o qcow2-snapshot.o
-block-nested-y += parallels.o nbd.o
-block-nested-$(CONFIG_WIN32) += raw-win32.o
-block-nested-$(CONFIG_POSIX) += raw-posix.o
-block-nested-$(CONFIG_CURL) += curl.o
-
-block-obj-y +=  $(addprefix block/, $(block-nested-y))
-
-net-obj-y = net.o
-net-nested-y = queue.o checksum.o util.o
-net-nested-y += socket.o
-net-nested-y += dump.o
-net-nested-$(CONFIG_POSIX) += tap.o
-net-nested-$(CONFIG_LINUX) += tap-linux.o
-net-nested-$(CONFIG_WIN32) += tap-win32.o
-net-nested-$(CONFIG_BSD) += tap-bsd.o
-net-nested-$(CONFIG_SOLARIS) += tap-solaris.o
-net-nested-$(CONFIG_AIX) += tap-aix.o
-net-nested-$(CONFIG_SLIRP) += slirp.o
-net-nested-$(CONFIG_VDE) += vde.o
-net-obj-y += $(addprefix net/, $(net-nested-y))
-
-######################################################################
-# libqemu_common.a: Target independent part of system emulation. The
-# long term path is to suppress *all* target specific code in case of
-# system emulation, i.e. a single QEMU executable should support all
-# CPUs and machines.
-
-obj-y = $(block-obj-y)
-obj-y += $(net-obj-y)
-obj-y += $(qobject-obj-y)
-obj-y += readline.o console.o
-
-obj-y += tcg-runtime.o host-utils.o
-obj-y += irq.o ioport.o
-obj-$(CONFIG_PTIMER) += ptimer.o
-obj-$(CONFIG_MAX7310) += max7310.o
-obj-$(CONFIG_WM8750) += wm8750.o
-obj-$(CONFIG_TWL92230) += twl92230.o
-obj-$(CONFIG_TSC2005) += tsc2005.o
-obj-$(CONFIG_LM832X) += lm832x.o
-obj-$(CONFIG_TMP105) += tmp105.o
-obj-$(CONFIG_STELLARIS_INPUT) += stellaris_input.o
-obj-$(CONFIG_SSD0303) += ssd0303.o
-obj-$(CONFIG_SSD0323) += ssd0323.o
-obj-$(CONFIG_ADS7846) += ads7846.o
-obj-$(CONFIG_MAX111X) += max111x.o
-obj-$(CONFIG_DS1338) += ds1338.o
-obj-y += i2c.o smbus.o smbus_eeprom.o
-obj-y += eeprom93xx.o
-obj-y += scsi-disk.o cdrom.o
-obj-y += scsi-generic.o scsi-bus.o
-obj-y += usb.o usb-hub.o usb-$(HOST_USB).o usb-hid.o usb-msd.o usb-wacom.o
-obj-y += usb-serial.o usb-net.o usb-bus.o
-obj-$(CONFIG_SSI) += ssi.o
-obj-$(CONFIG_SSI_SD) += ssi-sd.o
-obj-$(CONFIG_SD) += sd.o
-obj-y += bt.o bt-host.o bt-vhci.o bt-l2cap.o bt-sdp.o bt-hci.o bt-hid.o usb-bt.o
-obj-y += bt-hci-csr.o
-obj-y += buffered_file.o migration.o migration-tcp.o qemu-sockets.o
-obj-y += qemu-char.o aio.o savevm.o
-obj-y += msmouse.o ps2.o
-obj-y += qdev.o qdev-properties.o
-obj-y += qemu-config.o block-migration.o
-
-obj-$(CONFIG_BRLAPI) += baum.o
-obj-$(CONFIG_POSIX) += migration-exec.o migration-unix.o migration-fd.o
-
  audio/audio.o audio/fmodaudio.o: QEMU_CFLAGS += $(FMOD_CFLAGS)
 
-audio-obj-y = audio.o noaudio.o wavaudio.o mixeng.o
-audio-obj-$(CONFIG_SDL) += sdlaudio.o
-audio-obj-$(CONFIG_OSS) += ossaudio.o
-audio-obj-$(CONFIG_COREAUDIO) += coreaudio.o
-audio-obj-$(CONFIG_ALSA) += alsaaudio.o
-audio-obj-$(CONFIG_DSOUND) += dsoundaudio.o
-audio-obj-$(CONFIG_FMOD) += fmodaudio.o
-audio-obj-$(CONFIG_ESD) += esdaudio.o
-audio-obj-$(CONFIG_PA) += paaudio.o
-audio-obj-$(CONFIG_WINWAVE) += winwaveaudio.o
-audio-obj-$(CONFIG_AUDIO_PT_INT) += audio_pt_int.o
-audio-obj-$(CONFIG_AUDIO_WIN_INT) += audio_win_int.o
-audio-obj-y += wavcapture.o
-obj-y += $(addprefix audio/, $(audio-obj-y))
-
-obj-y += keymaps.o
-obj-$(CONFIG_SDL) += sdl.o sdl_zoom.o x_keymap.o
-obj-$(CONFIG_CURSES) += curses.o
-obj-y += vnc.o acl.o d3des.o
-obj-$(CONFIG_VNC_TLS) += vnc-tls.o vnc-auth-vencrypt.o
-obj-$(CONFIG_VNC_SASL) += vnc-auth-sasl.o
-obj-$(CONFIG_COCOA) += cocoa.o
-obj-$(CONFIG_IOTHREAD) += qemu-thread.o
-
-slirp-obj-y = cksum.o if.o ip_icmp.o ip_input.o ip_output.o
-slirp-obj-y += slirp.o mbuf.o misc.o sbuf.o socket.o tcp_input.o tcp_output.o
-slirp-obj-y += tcp_subr.o tcp_timer.o udp.o bootp.o tftp.o
-obj-$(CONFIG_SLIRP) += $(addprefix slirp/, $(slirp-obj-y))
-
-# xen backend driver support
-obj-$(CONFIG_XEN) += xen_backend.o xen_devconfig.o
-obj-$(CONFIG_XEN) += xen_console.o xenfb.o xen_disk.o xen_nic.o
-
  QEMU_CFLAGS+=$(CURL_CFLAGS)
 

 cocoa.o: cocoa.m

Makefile +0 -2
@@ -229,17 +115,23 @@ curses.o: curses.c keymaps.h curses_keys.h
 
  bt-host.o: QEMU_CFLAGS += $(BLUEZ_CFLAGS)
 
-libqemu_common.a: $(obj-y)
-
  ######################################################################
 

 qemu-img.o: qemu-img-cmds.h

Makefile +11 -3
-qemu-img$(EXESUF): qemu-img.o qemu-tool.o $(block-obj-y) $(qobject-obj-y)
+obj-y = qemu-img.o qemu-tool.o $(block-obj-y) $(qobject-obj-y)
+
+qemu-img$(EXESUF): $(obj-y)
+
+obj-y = qemu-nbd.o qemu-tool.o $(block-obj-y) $(qobject-obj-y)
+$(obj-y): $(GENERATED_HEADERS)
+
+qemu-nbd$(EXESUF): $(obj-y)
 
-qemu-nbd$(EXESUF):  qemu-nbd.o qemu-tool.o $(block-obj-y) $(qobject-obj-y)
+obj-y = qemu-io.o qemu-tool.o cmd.o $(block-obj-y) $(qobject-obj-y)
+$(obj-y): $(GENERATED_HEADERS)
 
-qemu-io$(EXESUF):  qemu-io.o qemu-tool.o cmd.o $(block-obj-y) $(qobject-obj-y)
+qemu-io$(EXESUF): $(obj-y)

 qemu-img-cmds.h: $(SRC_PATH)/qemu-img-cmds.hx
       $(call quiet-command,sh $(SRC_PATH)/hxtool -h < $< > $@,"  GEN   $@")

Makefile.hw +0 -0
index bd252f5..ff87ae4 100644
@@ -11,41 +11,12 @@ VPATH=$(SRC_PATH):$(SRC_PATH)/hw
 

 QEMU_CFLAGS+=-I.. -I$(SRC_PATH)/fpu

Makefile.hw +2 -29
-obj-y =
-obj-y += loader.o
-obj-y += virtio.o
-obj-y += fw_cfg.o
-obj-y += watchdog.o
-obj-$(CONFIG_ECC) += ecc.o
-obj-$(CONFIG_NAND) += nand.o
+include $(SRC_PATH)/Makefile.objs
 
-obj-$(CONFIG_M48T59) += m48t59.o
-obj-$(CONFIG_ESCC) += escc.o
-
-# PCI watchdog devices
-obj-y += wdt_i6300esb.o
-
-obj-y += msix.o
-
-# PCI network cards
-obj-y += ne2000.o
-
-obj-$(CONFIG_SMC91C111) += smc91c111.o
-obj-$(CONFIG_LAN9118) += lan9118.o
-
-# SCSI layer
-obj-y += lsi53c895a.o
-obj-$(CONFIG_ESP) += esp.o
-
-obj-y += dma-helpers.o sysbus.o isa-bus.o
-obj-$(CONFIG_QDEV_ADDR) += qdev-addr.o
-
-all: $(HWLIB)
+all: $(hw-obj-y)

 # Dummy command so that make thinks it has done something @true

-$(HWLIB): $(obj-y)
-
 clean:
       rm -f *.o *.d *.a *~

Makefile.objs new file +155 -0
new file mode 100644
index 0000000..e8a44d7
@@ -0,0 +1,155 @@
+#######################################################################
+# QObject
+qobject-obj-y = qint.o qstring.o qdict.o qlist.o qfloat.o qbool.o
+qobject-obj-y += qjson.o json-lexer.o json-streamer.o json-parser.o
+qobject-obj-y += qerror.o
+
+#######################################################################
+# block-obj-y is code used by both qemu system emulation and qemu-img
+
+block-obj-y = cutils.o cache-utils.o qemu-malloc.o qemu-option.o module.o
+block-obj-y += nbd.o block.o aio.o aes.o osdep.o
+block-obj-$(CONFIG_POSIX) += posix-aio-compat.o
+block-obj-$(CONFIG_LINUX_AIO) += linux-aio.o
+
+block-nested-y += cow.o qcow.o vdi.o vmdk.o cloop.o dmg.o bochs.o vpc.o vvfat.o
+block-nested-y += qcow2.o qcow2-refcount.o qcow2-cluster.o qcow2-snapshot.o
+block-nested-y += parallels.o nbd.o
+block-nested-$(CONFIG_WIN32) += raw-win32.o
+block-nested-$(CONFIG_POSIX) += raw-posix.o
+block-nested-$(CONFIG_CURL) += curl.o
+
+block-obj-y +=  $(addprefix block/, $(block-nested-y))
+
+net-obj-y = net.o
+net-nested-y = queue.o checksum.o util.o
+net-nested-y += socket.o
+net-nested-y += dump.o
+net-nested-$(CONFIG_POSIX) += tap.o
+net-nested-$(CONFIG_LINUX) += tap-linux.o
+net-nested-$(CONFIG_WIN32) += tap-win32.o
+net-nested-$(CONFIG_BSD) += tap-bsd.o
+net-nested-$(CONFIG_SOLARIS) += tap-solaris.o
+net-nested-$(CONFIG_AIX) += tap-aix.o
+net-nested-$(CONFIG_SLIRP) += slirp.o
+net-nested-$(CONFIG_VDE) += vde.o
+net-obj-y += $(addprefix net/, $(net-nested-y))
+
+######################################################################
+# libqemu_common.a: Target independent part of system emulation. The
+# long term path is to suppress *all* target specific code in case of
+# system emulation, i.e. a single QEMU executable should support all
+# CPUs and machines.
+
+common-obj-y = $(block-obj-y)
+common-obj-y += $(net-obj-y)
+common-obj-y += $(qobject-obj-y)
+common-obj-y += readline.o console.o
+
+common-obj-y += tcg-runtime.o host-utils.o
+common-obj-y += irq.o ioport.o
+common-obj-$(CONFIG_PTIMER) += ptimer.o
+common-obj-$(CONFIG_MAX7310) += max7310.o
+common-obj-$(CONFIG_WM8750) += wm8750.o
+common-obj-$(CONFIG_TWL92230) += twl92230.o
+common-obj-$(CONFIG_TSC2005) += tsc2005.o
+common-obj-$(CONFIG_LM832X) += lm832x.o
+common-obj-$(CONFIG_TMP105) += tmp105.o
+common-obj-$(CONFIG_STELLARIS_INPUT) += stellaris_input.o
+common-obj-$(CONFIG_SSD0303) += ssd0303.o
+common-obj-$(CONFIG_SSD0323) += ssd0323.o
+common-obj-$(CONFIG_ADS7846) += ads7846.o
+common-obj-$(CONFIG_MAX111X) += max111x.o
+common-obj-$(CONFIG_DS1338) += ds1338.o
+common-obj-y += i2c.o smbus.o smbus_eeprom.o
+common-obj-y += eeprom93xx.o
+common-obj-y += scsi-disk.o cdrom.o
+common-obj-y += scsi-generic.o scsi-bus.o
+common-obj-y += usb.o usb-hub.o usb-$(HOST_USB).o usb-hid.o usb-msd.o usb-wacom.o
+common-obj-y += usb-serial.o usb-net.o usb-bus.o
+common-obj-$(CONFIG_SSI) += ssi.o
+common-obj-$(CONFIG_SSI_SD) += ssi-sd.o
+common-obj-$(CONFIG_SD) += sd.o
+common-obj-y += bt.o bt-host.o bt-vhci.o bt-l2cap.o bt-sdp.o bt-hci.o bt-hid.o usb-bt.o
+common-obj-y += bt-hci-csr.o
+common-obj-y += buffered_file.o migration.o migration-tcp.o qemu-sockets.o
+common-obj-y += qemu-char.o savevm.o #aio.o
+common-obj-y += msmouse.o ps2.o
+common-obj-y += qdev.o qdev-properties.o
+common-obj-y += qemu-config.o block-migration.o
+
+common-obj-$(CONFIG_BRLAPI) += baum.o
+common-obj-$(CONFIG_POSIX) += migration-exec.o migration-unix.o migration-fd.o
+
+audio-obj-y = audio.o noaudio.o wavaudio.o mixeng.o
+audio-obj-$(CONFIG_SDL) += sdlaudio.o
+audio-obj-$(CONFIG_OSS) += ossaudio.o
+audio-obj-$(CONFIG_COREAUDIO) += coreaudio.o
+audio-obj-$(CONFIG_ALSA) += alsaaudio.o
+audio-obj-$(CONFIG_DSOUND) += dsoundaudio.o
+audio-obj-$(CONFIG_FMOD) += fmodaudio.o
+audio-obj-$(CONFIG_ESD) += esdaudio.o
+audio-obj-$(CONFIG_PA) += paaudio.o
+audio-obj-$(CONFIG_WINWAVE) += winwaveaudio.o
+audio-obj-$(CONFIG_AUDIO_PT_INT) += audio_pt_int.o
+audio-obj-$(CONFIG_AUDIO_WIN_INT) += audio_win_int.o
+audio-obj-y += wavcapture.o
+common-obj-y += $(addprefix audio/, $(audio-obj-y))
+
+common-obj-y += keymaps.o
+common-obj-$(CONFIG_SDL) += sdl.o sdl_zoom.o x_keymap.o
+common-obj-$(CONFIG_CURSES) += curses.o
+common-obj-y += vnc.o acl.o d3des.o
+common-obj-$(CONFIG_VNC_TLS) += vnc-tls.o vnc-auth-vencrypt.o
+common-obj-$(CONFIG_VNC_SASL) += vnc-auth-sasl.o
+common-obj-$(CONFIG_COCOA) += cocoa.o
+common-obj-$(CONFIG_IOTHREAD) += qemu-thread.o
+
+slirp-obj-y = cksum.o if.o ip_icmp.o ip_input.o ip_output.o
+slirp-obj-y += slirp.o mbuf.o misc.o sbuf.o socket.o tcp_input.o tcp_output.o
+slirp-obj-y += tcp_subr.o tcp_timer.o udp.o bootp.o tftp.o
+common-obj-$(CONFIG_SLIRP) += $(addprefix slirp/, $(slirp-obj-y))
+
+# xen backend driver support
+common-obj-$(CONFIG_XEN) += xen_backend.o xen_devconfig.o
+common-obj-$(CONFIG_XEN) += xen_console.o xenfb.o xen_disk.o xen_nic.o
+
+######################################################################
+# libuser
+
+user-obj-y =
+user-obj-y += envlist.o path.o
+user-obj-y += tcg-runtime.o host-utils.o
+user-obj-y += cutils.o cache-utils.o
+
+######################################################################
+# libhw
+
+hw-obj-y =
+hw-obj-y += loader.o
+hw-obj-y += virtio.o
+hw-obj-y += fw_cfg.o
+hw-obj-y += watchdog.o
+hw-obj-$(CONFIG_ECC) += ecc.o
+hw-obj-$(CONFIG_NAND) += nand.o
+
+hw-obj-$(CONFIG_M48T59) += m48t59.o
+hw-obj-$(CONFIG_ESCC) += escc.o
+
+# PCI watchdog devices
+hw-obj-y += wdt_i6300esb.o
+
+hw-obj-y += msix.o
+
+# PCI network cards
+hw-obj-y += ne2000.o
+
+hw-obj-$(CONFIG_SMC91C111) += smc91c111.o
+hw-obj-$(CONFIG_LAN9118) += lan9118.o
+
+# SCSI layer
+hw-obj-y += lsi53c895a.o
+hw-obj-$(CONFIG_ESP) += esp.o
+
+hw-obj-y += dma-helpers.o sysbus.o isa-bus.o
+hw-obj-$(CONFIG_QDEV_ADDR) += qdev-addr.o
Makefile.target +0 -1
index 7c1f30c..543e8cd 100644
@@ -1,17 +1,21 @@
  # -*- Mode: makefile -*-
 
-# This needs to be defined before rules.mak

 GENERATED_HEADERS = config-target.h

 include ../config-host.mak
 include config-devices.mak
 include config-target.mak
 include $(SRC_PATH)/rules.mak

Makefile.target +3 -0
+ifneq ($(HWDIR),)
+include $(HWDIR)/config.mak
+endif

 TARGET_PATH=$(SRC_PATH)/target-$(TARGET_BASE_ARCH) VPATH=$(SRC_PATH):$(TARGET_PATH):$(SRC_PATH)/hw QEMU_CFLAGS+= -I.. -I$(TARGET_PATH) -DNEED_CPU_H

Makefile.target +2 -0
+include $(SRC_PATH)/Makefile.objs
+

 ifdef CONFIG_USER_ONLY

 # user emulator name
 QEMU_PROG=qemu-$(TARGET_ARCH2)
Makefile.target +0 -0
@@ -64,9 +68,9 @@ libobj-$(CONFIG_S390_DIS) += s390-dis.o

 libobj-$(CONFIG_SH4_DIS) += sh4-dis.o
 libobj-$(CONFIG_SPARC_DIS) += sparc-dis.o

Makefile.target +2 -2
-# libqemu
+$(libobj-y): $(GENERATED_HEADERS)
 
-libqemu.a: $(libobj-y)
+# libqemu

 translate.o: translate.c cpu.h

Makefile.target +0 -0
@@ -106,7 +110,10 @@ obj-arm-y += arm-semi.o
 

 obj-m68k-y += m68k-sim.o m68k-semi.o

Makefile.target +4 -1
-ARLIBS=../libuser/libuser.a libqemu.a
+$(obj-y) $(obj-$(TARGET_BASE_ARCH)-y): $(GENERATED_HEADERS)
+
+obj-y += $(addprefix ../libuser/, $(user-obj-y))
+obj-y += $(libobj-y)

 endif #CONFIG_LINUX_USER

Makefile.target +0 -0
@@ -128,7 +135,10 @@ obj-y = main.o commpage.o machload.o mmap.o signal.o syscall.o thunk.o \
 

 obj-i386-y += ioport-user.o

Makefile.target +4 -1
-ARLIBS=../libuser/libuser.a libqemu.a
+$(obj-y) $(obj-$(TARGET_BASE_ARCH)-y): $(GENERATED_HEADERS)
+
+obj-y += $(addprefix ../libuser/, $(user-obj-y))
+obj-y += $(libobj-y)

 endif #CONFIG_DARWIN_USER

Makefile.target +0 -0
@@ -145,7 +155,10 @@ obj-y = main.o bsdload.o elfload.o mmap.o signal.o strace.o syscall.o \
 

 obj-i386-y += ioport-user.o

Makefile.target +4 -1
-ARLIBS=../libuser/libuser.a libqemu.a
+$(obj-y) $(obj-$(TARGET_BASE_ARCH)-y): $(GENERATED_HEADERS)
+
+obj-y += $(addprefix ../libuser/, $(user-obj-y))
+obj-y += $(libobj-y)

 endif #CONFIG_BSD_USER

Makefile.target +0 -0
@@ -303,13 +316,17 @@ vl.o: qemu-options.h
 

 monitor.o: qemu-monitor.h

Makefile.target +5 -1
-ARLIBS=../libqemu_common.a libqemu.a $(HWLIB)
+$(obj-y) $(obj-$(TARGET_BASE_ARCH)-y): $(GENERATED_HEADERS)
+
+obj-y += $(addprefix ../, $(common-obj-y))
+obj-y += $(libobj-y)
+obj-y += $(addprefix $(HWDIR)/, $(hw-obj-y))

 endif # CONFIG_SOFTMMU

 obj-$(CONFIG_GDBSTUB_XML) += gdbstub-xml.o

-$(QEMU_PROG): $(obj-y) $(obj-$(TARGET_BASE_ARCH)-y) $(ARLIBS) +$(QEMU_PROG): $(obj-y) $(obj-$(TARGET_BASE_ARCH)-y) $(call LINK,$(obj-y) $(obj-$(TARGET_BASE_ARCH)-y))

Makefile.user +0 -0
index 7daedef..c6ac509 100644
@@ -14,17 +14,12 @@ vpath %.c %.h $(SRC_PATH)
 

 QEMU_CFLAGS+=-I..

Makefile.user +2 -5
-obj-y =
-obj-y += envlist.o path.o
-obj-y += tcg-runtime.o host-utils.o
-obj-y += cutils.o cache-utils.o
+include $(SRC_PATH)/Makefile.objs
 
-all: libuser.a
+all: $(user-obj-y)

 # Dummy command so that make thinks it has done something @true

Makefile.user +0 -2
-libuser.a: $(obj-y)
-

 clean:
       rm -f *.o *.d *.a *~

configure +0 -0
index 18aed43..1e9dd04 100755
@@ -1707,37 +1707,6 @@ elif compile_prog "" "-lrt" ; then

  LIBS="-lrt $LIBS"
 fi

configure +0 -31
-# Determine what linker flags to use to force archive inclusion
-check_linker_flags()
-{
-    w2=
-    if test "$2" ; then
-       w2=-Wl,$2
-    fi
-    compile_prog "" "-Wl,$1 ${w2}"
-}
-
-cat > $TMPC << EOF
-int main(void) { }
-EOF
-if check_linker_flags --whole-archive --no-whole-archive ; then
-    # GNU ld
-    arlibs_begin="-Wl,--whole-archive"
-    arlibs_end="-Wl,--no-whole-archive"
-elif check_linker_flags -z,allextract -z,defaultextract ; then
-    # Solaris ld
-    arlibs_begin="-Wl,-z,allextract"
-    arlibs_end="-Wl,-z,defaultextract"
-elif check_linker_flags -all_load ; then
-    # Mac OS X
-    arlibs_begin="-all_load"
-    arlibs_end=""
-else
-    echo "Error: your linker does not support --whole-archive or -z."
-    echo "Please report to [email protected]"
-    exit 1
-fi
-

 if test "$darwin" != "yes" -a "$mingw32" != "yes" -a "$solaris" != yes -a \
        "$aix" != "yes" ; then
    libs_softmmu="-lutil $libs_softmmu"

configure +0 -0
@@ -2427,7 +2396,7 @@ fi

 if test "$target_softmmu" = "yes" ; then
  echo "CONFIG_SOFTMMU=y" >> $config_target_mak
  echo "LIBS+=$libs_softmmu" >> $config_target_mak
-  echo "HWLIB=../libhw$target_phys_bits/libqemuhw$target_phys_bits.a" >> $config_target_mak
+  echo "HWDIR=../libhw$target_phys_bits" >> $config_target_mak
  echo "subdir-$target: subdir-libhw$target_phys_bits" >> $config_host_mak
 fi
 if test "$target_user_only" = "yes" ; then

configure +0 -0
@@ -2644,7 +2613,6 @@ for hwlib in 32 64; do

  mkdir -p $d
  rm -f $d/Makefile
  ln -s $source_path/Makefile.hw $d/Makefile
-  echo "HWLIB=libqemuhw$hwlib.a" > $d/config.mak
  echo "QEMU_CFLAGS+=-DTARGET_PHYS_ADDR_BITS=$hwlib" >> $d/config.mak done

rules.mak +0 -0
index 5d9f684..9bcf9af 100644
@@ -14,7 +14,7 @@ MAKEFLAGS += -rR
  # Flags for dependency generation

 QEMU_DGFLAGS += -MMD -MP -MT $@

-%.o: %.c $(GENERATED_HEADERS)
+%.o: %.c
       $(call quiet-command,$(CC) $(QEMU_CFLAGS) $(QEMU_DGFLAGS) $(CFLAGS) -c -o $@ $<,"  CC    $(TARGET_DIR)$@")

 %.o: %.S

rules.mak +0 -0
@@ -23,7 +23,7 @@ QEMU_DGFLAGS += -MMD -MP -MT $@

 %.o: %.m
       $(call quiet-command,$(CC) $(QEMU_CFLAGS) $(QEMU_DGFLAGS) $(CFLAGS) -c -o $@ $<,"  OBJC  $(TARGET_DIR)$@")

rules.mak +1 -1
-LINK = $(call quiet-command,$(CC) $(QEMU_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ $(1) $(ARLIBS_BEGIN) $(ARLIBS) $(ARLIBS_END) $(LIBS),"  LINK  $(TARGET_DIR)$@")
+LINK = $(call quiet-command,$(CC) $(QEMU_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ $(1) $(LIBS),"  LINK  $(TARGET_DIR)$@")

 %$(EXESUF): %.o
       $(call LINK,$^)
--
1.6.5.3

#12 lore raw
In reply to Andreas Färber
Quoted 4 lines · Andreas F?rber

v3:
- Fix dependency modelling for tools
- Remove comment on GENERATED_HEADERS obsoleted by this patch

Hi,

as the previous patches this v3 version solves the linking problems on Solaris hosts

regards
Palle

#6 lore raw

[Qemu-devel] QEMU license problem (was [PATCH v3] Drop --whole-archive and static libraries)

In reply to Blue Swirl
Quoted 52 lines · Blue Swirl

Thanks, applied.

Quoted 47 lines · Andreas Färber

From: Andreas Färber <[email protected]>

Juan has contributed a cool Makefile infrastructure that enables us to drop
static libraries completely:

Move shared obj-y definitions to Makefile.objs, prefixed {common-,hw-,user-},
and link those object files directly into the executables.

Replace HWLIB by HWDIR, specifying only the directory.

Drop --whole-archive and ARLIBS in Makefiles and configure.

Drop GENERATED_HEADERS dependency in rules.mak, since this rebuilds all common objects after generating a target-specific header; add dependency rules to Makefile and Makefile.target instead.

v2:
- Don't try to include /config.mak for user emulators
- Changes to user object paths ("Quickfix for libuser.a drop") were obsoleted
by "user_only: compile everything with -fpie" (Kirill A. Shutemov)

v3:
- Fix dependency modelling for tools
- Remove comment on GENERATED_HEADERS obsoleted by this patch

Cc Blue Swirl <[email protected]>
Cc Palle Lyckegaard <[email protected]>
Cc Ben Taylor <[email protected]>
Cc Juan Quintela <[email protected]>
Cc Kirill A. Shutemov <[email protected]>
Cc Paolo Bonzini <[email protected]>
---
 Makefile        |  138 +++++-------------------------------------------
 Makefile.hw     |   33 +-----------
 Makefile.objs   |  155
+++++++++++++++++++++++++++++++++++++++++++++++++++++++
 Makefile.target |   33 +++++++++---
 Makefile.user   |    9 +---
 configure       |   34 +------------
 rules.mak       |    4 +-
 7 files changed, 202 insertions(+), 204 deletions(-)
 create mode 100644 Makefile.objs

Removing libqemu.a was technically ok, but throws a license problem:

"In particular, the QEMU virtual CPU core library (libqemu.a) is released under the GNU Lesser General Public License."

Without libqemu.a, this part of QEMU's license no longer works.

I think the best solution would be to add a rule for libqemu.a which allows users to build this static library (make libqemu.a).

libqemu.a is also still needed for tests/qruncom.

Regards,
Stefan Weil

#7 lore raw

Re: [Qemu-devel] QEMU license problem (was [PATCH v3] Drop --whole-archive and static libraries)

Quoted 56 lines · Stefan Weil
Quoted 54 lines · Blue Swirl

Thanks, applied.

Quoted 48 lines · Andreas Färber

From: Andreas Färber<[email protected]>

Juan has contributed a cool Makefile infrastructure that enables us to drop
static libraries completely:

Move shared obj-y definitions to Makefile.objs, prefixed {common-,hw-,user-},
and link those object files directly into the executables.

Replace HWLIB by HWDIR, specifying only the directory.

Drop --whole-archive and ARLIBS in Makefiles and configure.

Drop GENERATED_HEADERS dependency in rules.mak, since this rebuilds all common objects after generating a target-specific header; add dependency rules to Makefile and Makefile.target instead.

v2:
- Don't try to include /config.mak for user emulators
- Changes to user object paths ("Quickfix for libuser.a drop") were obsoleted
by "user_only: compile everything with -fpie" (Kirill A. Shutemov)

v3:
- Fix dependency modelling for tools
- Remove comment on GENERATED_HEADERS obsoleted by this patch

Cc Blue Swirl<[email protected]>
Cc Palle Lyckegaard<[email protected]>
Cc Ben Taylor<[email protected]>
Cc Juan Quintela<[email protected]>
Cc Kirill A. Shutemov<[email protected]>
Cc Paolo Bonzini<[email protected]>
---
  Makefile        |  138 +++++-------------------------------------------
  Makefile.hw     |   33 +-----------
  Makefile.objs   |  155
+++++++++++++++++++++++++++++++++++++++++++++++++++++++
  Makefile.target |   33 +++++++++---
  Makefile.user   |    9 +---
  configure       |   34 +------------
  rules.mak       |    4 +-
  7 files changed, 202 insertions(+), 204 deletions(-)

create mode 100644 Makefile.objs

Quoted 2 lines

Removing libqemu.a was technically ok, but throws a license problem:

Every file contains a copyright/license. The statement in the top level is just a statement of intention. It's to make sure that people do not introduce GPL'd code into libqemu.a.

Regards,

Anthony Liguori

#8 lore raw

Re: [Qemu-devel] QEMU license problem (was [PATCH v3] Drop --whole-archive and static libraries)

On Sun, Mar 7, 2010 at 2:53 PM, Anthony Liguori <[email protected]> wrote:
[...]

Quoted 7 lines
Quoted 3 lines

Removing libqemu.a was technically ok, but throws a license problem:

Every file contains a copyright/license.  The statement in the top level is just a statement of intention.  It's to make sure that people do not introduce GPL'd code into libqemu.a.

./configure --target-list=i386-linux-user,i386-softmmu make -j7

And:

find . -name 'lib*a'

finds nothing, so how can you say what is supposed to be in libqemu?

Laurent

#9 lore raw

[Qemu-devel] Re: QEMU license problem (was [PATCH v3] Drop --whole-archive and static libraries)

In reply to Stefan Weil
Quoted 8 lines · Stefan Weil
Quoted 1 line · Blue Swirl

Thanks, applied.

Removing libqemu.a was technically ok, but throws a license problem:

"In particular, the QEMU virtual CPU core library (libqemu.a) is released under the GNU Lesser General Public License."

Quoted 6 lines

Without libqemu.a, this part of QEMU's license no longer works.

I think the best solution would be to add a rule for libqemu.a which allows users to build this static library (make libqemu.a).

libqemu.a is also still needed for tests/qruncom.

I noticed it also. Not sure how to go here. Create libqemu.a even if it is not used?

Quoted 1 line

From LICENSE:

In particular, the QEMU virtual CPU core library (libqemu.a) is released under the GNU Lesser General Public License.

And if GPL licencse is complicated, LGPL for a static lib makes my head explode.

Later, Juan.

#10 lore raw

[Qemu-devel] Re: QEMU license problem (was [PATCH v3] Drop --whole-archive and static libraries)

Am 07.03.2010 um 17:47 schrieb Juan Quintela:

Quoted 13 lines
Quoted 11 lines · Stefan Weil

Removing libqemu.a was technically ok, but throws a license problem:

"In particular, the QEMU virtual CPU core library (libqemu.a) is released under the GNU Lesser General Public License."

Without libqemu.a, this part of QEMU's license no longer works.

I think the best solution would be to add a rule for libqemu.a which allows users to build this static library (make libqemu.a).

libqemu.a is also still needed for tests/qruncom.

Quoted 7 lines

I noticed it also. Not sure how to go here. Create libqemu.a even if it is not used?

From LICENSE:
In particular, the QEMU virtual CPU core library (libqemu.a) is released under the GNU Lesser General Public License.

We've had a handful of people inquire about LGPL licensing on this list, getting no answer: They complained that libqemu.a contained GPL'ed code and none of you cared, so that would seem a moot point and we should rather fix the licensing passage.

If libqemu.a is still used somewhere in the Makefiles, then obviously we have to fix it. Sorry if I missed something there.

Not sure how to go about re-providing a library either, we could theoretically add a target using our new infrastructure and leave our own executables as they are now, but that would re-introduce the original problems for any user with an incompatible tool chain, not to mention that someone would need to test such a library target.

Andreas

#11 lore raw

Re: [Qemu-devel] Re: QEMU license problem (was [PATCH v3] Drop --whole-archive and static libraries)

Quoted 20 lines · Andreas Färber

Am 07.03.2010 um 17:47 schrieb Juan Quintela:

Quoted 17 lines
Quoted 11 lines · Stefan Weil

Removing libqemu.a was technically ok, but throws a license problem:

"In particular, the QEMU virtual CPU core library (libqemu.a) is released under the GNU Lesser General Public License."

Without libqemu.a, this part of QEMU's license no longer works.

I think the best solution would be to add a rule for libqemu.a which allows users to build this static library (make libqemu.a).

libqemu.a is also still needed for tests/qruncom.

I noticed it also. Not sure how to go here. Create libqemu.a even if it is not used?

Quoted 5 lines
Quoted 3 lines

From LICENSE:
In particular, the QEMU virtual CPU core library (libqemu.a) is released under the GNU Lesser General Public License.

We've had a handful of people inquire about LGPL licensing on this list, getting no answer: They complained that libqemu.a contained GPL'ed code and none of you cared, so that would seem a moot point and we should rather fix the licensing passage.

What we need to do is audit the code base for any file that doesn't carry an explicit copyright notice, and have the author(s) add explicit copyright/license statements to it. This top level file is not a valid copyright statement IMHO in particular because it deals with things like "libqemu.a" which is poorly defined.

My understanding of LICENSE is that it is purely an explanation, not a licensing statement. It was added by Fabrice and it covers code in the tree that was there before he added it that he didn't hold the copyright on so it's not a very strong statement.

It was his desire that libqemu.a be LGPL, that does not mean that it actually is...

Regards,

Anthony Liguori