diff -ruN qemu.ORIG/configure qemu/configure --- qemu.ORIG/configure 2008-05-04 17:21:08.000000000 -0400 +++ qemu/configure 2008-05-04 17:36:55.000000000 -0400 @@ -1199,6 +1199,13 @@ then echo "#define USE_KQEMU 1" >> $config_h fi + gcc3minver=`$cc --version 2> /dev/null| fgrep "(GCC) 3." | awk '{ print $3 }' | cut -f2 -d.` + if test -n "$gcc3minver" -a $gcc3minver -gt 3 + then + echo "HAVE_GT_GCC_3_3=true" >> $config_mak + else + echo "HAVE_GT_GCC_3_3=false" >> $config_mak + fi ;; x86_64) echo "TARGET_ARCH=x86_64" >> $config_mak diff -ruN qemu.ORIG/Makefile.target qemu/Makefile.target --- qemu.ORIG/Makefile.target 2008-05-04 17:21:08.000000000 -0400 +++ qemu/Makefile.target 2008-05-04 20:58:47.000000000 -0400 @@ -96,6 +96,12 @@ ifeq ($(ARCH),i386) HELPER_CFLAGS+=-fomit-frame-pointer OP_CFLAGS+=-mpreferred-stack-boundary=2 -fomit-frame-pointer +# OP_CFLAGS needs this on 32-bit x86 system to avoid +# a compiler spill error. This can probably go away +# once the SSE ops have been converted to TCG +ifeq ($(HAVE_GT_GCC_3_3), true) +MTUNE_CFLAGS=-march=i486 -mtune=i686 +endif endif ifeq ($(ARCH),ppc) @@ -309,7 +315,7 @@ $(DYNGEN) -g -o $@ $< op.o: op.c - $(CC) $(OP_CFLAGS) $(CPPFLAGS) -c -o $@ $< + $(CC) $(OP_CFLAGS) $(CPPFLAGS) $(MTUNE_CFLAGS) -c -o $@ $< machine.o: machine.c $(CC) $(OP_CFLAGS) $(CPPFLAGS) -c -o $@ $< @@ -317,9 +323,24 @@ # HELPER_CFLAGS is used for all the code compiled with static register # variables ifeq ($(TARGET_BASE_ARCH), i386) + # if current host is i386 and gcc >= -3.4, CFLAGS requires some + # handling as helper.c generates a compiler spill error if + # "-march=i686 -mtune=i686" or -"march=athlon-xp -mtune=athlon-xp" + # We set MTUNE_CFLAGS="-march=i486 -mtune=i686" here + # Once SSE ops are converted to TCG, this can go away + HCFLAGS=$(CFLAGS) + ifeq ($(ARCH), i386) + ifeq ($(HAVE_GT_GCC_3_3), true) + # if CFLAGS has -march=i686, remove it so helper.o + # can compile on 32-bit intel systems + HCFLAGS=`echo $(CFLAGS) | sed 's,-march=i686,,' | sed 's,-mtune=i686,,' \ + | sed 's,-march=athlon-xp,,' | sed 's,-mtune=athlon-xp,,'` + endif + endif + # XXX: rename helper.c to op_helper.c helper.o: helper.c - $(CC) $(HELPER_CFLAGS) $(CPPFLAGS) $(CFLAGS) -c -o $@ $< + $(CC) $(HELPER_CFLAGS) $(CPPFLAGS) $(MTUNE_CFLAGS) $(HCFLAGS) -c -o $@ $< else op_helper.o: op_helper.c $(CC) $(HELPER_CFLAGS) $(CPPFLAGS) $(CFLAGS) -c -o $@ $<