Test for broken gcc -combine on FC12.
authorKevin O'Connor <kevin@koconnor.net>
Fri, 20 Nov 2009 14:19:28 +0000 (09:19 -0500)
committerKevin O'Connor <kevin@koconnor.net>
Fri, 20 Nov 2009 14:19:28 +0000 (09:19 -0500)
The Fedora Core 12 distro throws an internal compiler error due to a
    bug in gcc.  Look for this case and avoid using -combine if found.

tools/test-gcc.sh

index e189f25d5d1ebc816af86590324ac78850decc5f..3bb91e97d7d1d2cba1a27cbc6283dfb007296596 100755 (executable)
@@ -43,13 +43,30 @@ fi
 
 # Test if "-combine" works.  On Ubuntu 8.04 the compiler doesn't work
 # correctly with combine and the "struct bregs" register due to the
-# anonymous unions and structs.
-mkdir -p out
+# anonymous unions and structs.  On Fedora Core 12 the compiler throws
+# an internal compiler error when multiple files access global
+# variables with debugging enabled.
 cat - > $TMPFILE1 <<EOF
+// Look for anonymous union/struct failure
 struct ts { union { int u1; struct { int u2; }; }; };
-void t1(struct ts *r);
+void func1(struct ts *r);
+
+// Look for global variable failure.
+struct s1_s { int v; } g1;
+void __attribute__((externally_visible)) func2() {
+    struct s1_s *l1 = &g1;
+}
 EOF
-$CC -c -fwhole-program -combine $TMPFILE1 $TMPFILE1 -o $TMPFILE1o > /dev/null 2>&1
+cat - > $TMPFILE2 <<EOF
+struct ts { union { int u1; struct { int u2; }; }; };
+void func1(struct ts *r);
+
+extern struct s1_s g1;
+void func3() {
+    &g1;
+}
+EOF
+$CC -O -g -fwhole-program -combine -c $TMPFILE1 $TMPFILE2 -o $TMPFILE1o > /dev/null 2>&1
 if [ $? -eq 0 ]; then
     echo 0
 else
@@ -57,6 +74,12 @@ else
     echo 1
 fi
 
+# Also, on several compilers, -combine fails if code is emitted with a
+# reference to an extern variable that is later found to be externally
+# visible - the compiler does not mark those variables as global.
+# This is being worked around by ordering the compile objects to avoid
+# this case.
+
 # Also, the Ubuntu 8.04 compiler has a bug causing corruption when the
 # "ebp" register is clobberred in an "asm" statement.  The code has
 # been modified to not clobber "ebp" - no test is available yet.