2 # Script to test if gcc "-fwhole-program" works properly.
5 TMPFILE1=out/tmp_testcompile1.c
6 TMPFILE1o=out/tmp_testcompile1.o
7 TMPFILE2=out/tmp_testcompile2.c
8 TMPFILE2o=out/tmp_testcompile2.o
9 TMPFILE3o=out/tmp_testcompile3.o
11 # Test for "-fwhole-program"
12 $CC -fwhole-program -S -o /dev/null -xc /dev/null > /dev/null 2>&1
14 echo " Working around no -fwhole-program" > /dev/fd/2
19 # Test if "visible" variables are marked global.
20 cat - > $TMPFILE1 <<EOF
21 unsigned char t1 __attribute__((section(".data16.foo.19"))) __attribute__((externally_visible));
23 $CC -Os -c -fwhole-program $TMPFILE1 -o $TMPFILE1o > /dev/null 2>&1
24 cat - > $TMPFILE2 <<EOF
25 extern unsigned char t1;
26 int __attribute__((externally_visible)) main() { return t1; }
28 $CC -Os -c -fwhole-program $TMPFILE2 -o $TMPFILE2o > /dev/null 2>&1
29 $CC -nostdlib -Os $TMPFILE1o $TMPFILE2o -o $TMPFILE3o > /dev/null 2>&1
31 echo "This version of gcc does not properly handle" > /dev/fd/2
32 echo " global variables in -fwhole-program mode." > /dev/fd/2
33 echo "Please upgrade to a newer gcc (eg, v4.3 or later)" > /dev/fd/2
38 # Test if "visible" functions are marked global.
39 cat - > $TMPFILE1 <<EOF
40 void __attribute__((externally_visible)) t1() { }
42 $CC -Os -c -fwhole-program $TMPFILE1 -o $TMPFILE1o > /dev/null 2>&1
43 cat - > $TMPFILE2 <<EOF
45 void __attribute__((externally_visible)) main() { t1(); }
47 $CC -Os -c -fwhole-program $TMPFILE2 -o $TMPFILE2o > /dev/null 2>&1
48 $CC -nostdlib -Os $TMPFILE1o $TMPFILE2o -o $TMPFILE3o > /dev/null 2>&1
50 echo " Working around non-global functions in -fwhole-program" > /dev/fd/2
53 # Test if "-combine" works
55 cat - > $TMPFILE1 <<EOF
56 struct ts { union { int u1; struct { int u2; }; }; };
57 void t1(struct ts *r);
59 $CC -c -fwhole-program -combine $TMPFILE1 $TMPFILE1 -o $TMPFILE1o > /dev/null 2>&1
61 #echo " Setting AVOIDCOMBINE=0" > /dev/fd/2
64 echo " Enabling AVOIDCOMBINE=1" > /dev/fd/2
68 rm -f $TMPFILE1 $TMPFILE1o $TMPFILE2 $TMPFILE2o $TMPFILE3o