diff mbox

[RFC,0/5] Add configure flag to disable TCG

Message ID alpine.DEB.2.00.1109051525270.12963@kaball-desktop
State New
Headers show

Commit Message

Stefano Stabellini Sept. 5, 2011, 2:53 p.m. UTC
On Fri, 2 Sep 2011, Anthony Liguori wrote:
> Hi,
> 
> There have been a few attempts in the past to allow TCG to be disabled
> at build time.  Recently, Alex made the suggestion that we could do it by using
> the same trick that we used to introduce kvm support.  That involves introducing
> a tcg_enabled() macro that will be (0) if TCG is disabled in the build.
> 
> GCC is smart enough to do dead code elimination if it sees an if (0) and the
> result is that if you can do:
> 
> if (tcg_enabled()) {
>   foo();
> }
> 
> and it's more or less equivalent to:
> 
> #ifdef CONFIG_TCG
>   foo();
> #endif
> 
> Without the ugliness that comes from using the preprocessor.  I think this ended
> up being pretty straight forward.  exec.c could use a fair bit of cleanup but
> other than that, this pretty much eliminates all of the TCG code from the build.
> 
> This absolutely is going to break non-x86 KVM builds if they use the
> --disable-tcg flag as I haven't tested those yet.  The normal TCG build
> shouldn't be affected at all though.
> 
> In principle, the code assumes that you need KVM if you don't have TCG.  Of
> course, some extra logic could be added to allow for Xen if TCG isn't present.

I like the goal if the series very much and compilation with
--disable-tcg --enable-xen works out of the box!


However there are two problems:

- compilation with --disable-kvm --disable-xen (--enable-tcg) breaks on
my box, log attached;

- the automatic filtering on the target list introduced by the first
patch effectively prevents users from enabling xen with --disable-tcg,
unless they also enable kvm. See appended patch.
sstabellini@dt02:/local/scratch/sstabellini/qemu$ ./configure --disable-kvm --disable-xen --target-list=i386-softmmu
Install prefix    /usr/local
BIOS directory    /usr/local/share/qemu
binary directory  /usr/local/bin
library directory /usr/local/lib
include directory /usr/local/include
config directory  /usr/local/etc
Manual directory  /usr/local/share/man
ELF interp prefix /usr/gnemul/qemu-%M
Source path       /local/scratch/sstabellini/qemu
C compiler        gcc
Host C compiler   gcc
CFLAGS            -O2 -g 
QEMU_CFLAGS       -Werror -m64 -D_FORTIFY_SOURCE=2 -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -Wstrict-prototypes -Wredundant-decls -Wall -Wundef -Wwrite-strings -Wmissing-prototypes -fno-strict-aliasing  -fstack-protector-all -Wendif-labels -Wmissing-include-dirs -Wempty-body -Wnested-externs -Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers -Wold-style-declaration -Wold-style-definition -Wtype-limits -I/usr/include/libpng12   -I/usr/local/include/spice-server -I/usr/local/include/pixman-1 -I/usr/local/include -I/usr/local/include/spice-1  
LDFLAGS           -Wl,--warn-common -m64 -g 
make              make
install           install
python            python
smbd              /usr/sbin/smbd
host CPU          x86_64
host big endian   no
target list       i386-softmmu
tcg debug enabled no
Mon debug enabled no
gprof enabled     no
sparse enabled    no
strip binaries    yes
profiler          no
static build      no
-Werror enabled   yes
SDL support       yes
curses support    yes
curl support      no
check support     no
mingw32 support   no
Audio drivers     oss
Extra audio cards ac97 es1370 sb16 hda
Block whitelist   
Mixer emulation   no
VNC support       yes
VNC TLS support   no
VNC SASL support  no
VNC JPEG support  yes
VNC PNG support   yes
VNC thread        no
xen support       no
brlapi support    no
bluez  support    no
Documentation     yes
NPTL support      yes
GUEST_BASE        yes
PIE user targets  no
vde support       no
Linux AIO support yes
ATTR/XATTR support no
Install blobs     yes
KVM support       no
fdt support       no
preadv support    yes
fdatasync         yes
madvise           yes
posix_madvise     yes
uuid support      yes
vhost-net support yes
Trace backend     nop
Trace output file trace-<pid>
spice support     yes
rbd support       no
xfsctl support    no
nss used          no
usb net redir     no
OpenGL support    yes
build guest agent yes
sstabellini@dt02:/local/scratch/sstabellini/qemu$ make -j12
  GEN   config-host.h
  GEN   trace.h
  GEN   qemu-options.def
  GEN   qapi-generated/qga-qapi-visit.h
  GEN   trace.c
  CC    trace/control.o
  CC    trace/default.o
  GEN   qemu-img-cmds.h
  GEN   qapi-generated/qga-qapi-types.h
  GEN   qapi-generated/qga-qmp-marshal.c
  CC    qemu-ga.o
  CC    qga/guest-agent-commands.o
  CC    qga/guest-agent-command-state.o
  CC    qemu-tool.o
  CC    qemu-error.o
  CC    trace/default.o
  CC    trace/control.o
  CC    qint.o
  CC    qstring.o
  CC    qdict.o
  CC    qlist.o
  CC    qfloat.o
  CC    qjson.o
  CC    qbool.o
  CC    json-lexer.o
  CC    json-streamer.o
  CC    json-parser.o
  CC    qerror.o
  CC    error.o
  CC    qemu-nbd.o
  CC    qemu-thread-posix.o
  CC    cache-utils.o
  CC    async.o
  CC    nbd.o
  CC    block.o
  CC    aio.o
  CC    aes.o
  CC    qemu-config.o
  CC    qemu-progress.o
  CC    qemu-coroutine.o
  CC    qemu-coroutine-lock.o
  CC    coroutine-ucontext.o
  CC    posix-aio-compat.o
  CC    linux-aio.o
  CC    block/raw.o
  CC    block/cow.o
  CC    block/qcow.o
  CC    block/vdi.o
  CC    block/vmdk.o
  CC    block/cloop.o
  CC    block/dmg.o
  CC    block/bochs.o
  CC    block/vpc.o
  CC    block/vvfat.o
  CC    block/qcow2.o
  CC    block/qcow2-refcount.o
  CC    block/qcow2-cluster.o
  CC    block/qcow2-snapshot.o
  CC    block/qcow2-cache.o
  CC    block/qed.o
  CC    block/qed-gencb.o
  CC    block/qed-l2-cache.o
  CC    block/qed-table.o
  CC    block/qed-cluster.o
  CC    block/qed-check.o
  CC    block/parallels.o
  CC    block/nbd.o
  CC    block/blkdebug.o
  CC    block/sheepdog.o
  CC    block/blkverify.o
  CC    block/raw-posix.o
  CC    qemu-timer-common.o
  CC    qemu-img.o
  CC    qemu-io.o
  CC    cmd.o
  CC    libhw64/vl.o
  CC    blockdev.o
  CC    libhw64/loader.o
  CC    libhw64/virtio-console.o
  CC    libhw64/usb-libhw.o
  CC    net.o
  CC    net/queue.o
  CC    net/checksum.o
  CC    libhw64/virtio-pci.o
  CC    libhw64/fw_cfg.o
  CC    net/util.o
  CC    net/socket.o
  CC    net/dump.o
  CC    net/tap.o
  CC    net/tap-linux.o
  CC    net/slirp.o
  CC    readline.o
  CC    console.o
  CC    cursor.o
  CC    libhw64/pci.o
  CC    os-posix.o
  CC    tcg-runtime.o
  CC    host-utils.o
  CC    irq.o
  CC    ioport.o
  CC    libhw64/pci_bridge.o
  CC    input.o
  CC    libhw64/msix.o
  CC    i2c.o
  CC    smbus.o
  CC    smbus_eeprom.o
  CC    eeprom93xx.o
  CC    scsi-disk.o
  CC    cdrom.o
  CC    scsi-generic.o
  CC    libhw64/msi.o
  CC    scsi-bus.o
  CC    hid.o
  CC    usb.o
  CC    usb-hub.o
  CC    usb-linux.o
  CC    libhw64/pci_host.o
  CC    libhw64/pcie_host.o
  CC    usb-hid.o
  CC    usb-msd.o
  CC    libhw64/ioh3420.o
  CC    usb-wacom.o
  CC    usb-serial.o
  CC    libhw64/xio3130_upstream.o
  CC    libhw64/xio3130_downstream.o
  CC    usb-net.o
  CC    libhw64/watchdog.o
  CC    usb-bus.o
  CC    libhw64/serial.o
  CC    usb-desc.o
  CC    bt.o
  CC    bt-host.o
  CC    libhw64/parallel.o
  CC    bt-vhci.o
  CC    libhw64/i8254.o
  CC    bt-l2cap.o
  CC    libhw64/pcspk.o
  CC    bt-sdp.o
  CC    bt-hci.o
  CC    bt-hid.o
  CC    usb-bt.o
  CC    bt-hci-csr.o
  CC    buffered_file.o
  CC    libhw64/pckbd.o
  CC    libhw64/usb-uhci.o
  CC    libhw64/usb-ohci.o
  CC    migration.o
  CC    libhw64/usb-ehci.o
  CC    migration-tcp.o
  CC    qemu-char.o
  CC    savevm.o
  CC    msmouse.o
  CC    ps2.o
  CC    qdev.o
  CC    libhw64/fdc.o
  CC    qdev-properties.o
  CC    block-migration.o
  CC    iohandler.o
  CC    libhw64/acpi.o
  CC    pflib.o
  CC    bitmap.o
  CC    bitops.o
  CC    libhw64/acpi_piix4.o
  CC    migration-exec.o
  CC    migration-unix.o
  CC    migration-fd.o
  CC    libhw64/pm_smbus.o
  CC    libhw64/apm.o
  CC    ui/spice-core.o
  CC    ui/spice-input.o
  CC    ui/spice-display.o
  CC    spice-qemu-char.o
  CC    libhw64/dma.o
  CC    audio/audio.o
  CC    audio/noaudio.o
  CC    audio/wavaudio.o
  CC    libhw64/hpet.o
  CC    libhw64/applesmc.o
  CC    libhw64/usb-ccid.o
  CC    audio/mixeng.o
  CC    audio/sdlaudio.o
  CC    audio/ossaudio.o
  CC    audio/spiceaudio.o
  CC    libhw64/ccid-card-passthru.o
  CC    audio/wavcapture.o
  CC    libhw64/wdt_i6300esb.o
  CC    ui/keymaps.o
  CC    libhw64/pcie.o
  CC    libhw64/pcie_aer.o
  CC    ui/sdl.o
  CC    ui/sdl_zoom.o
  CC    ui/x_keymap.o
  CC    libhw64/pcie_port.o
  CC    libhw64/ne2000.o
  CC    ui/curses.o
  CC    libhw64/eepro100.o
  CC    ui/vnc.o
  CC    ui/d3des.o
  CC    ui/vnc-enc-zlib.o
  CC    libhw64/pcnet-pci.o
  CC    ui/vnc-enc-hextile.o
  CC    libhw64/pcnet.o
  CC    ui/vnc-enc-tight.o
  CC    ui/vnc-palette.o
  CC    libhw64/e1000.o
  CC    ui/vnc-enc-zrle.o
  CC    libhw64/rtl8139.o
  CC    libhw64/ne2000-isa.o
  CC    ui/vnc-jobs-sync.o
  CC    libhw64/ide/core.o
  CC    iov.o
  CC    libhw64/ide/atapi.o
  CC    acl.o
  CC    libhw64/ide/qdev.o
  CC    compatfd.o
  CC    notify.o
  CC    libhw64/ide/pci.o
  CC    event_notifier.o
  CC    libhw64/ide/isa.o
  CC    qemu-timer.o
  CC    slirp/cksum.o
  CC    libhw64/ide/piix.o
  CC    slirp/if.o
  CC    libhw64/ide/ahci.o
  CC    libhw64/ide/ich.o
  CC    libhw64/lsi53c895a.o
  CC    libhw64/dma-helpers.o
  CC    slirp/ip_icmp.o
  CC    slirp/ip_input.o
  CC    slirp/ip_output.o
  CC    libhw64/sysbus.o
  CC    slirp/slirp.o
  CC    libhw64/isa-bus.o
  CC    libhw64/qdev-addr.o
  CC    libhw64/vga-pci.o
  CC    slirp/mbuf.o
  CC    slirp/misc.o
  CC    slirp/sbuf.o
  CC    slirp/socket.o
  CC    libhw64/vga-isa.o
  CC    libhw64/vmware_vga.o
  CC    libhw64/vmmouse.o
  CC    libhw64/sb16.o
  CC    slirp/tcp_input.o
  CC    libhw64/es1370.o
  CC    slirp/tcp_output.o
  CC    slirp/tcp_subr.o
  CC    libhw64/ac97.o
  CC    slirp/tcp_timer.o
  CC    libhw64/intel-hda.o
  CC    slirp/udp.o
  CC    slirp/bootp.o
  CC    slirp/tftp.o
  CC    libhw64/hda-audio.o
  CC    slirp/arp_table.o
  AS    optionrom/multiboot.o
  AS    optionrom/linuxboot.o
  CC    libdis/i386-dis.o
  Building optionrom/multiboot.img
  Building optionrom/multiboot.raw
  Building optionrom/linuxboot.img
  CC    qemu-error.o
  Signing optionrom/multiboot.bin
  CC    qemu-sockets.o
  Building optionrom/linuxboot.raw
  Signing optionrom/linuxboot.bin
  CC    module.o
  CC    qemu-option.o
  CC    cutils.o
  CC    osdep.o
  CC    oslib-posix.o
  CC    qapi/qapi-visit-core.o
  CC    qapi/qmp-input-visitor.o
  CC    qapi/qmp-output-visitor.o
  CC    qapi/qapi-dealloc-visitor.o
  CC    qapi/qmp-registry.o
  CC    qapi/qmp-dispatch.o
  CC    trace.o
  CC    qapi-generated/qga-qapi-visit.o
  CC    qapi-generated/qga-qapi-types.o
  CC    qapi-generated/qga-qmp-marshal.o
  LINK  qemu-nbd
  LINK  qemu-io
  LINK  qemu-img
  LINK  qemu-ga
  GEN   config-target.h
  GEN   i386-softmmu/hmp-commands.h
  GEN   i386-softmmu/qmp-commands.h
  CC    i386-softmmu/arch_init.o
  CC    i386-softmmu/cpus.o
  CC    i386-softmmu/machine.o
  CC    i386-softmmu/gdbstub.o
  CC    i386-softmmu/balloon.o
  CC    i386-softmmu/virtio.o
  CC    i386-softmmu/virtio-blk.o
  CC    i386-softmmu/virtio-balloon.o
  CC    i386-softmmu/virtio-net.o
  CC    i386-softmmu/virtio-serial-bus.o
  CC    i386-softmmu/vhost_net.o
  CC    i386-softmmu/rwhandler.o
  CC    i386-softmmu/kvm-stub.o
  CC    i386-softmmu/memory.o
  CC    i386-softmmu/xen-stub.o
  CC    i386-softmmu/exec.o
  CC    i386-softmmu/helper.o
  CC    i386-softmmu/cpuid.o
  CC    i386-softmmu/disas.o
  CC    i386-softmmu/vga.o
  CC    i386-softmmu/mc146818rtc.o
  CC    i386-softmmu/i8259.o
  CC    i386-softmmu/pc.o
  CC    i386-softmmu/cirrus_vga.o
  CC    i386-softmmu/sga.o
  CC    i386-softmmu/apic.o
  CC    i386-softmmu/ioapic.o
  CC    i386-softmmu/piix_pci.o
  CC    i386-softmmu/vmport.o
rm multiboot.o linuxboot.raw linuxboot.img multiboot.raw multiboot.img linuxboot.o
  CC    i386-softmmu/device-hotplug.o
  CC    i386-softmmu/pci-hotplug.o
  CC    i386-softmmu/smbios.o
  CC    i386-softmmu/wdt_ib700.o
  CC    i386-softmmu/debugcon.o
  CC    i386-softmmu/multiboot.o
  CC    i386-softmmu/pc_piix.o
  CC    i386-softmmu/qxl.o
  CC    i386-softmmu/qxl-logger.o
  CC    i386-softmmu/qxl-render.o
  CC    i386-softmmu/monitor.o
  LINK  i386-softmmu/qemu-system-i386
cpus.o: In function `tcg_cpu_exec':
/local/scratch/sstabellini/qemu/cpus.c:919: undefined reference to `cpu_x86_exec'
exec.o: In function `tb_phys_invalidate':
/local/scratch/sstabellini/qemu/exec.c:912: undefined reference to `tb_invalidated_flag'
/local/scratch/sstabellini/qemu/exec.c:912: undefined reference to `tb_invalidated_flag'
exec.o: In function `tcg_exec_init':
/local/scratch/sstabellini/qemu/exec.c:585: undefined reference to `cpu_gen_init'
/local/scratch/sstabellini/qemu/exec.c:592: undefined reference to `tcg_ctx'
exec.o: In function `tb_gen_code':
/local/scratch/sstabellini/qemu/exec.c:1016: undefined reference to `tb_invalidated_flag'
/local/scratch/sstabellini/qemu/exec.c:1026: undefined reference to `cpu_x86_gen_code'
exec.o: In function `cpu_io_recompile':
/local/scratch/sstabellini/qemu/exec.c:4695: undefined reference to `cpu_restore_state'
exec.o: In function `slow_ldq_cmmu':
/local/scratch/sstabellini/qemu/softmmu_template.h:186: undefined reference to `tlb_fill'
exec.o: In function `__ldq_cmmu':
/local/scratch/sstabellini/qemu/softmmu_template.h:135: undefined reference to `tlb_fill'
exec.o: In function `slow_ldb_cmmu':
/local/scratch/sstabellini/qemu/softmmu_template.h:186: undefined reference to `tlb_fill'
exec.o: In function `__ldb_cmmu':
/local/scratch/sstabellini/qemu/softmmu_template.h:135: undefined reference to `tlb_fill'
exec.o: In function `slow_ldw_cmmu':
/local/scratch/sstabellini/qemu/softmmu_template.h:186: undefined reference to `tlb_fill'
exec.o:/local/scratch/sstabellini/qemu/softmmu_template.h:135: more undefined references to `tlb_fill' follow
exec.o: In function `tb_invalidate_phys_page_range':
/local/scratch/sstabellini/qemu/exec.c:1109: undefined reference to `cpu_restore_state'
exec.o: In function `check_watchpoint':
/local/scratch/sstabellini/qemu/exec.c:3450: undefined reference to `cpu_restore_state'
/local/scratch/sstabellini/qemu/exec.c:3460: undefined reference to `cpu_resume_from_signal'
exec.o: In function `dump_exec_info':
/local/scratch/sstabellini/qemu/exec.c:4794: undefined reference to `tcg_dump_info'
exec.o: In function `tcg_exec_init':
/local/scratch/sstabellini/qemu/exec.c:592: undefined reference to `tcg_prologue_init'
exec.o: In function `cpu_io_recompile':
/local/scratch/sstabellini/qemu/exec.c:4738: undefined reference to `cpu_resume_from_signal'
exec.o: In function `tb_invalidate_phys_page_range':
/local/scratch/sstabellini/qemu/exec.c:1147: undefined reference to `cpu_resume_from_signal'
helper.o: In function `breakpoint_handler':
/local/scratch/sstabellini/qemu/target-i386/helper.c:1058: undefined reference to `cpu_resume_from_signal'
/local/scratch/sstabellini/qemu/target-i386/helper.c:1065: undefined reference to `raise_exception_env'
helper.o: In function `cpu_x86_init':
/local/scratch/sstabellini/qemu/target-i386/helper.c:1267: undefined reference to `optimize_flags_init'
/local/scratch/sstabellini/qemu/target-i386/helper.c:1270: undefined reference to `cpu_set_debug_excp_handler'
collect2: ld returned 1 exit status
make[1]: *** [qemu-system-i386] Error 1
make: *** [subdir-i386-softmmu] Error 2
sstabellini@dt02:/local/scratch/sstabellini/qemu$
diff mbox

Patch

diff --git a/configure b/configure
index 3f2cf6a..64f85b6 100755
--- a/configure
+++ b/configure
@@ -3148,7 +3148,7 @@  if test "$static" = "no" -a "$user_pie" = "yes" ; then
   echo "QEMU_CFLAGS+=-fpie" > libdis-user/config.mak
 fi
 
-kvm_incompatible() {
+virt_incompatible() {
     if test "$kvm" = "yes" -a \
       \( "$1" = "$cpu" -o \
       \( "$1" = "ppcemb" -a "$cpu" = "ppc" \) -o \
@@ -3158,9 +3158,14 @@  kvm_incompatible() {
       \( "$1" = "x86_64" -a "$cpu" = "i386"   \) -o \
       \( "$1" = "i386"   -a "$cpu" = "x86_64" \) \) ; then
 	return 1
-    else
-	return 0
     fi
+    if test "$xen" = "yes" -a \ 
+      \( "$1" = "$cpu" -o \
+      \( "$1" = "x86_64" -a "$cpu" = "i386"   \) -o \
+      \( "$1" = "i386"   -a "$cpu" = "x86_64" \) \) ; then
+	return 1
+    fi
+    return 0
 }
 
 target_list2=
@@ -3219,7 +3224,7 @@  if test "$tcg" = "no"; then
     if test "$target_softmmu" = "no"; then
 	continue;
     fi
-    if kvm_incompatible "$target_arch2"; then
+    if virt_incompatible "$target_arch2"; then
 	continue;
     fi
 fi