Skip to contentSkip to conversation

Check for gcc3 only if compiling dyngen targets

PATCH In review Hervé Poussineau 2 participants 2 messages Aug 22, 2008

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Check for gcc3 only if compiling dyngen targets

Hi,

If no configured target needs dyngen, gcc3.x is not required. Currently, you have to explicitly pass --disable-gcc-check flag to allow compilation.

Attached patch removes gcc check if no selected target needs dyngen. I had to move gcc4 detection later in the configure script

Hervé

configure +45 -34
Index: configure
===================================================================
@@ -468,40 +468,6 @@
     oss="no"
 fi
 
-# Check for gcc4, error if pre-gcc4
-if test "$check_gcc" = "yes" ; then
-    cat > $TMPC <<EOF
-#if __GNUC__ < 4
-#error gcc3
-#endif
-int main(){return 0;}
-EOF
-    if "$cc" $ARCH_CFLAGS -o $TMPE $TMPC 2> /dev/null ; then
-	echo "WARNING: \"$cc\" looks like gcc 4.x"
-	found_compat_cc="no"
-	if test "$gcc3_search" = "yes" ; then
-	    echo "Looking for gcc 3.x"
-	    for compat_cc in $gcc3_list ; do
-		if "$cross_prefix$compat_cc" --version 2> /dev/null | fgrep '(GCC) 3.' > /dev/null 2>&1 ; then
-		    echo "Found \"$compat_cc\""
-		    cc="$cross_prefix$compat_cc"
-		    found_compat_cc="yes"
-		    break
-		fi
-	    done
-	    if test "$found_compat_cc" = "no" ; then
-		echo "gcc 3.x not found!"
-	    fi
-	fi
-	if test "$found_compat_cc" = "no" ; then
-	    echo "QEMU is known to have problems when compiled with gcc 4.x"
-	    echo "It is recommended that you use gcc 3.x to build QEMU"
-	    echo "To use this compiler anyway, configure with --disable-gcc-check"
-	    exit 1;
-	fi
-    fi
-fi
-
 #
 # Solaris specific configure tool chain decisions
 #
@@ -1305,6 +1271,7 @@
 bflt="no"
 elfload32="no"
 target_nptl="no"
+requires_gcc3="no"
 interp_prefix1=`echo "$interp_prefix" | sed "s/%M/$target_cpu/g"`
 echo "#define CONFIG_QEMU_PREFIX \"$interp_prefix1\"" >> $config_h
 
@@ -1341,6 +1308,7 @@
     echo "#define TARGET_ARCH \"alpha\"" >> $config_h
     echo "#define TARGET_ALPHA 1" >> $config_h
     echo "#define CONFIG_DYNGEN_OP 1" >> $config_h
+    requires_gcc3="yes"
   ;;
   arm|armeb)
     echo "TARGET_ARCH=arm" >> $config_mak
@@ -1385,6 +1353,7 @@
     echo "#define TARGET_ARCH \"ppc\"" >> $config_h
     echo "#define TARGET_PPC 1" >> $config_h
     echo "#define CONFIG_DYNGEN_OP 1" >> $config_h
+    requires_gcc3="yes"
   ;;
   ppcemb)
     echo "TARGET_ARCH=ppcemb" >> $config_mak
@@ -1394,6 +1363,7 @@
     echo "#define TARGET_PPC 1" >> $config_h
     echo "#define TARGET_PPCEMB 1" >> $config_h
     echo "#define CONFIG_DYNGEN_OP 1" >> $config_h
+    requires_gcc3="yes"
   ;;
   ppc64)
     echo "TARGET_ARCH=ppc64" >> $config_mak
@@ -1403,6 +1373,7 @@
     echo "#define TARGET_PPC 1" >> $config_h
     echo "#define TARGET_PPC64 1" >> $config_h
     echo "#define CONFIG_DYNGEN_OP 1" >> $config_h
+    requires_gcc3="yes"
   ;;
   ppc64abi32)
     echo "TARGET_ARCH=ppc64" >> $config_mak
@@ -1414,6 +1385,7 @@
     echo "#define TARGET_PPC64 1" >> $config_h
     echo "#define TARGET_ABI32 1" >> $config_h
     echo "#define CONFIG_DYNGEN_OP 1" >> $config_h
+    requires_gcc3="yes"
   ;;
   sh4|sh4eb)
     echo "TARGET_ARCH=sh4" >> $config_mak
@@ -1422,6 +1394,7 @@
     echo "#define TARGET_SH4 1" >> $config_h
     echo "#define CONFIG_DYNGEN_OP 1" >> $config_h
     bflt="yes"
+    requires_gcc3="yes"
   ;;
   sparc)
     echo "TARGET_ARCH=sparc" >> $config_mak
@@ -1503,6 +1476,44 @@
 
 done # for target in $targets
 
+if test "$requires_gcc3" = "no" ; then
+  check_gcc="no"
+fi
+
+# Check for gcc4, error if pre-gcc4
+if test "$check_gcc" = "yes" ; then
+    cat > $TMPC <<EOF
+#if __GNUC__ < 4
+#error gcc3
+#endif
+int main(){return 0;}
+EOF
+    if "$cc" $ARCH_CFLAGS -o $TMPE $TMPC 2> /dev/null ; then
+	echo "WARNING: \"$cc\" looks like gcc 4.x"
+	found_compat_cc="no"
+	if test "$gcc3_search" = "yes" ; then
+	    echo "Looking for gcc 3.x"
+	    for compat_cc in $gcc3_list ; do
+		if "$cross_prefix$compat_cc" --version 2> /dev/null | fgrep '(GCC) 3.' > /dev/null 2>&1 ; then
+		    echo "Found \"$compat_cc\""
+		    cc="$cross_prefix$compat_cc"
+		    found_compat_cc="yes"
+		    break
+		fi
+	    done
+	    if test "$found_compat_cc" = "no" ; then
+		echo "gcc 3.x not found!"
+	    fi
+	fi
+	if test "$found_compat_cc" = "no" ; then
+	    echo "QEMU is known to have problems when compiled with gcc 4.x"
+	    echo "It is recommended that you use gcc 3.x to build QEMU"
+	    echo "To use this compiler anyway, configure with --disable-gcc-check"
+	    exit 1;
+	fi
+    fi
+fi
+
 # build tree in object directory if source path is different from current one
 if test "$source_path_used" = "yes" ; then
     DIRS="tests tests/cris slirp audio"
#1 lore raw
Quoted 8 lines · Hervé Poussineau

Hi,

If no configured target needs dyngen, gcc3.x is not required. Currently, you have to explicitly pass --disable-gcc-check flag to allow compilation.

Attached patch removes gcc check if no selected target needs dyngen. I had to move gcc4 detection later in the configure script

This patch breaks gcc3 autodetection in a subtle way. You more the autodetect down much further after $cc is used to compile a bunch of test executables. gcc3 autodetection may change $cc so all of those compile tests are now invalid.

I posted a patch a while ago that did basically the same thing but didn't suffer from this problem. Paul Brook basically Nacked it though as it's a lot of ugliness for little short term gain. Let's wait a bit longer and hope that the remaining targets get converted to TCG before doing a partial switch to gcc4.

Regards,

Anthony Liguori

Quoted 2 lines

Hervé