From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LwiDB-0005PG-Gf for qemu-devel@nongnu.org; Wed, 22 Apr 2009 15:34:25 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LwiD5-0005Ki-T7 for qemu-devel@nongnu.org; Wed, 22 Apr 2009 15:34:24 -0400 Received: from [199.232.76.173] (port=44679 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LwiD5-0005KC-9k for qemu-devel@nongnu.org; Wed, 22 Apr 2009 15:34:19 -0400 Received: from mail-bw0-f223.google.com ([209.85.218.223]:45476) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1LwiD4-0000l6-He for qemu-devel@nongnu.org; Wed, 22 Apr 2009 15:34:19 -0400 Received: by bwz23 with SMTP id 23so149546bwz.34 for ; Wed, 22 Apr 2009 12:34:16 -0700 (PDT) MIME-Version: 1.0 Date: Wed, 22 Apr 2009 22:34:16 +0300 Message-ID: From: Blue Swirl Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Subject: [Qemu-devel] [PATCH, RFC] Smarter compilation for target devices List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel Compile target devices only once for each endian and word size combination, saving a few compiles if large number of targets are enabled. --- Makefile.libqemuhw | 123 ++++++++++++++++++++++++++++++++++++++++++++++++++++ Makefile.target | 30 +++++++++++- configure | 70 +++++++++++++++++++++++++++++- 3 files changed, 219 insertions(+), 4 deletions(-) create mode 100644 Makefile.libqemuhw diff --git a/Makefile.libqemuhw b/Makefile.libqemuhw new file mode 100644 index 0000000..7aeae21 --- /dev/null +++ b/Makefile.libqemuhw @@ -0,0 +1,123 @@ +include config.mak +include $(SRC_PATH)/rules.mak + +VPATH=$(SRC_PATH):$(SRC_PATH)/hw +CPPFLAGS=-I. -I.. -I$(SRC_PATH) -MMD -MT $@ -MP -DNEED_CPU_H +#CFLAGS+=-Werror + +ifeq ($(ARCH),alpha) +# Ensure there's only a single GP +CFLAGS+=-msmall-data +endif + +ifeq ($(ARCH),ia64) +CFLAGS+=-mno-sdata +endif + +CFLAGS+=$(OS_CFLAGS) $(ARCH_CFLAGS) +LDFLAGS+=$(OS_LDFLAGS) $(ARCH_LDFLAGS) + +CPPFLAGS+=-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE +ifdef CONFIG_SOLARIS +ifdef NEEDS_LIBSUNMATH +CFLAGS+=-I/opt/SUNWspro/prod/include/cc +endif +endif + +CPPFLAGS+=-I$(SRC_PATH)/fpu + +# Warning: Do not add new files here if they have conditional code +# with #ifdef TARGET_xxx etc, use TARGET_PAGE_SIZE or reference +# CPUState + +# Common objects used by most targets +OBJS+=fw_cfg.o + +# Target specific objects +ifdef TARGET_I386 +LIBLE32OBJS+=$(OBJS) +endif + +ifdef TARGET_X86_64 +LIBLE64OBJS+=$(OBJS) +endif + +PPCOBJS=escc.o + +ifdef TARGET_PPC +LIBBE32OBJS+=$(PPCOBJS) +LIBBE32OBJS+=$(OBJS) +endif + +ifdef TARGET_PPC64 +LIBBE64OBJS+=$(PPCOBJS) +LIBBE32OBJS+=$(OBJS) +endif + +ifdef TARGET_MIPS +LIBBE32OBJS+=$(OBJS) +endif + +ifdef TARGET_MIPSEL +LIBLE32OBJS+=$(OBJS) +endif + +ifdef TARGET_MIPS64 +LIBBE64OBJS+=$(OBJS) +endif + +ifdef TARGET_MIPSEL64 +LIBLE64OBJS+=$(OBJS) +endif + +ifdef TARGET_CRIS +LIBLE32OBJS+=$(OBJS) +endif + +ifdef TARGET_SPARC +LIBBE32OBJS+=escc.o +LIBBE32OBJS+=$(OBJS) +endif + +ifdef TARGET_SPARC64 +LIBBE64OBJS+=$(OBJS) +endif + +ifdef TARGET_ARM +LIBLE32OBJS+=$(OBJS) +endif + +ifdef TARGET_ARMEB +LIBBE32OBJS+=$(OBJS) +endif + +ifdef TARGET_SH4 +LIBLE32OBJS+=$(OBJS) +endif + +ifdef TARGET_SH4EB +LIBBE32OBJS+=$(OBJS) +endif + +ifdef TARGET_M68K +LIBBE32OBJS+=$(OBJS) +endif + +all: $(LIB) + +libqemuhw_le32.a: $(LIBLE32OBJS) + +libqemuhw_be32.a: $(LIBBE32OBJS) + +libqemuhw_le64.a: $(LIBLE64OBJS) + +libqemuhw_be64.a: $(LIBBE64OBJS) + +clean: + rm -f *.o *.a *~ + rm -f *.d */*.d + +install: all + +# Include automatically generated dependency files +-include $(wildcard *.d */*.d) diff --git a/Makefile.target b/Makefile.target index 2171587..f28fb11 100644 --- a/Makefile.target +++ b/Makefile.target @@ -501,7 +501,6 @@ OBJS=vl.o osdep.o monitor.o pci.o loader.o isa_mmio.o machine.o dma-helpers.o # virtio has to be here due to weird dependency between PCI and virtio-net. # need to fix this properly OBJS+=virtio.o virtio-blk.o virtio-balloon.o virtio-net.o virtio-console.o -OBJS+=fw_cfg.o ifdef CONFIG_KVM OBJS+=kvm.o kvm-all.o endif @@ -589,6 +588,11 @@ OBJS+= cirrus_vga.o apic.o ioapic.o parallel.o acpi.o piix_pci.o OBJS+= usb-uhci.o vmmouse.o vmport.o vmware_vga.o hpet.o OBJS += device-hotplug.o pci-hotplug.o smbios.o CPPFLAGS += -DHAS_AUDIO -DHAS_AUDIO_CHOICE +ifeq ($(TARGET_ARCH), i386) +LIBS+=../lible32/libqemuhw_le32.a +else +LIBS+=../lible64/libqemuhw_le64.a +endif endif ifeq ($(TARGET_BASE_ARCH), ppc) CPPFLAGS += -DHAS_AUDIO -DHAS_AUDIO_CHOICE @@ -598,7 +602,7 @@ OBJS+= ppc.o ide.o vga.o $(SOUND_HW) dma.o openpic.o OBJS+= pckbd.o serial.o i8259.o i8254.o fdc.o m48t59.o mc146818rtc.o OBJS+= prep_pci.o ppc_prep.o # Mac shared devices -OBJS+= macio.o cuda.o adb.o mac_nvram.o mac_dbdma.o escc.o +OBJS+= macio.o cuda.o adb.o mac_nvram.o mac_dbdma.o # OldWorld PowerMac OBJS+= heathrow_pic.o grackle_pci.o ppc_oldworld.o # NewWorld PowerMac @@ -615,6 +619,11 @@ endif ifdef CONFIG_KVM OBJS+= kvm_ppc.o endif +ifeq ($(TARGET_ARCH), ppc64) +LIBS+=../libbe64/libqemuhw_be64.a +else +LIBS+=../libbe32/libqemuhw_be32.a +endif endif ifeq ($(TARGET_BASE_ARCH), mips) OBJS+= mips_r4k.o mips_jazz.o mips_malta.o mips_mipssim.o @@ -625,6 +634,11 @@ OBJS+= piix_pci.o parallel.o cirrus_vga.o pcspk.o $(SOUND_HW) OBJS+= mipsnet.o OBJS+= pflash_cfi01.o OBJS+= vmware_vga.o +ifeq ($(TARGET_ARCH), mips) +LIBS+=../libbe32/libqemuhw_be32.a +else +LIBS+=../lible32/libqemuhw_le32.a +endif CPPFLAGS += -DHAS_AUDIO -DHAS_AUDIO_CHOICE endif ifeq ($(TARGET_BASE_ARCH), cris) @@ -639,16 +653,19 @@ OBJS+= etraxfs_timer.o OBJS+= etraxfs_ser.o OBJS+= pflash_cfi02.o nand.o +LIBS+=../lible32/libqemuhw_le32.a endif ifeq ($(TARGET_BASE_ARCH), sparc) ifeq ($(TARGET_ARCH), sparc64) OBJS+= sun4u.o ide.o pckbd.o vga.o apb_pci.o OBJS+= fdc.o mc146818rtc.o serial.o m48t59.o OBJS+= cirrus_vga.o parallel.o +LIBS+=../libbe64/libqemuhw_be64.a else OBJS+= sun4m.o tcx.o pcnet.o iommu.o m48t59.o slavio_intctl.o -OBJS+= slavio_timer.o escc.o slavio_misc.o fdc.o sparc32_dma.o +OBJS+= slavio_timer.o slavio_misc.o fdc.o sparc32_dma.o OBJS+= cs4231.o eccmemctl.o sbi.o sun4c_intctl.o +LIBS+=../libbe32/libqemuhw_be32.a endif endif ifeq ($(TARGET_BASE_ARCH), arm) @@ -670,16 +687,23 @@ OBJS+= nseries.o blizzard.o onenand.o vga.o cbus.o tusb6010.o usb-musb.o OBJS+= mst_fpga.o mainstone.o OBJS+= musicpal.o pflash_cfi02.o OBJS+= framebuffer.o +ifeq ($(TARGET_ARCH), armeb) +LIBS+=../libbe32/libqemuhw_be32.a +else +LIBS+=../lible32/libqemuhw_le32.a +endif CPPFLAGS += -DHAS_AUDIO endif ifeq ($(TARGET_BASE_ARCH), sh4) OBJS+= shix.o r2d.o sh7750.o sh7750_regnames.o tc58128.o OBJS+= sh_timer.o sh_serial.o sh_intc.o sh_pci.o sm501.o serial.o OBJS+= ide.o +LIBS+=../lible32/libqemuhw_le32.a endif ifeq ($(TARGET_BASE_ARCH), m68k) OBJS+= an5206.o mcf5206.o mcf_uart.o mcf_intc.o mcf5208.o mcf_fec.o OBJS+= m68k-semi.o dummy_m68k.o +LIBS+=../libbe32/libqemuhw_be32.a endif ifdef CONFIG_GDBSTUB OBJS+=gdbstub.o gdbstub-xml.o diff --git a/configure b/configure index b7b7b01..8669fd4 100755 --- a/configure +++ b/configure @@ -1339,7 +1339,53 @@ fi #if test "$sdl_static" = "no"; then # echo "WARNING: cannot compile statically with SDL - qemu-fast won't have a graphical output" #fi + +for bits in 32 64 ; do + for endian in be le; do + dir=$endian$bits + libdir=lib$dir + libconfig_h=$libdir/config.h + libconfig_mak=$libdir/config.mak + mkdir -p $libdir + echo "/* Automatically generated by configure - do not modify */" > $libconfig_h + echo "#include \"../config-host.h\"" >> $libconfig_h + if test "$endian" = "be" ; then + words="#define TARGET_WORDS_BIGENDIAN" + else + words= + fi + cat >$libdir/cpu.h < $libconfig_mak + echo "include ../config-host.mak" >> $libconfig_mak + echo "include ../config-libs.mak" >> $libconfig_mak + echo "LIB=libqemuhw_$dir.a" >> $libconfig_mak + done +done + config_mak="config-host.mak" +configlibs_mak="config-libs.mak" config_h="config-host.h" #echo "Creating $config_mak and $config_h" @@ -1351,6 +1397,7 @@ printf "# Configured with:" >> $config_mak printf " '%s'" "$0" "$@" >> $config_mak echo >> $config_mak echo "/* Automatically generated by configure - do not modify */" > $config_h +echo "# Automatically generated by configure - do not modify" > $configlibs_mak echo "prefix=$prefix" >> $config_mak echo "bindir=\${prefix}$binsuffix" >> $config_mak @@ -1582,7 +1629,7 @@ echo "SRC_PATH=$source_path" >> $config_mak if [ "$source_path_used" = "yes" ]; then echo "VPATH=$source_path" >> $config_mak fi -echo "TARGET_DIRS=$target_list" >> $config_mak +echo "TARGET_DIRS=libbe32 lible32 libbe64 lible64 $target_list" >> $config_mak if [ "$build_docs" = "yes" ] ; then echo "BUILD_DOCS=yes" >> $config_mak fi @@ -1791,6 +1838,7 @@ case "$target_cpu" in echo "TARGET_ARCH=i386" >> $config_mak echo "#define TARGET_ARCH \"i386\"" >> $config_h echo "#define TARGET_I386 1" >> $config_h + echo "TARGET_I386=yes" >> $configlibs_mak if test $kqemu = "yes" -a "$target_softmmu" = "yes" then echo "CONFIG_KQEMU=yes" >> $config_mak @@ -1812,6 +1860,7 @@ case "$target_cpu" in echo "#define TARGET_ARCH \"x86_64\"" >> $config_h echo "#define TARGET_I386 1" >> $config_h echo "#define TARGET_X86_64 1" >> $config_h + echo "TARGET_X86_64=yes" >> $configlibs_mak if test $kqemu = "yes" -a "$target_softmmu" = "yes" -a $cpu = "x86_64" then echo "CONFIG_KQEMU=yes" >> $config_mak @@ -1832,11 +1881,17 @@ case "$target_cpu" in echo "TARGET_ARCH=alpha" >> $config_mak echo "#define TARGET_ARCH \"alpha\"" >> $config_h echo "#define TARGET_ALPHA 1" >> $config_h + echo "TARGET_ALPHA=yes" >> $configlibs_mak ;; arm|armeb) echo "TARGET_ARCH=arm" >> $config_mak echo "#define TARGET_ARCH \"arm\"" >> $config_h echo "#define TARGET_ARM 1" >> $config_h + if test "$target_cpu" = "arm" ; then + echo "TARGET_ARM=yes" >> $configlibs_mak + else + echo "TARGET_ARMEB=yes" >> $configlibs_mak + fi bflt="yes" target_nptl="yes" gdb_xml_files="arm-core.xml arm-vfp.xml arm-vfp3.xml arm-neon.xml" @@ -1845,12 +1900,14 @@ case "$target_cpu" in echo "TARGET_ARCH=cris" >> $config_mak echo "#define TARGET_ARCH \"cris\"" >> $config_h echo "#define TARGET_CRIS 1" >> $config_h + echo "TARGET_CRIS=yes" >> $configlibs_mak target_nptl="yes" ;; m68k) echo "TARGET_ARCH=m68k" >> $config_mak echo "#define TARGET_ARCH \"m68k\"" >> $config_h echo "#define TARGET_M68K 1" >> $config_h + echo "TARGET_M68K=yes" >> $configlibs_mak bflt="yes" gdb_xml_files="cf-core.xml cf-fp.xml" ;; @@ -1859,12 +1916,14 @@ case "$target_cpu" in echo "#define TARGET_ARCH \"mips\"" >> $config_h echo "#define TARGET_MIPS 1" >> $config_h echo "#define TARGET_ABI_MIPSO32 1" >> $config_h + echo "TARGET_MIPS=yes" >> $configlibs_mak ;; mipsn32|mipsn32el) echo "TARGET_ARCH=mipsn32" >> $config_mak echo "#define TARGET_ARCH \"mipsn32\"" >> $config_h echo "#define TARGET_MIPS 1" >> $config_h echo "#define TARGET_ABI_MIPSN32 1" >> $config_h + echo "TARGET_MIPS=yes" >> $configlibs_mak ;; mips64|mips64el) echo "TARGET_ARCH=mips64" >> $config_mak @@ -1872,11 +1931,13 @@ case "$target_cpu" in echo "#define TARGET_MIPS 1" >> $config_h echo "#define TARGET_MIPS64 1" >> $config_h echo "#define TARGET_ABI_MIPSN64 1" >> $config_h + echo "TARGET_MIPS=yes" >> $configlibs_mak ;; ppc) echo "TARGET_ARCH=ppc" >> $config_mak echo "#define TARGET_ARCH \"ppc\"" >> $config_h echo "#define TARGET_PPC 1" >> $config_h + echo "TARGET_PPC=yes" >> $configlibs_mak gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml" ;; ppcemb) @@ -1885,6 +1946,7 @@ case "$target_cpu" in echo "#define TARGET_ARCH \"ppcemb\"" >> $config_h echo "#define TARGET_PPC 1" >> $config_h echo "#define TARGET_PPCEMB 1" >> $config_h + echo "TARGET_PPC=yes" >> $configlibs_mak if test "$kvm" = "yes" ; then echo "CONFIG_KVM=yes" >> $config_mak echo "KVM_CFLAGS=$kvm_cflags" >> $config_mak @@ -1898,6 +1960,7 @@ case "$target_cpu" in echo "#define TARGET_ARCH \"ppc64\"" >> $config_h echo "#define TARGET_PPC 1" >> $config_h echo "#define TARGET_PPC64 1" >> $config_h + echo "TARGET_PPC64=yes" >> $configlibs_mak gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml" ;; ppc64abi32) @@ -1908,12 +1971,14 @@ case "$target_cpu" in echo "#define TARGET_PPC 1" >> $config_h echo "#define TARGET_PPC64 1" >> $config_h echo "#define TARGET_ABI32 1" >> $config_h + echo "TARGET_PPC64=yes" >> $configlibs_mak gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml" ;; sh4|sh4eb) echo "TARGET_ARCH=sh4" >> $config_mak echo "#define TARGET_ARCH \"sh4\"" >> $config_h echo "#define TARGET_SH4 1" >> $config_h + echo "TARGET_SH4=yes" >> $configlibs_mak bflt="yes" target_nptl="yes" ;; @@ -1921,12 +1986,14 @@ case "$target_cpu" in echo "TARGET_ARCH=sparc" >> $config_mak echo "#define TARGET_ARCH \"sparc\"" >> $config_h echo "#define TARGET_SPARC 1" >> $config_h + echo "TARGET_SPARC=yes" >> $configlibs_mak ;; sparc64) echo "TARGET_ARCH=sparc64" >> $config_mak echo "#define TARGET_ARCH \"sparc64\"" >> $config_h echo "#define TARGET_SPARC 1" >> $config_h echo "#define TARGET_SPARC64 1" >> $config_h + echo "TARGET_SPARC64=yes" >> $configlibs_mak elfload32="yes" ;; sparc32plus) @@ -1937,6 +2004,7 @@ case "$target_cpu" in echo "#define TARGET_SPARC 1" >> $config_h echo "#define TARGET_SPARC64 1" >> $config_h echo "#define TARGET_ABI32 1" >> $config_h + echo "TARGET_SPARC64=yes" >> $configlibs_mak ;; *) echo "Unsupported target CPU" -- 1.6.2.4