blob: 1dce4507932ccaa3e27c43234873d56a05776dda [file] [log] [blame]
Kevin O'Connor03f630e2009-03-26 20:45:36 -04001#!/bin/sh
2# Script to test if gcc's -combine option works properly.
3
4mkdir -p out
5TMPFILE1=out/tmp_testcompile1.c
6TMPFILE1o=out/tmp_testcompile1.o
7TMPFILE2=out/tmp_testcompile2.c
8TMPFILE2o=out/tmp_testcompile2.o
9TMPFILE3o=out/tmp_testcompile3.o
10
11# Test for "-fwhole-program"
12gcc -fwhole-program -S -o /dev/null -xc /dev/null > /dev/null 2>&1
13if [ $? -ne 0 ]; then
14 echo "This version of gcc does not support -fwhole-program." > /dev/fd/2
15 echo "Please upgrade to gcc v4.1 or later" > /dev/fd/2
16 echo -1
17 exit -1
18fi
19
20# Test if "visible" functions are marked global.
21cat - > $TMPFILE1 <<EOF
22void __attribute__((externally_visible)) t1() { }
23EOF
24$CC -c -fwhole-program $TMPFILE1 -o $TMPFILE1o > /dev/null 2>&1
25cat - > $TMPFILE2 <<EOF
26void t1();
27void __attribute__((externally_visible)) main() { t1(); }
28EOF
29$CC -c -fwhole-program $TMPFILE2 -o $TMPFILE2o > /dev/null 2>&1
30$CC $TMPFILE1o $TMPFILE2o -o $TMPFILE3o > /dev/null 2>&1
31if [ $? -ne 0 ]; then
32 echo " Working around non-global functions in -fwhole-program" > /dev/fd/2
33fi
34
35# Test if "-combine" works
36mkdir -p out
37cat - > $TMPFILE1 <<EOF
38struct ts { union { int u1; struct { int u2; }; }; };
39void t1(struct ts *r);
40EOF
41$CC -c -fwhole-program -combine $TMPFILE1 $TMPFILE1 -o $TMPFILE1o > /dev/null 2>&1
42if [ $? -eq 0 ]; then
43 #echo " Setting AVOIDCOMBINE=0" > /dev/fd/2
44 echo 0
45else
46 echo " Enabling AVOIDCOMBINE=1" > /dev/fd/2
47 echo 1
48fi
49
50rm -f $TMPFILE1 $TMPFILE1o $TMPFILE2 $TMPFILE2o $TMPFILE3o