summaryrefslogtreecommitdiffstats
path: root/gcc/test_driver
blob: 6697e3439099ba29a2e51c44a15b24736e946064 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
#! /usr/bin/eval bash
#
#  Test Driver
#
#  test_driver CPUs|all
#

vfile=`dirname $0`/../VERSIONS
if [ ! -r ${vfile} ] ; then
  echo VERSIONS file not found
  exit 1
fi

source ${vfile}

if [ ! -d ${BASEDIR} ] ; then
  echo Have you set the BASEDIR in VERSIONS correctly?
  exit 1
fi

BASEDIR=`pwd`

for d in ${AUTOCONF} ${AUTOMAKE} ${BINUTILSDIR} \
    ${GDBDIR} ${NEWLIBDIR} ${GCCDIR}
do
  if [ ! -d ${d} ] ; then
    echo "Cannot locate ${d} -- aborting"
    exit 1
  fi
done

toggle()
{
  case $1 in
    no)  echo "yes" ;;
    yes) echo "no" ;;
    *)   fatal "Unknown value to toggle ($1)" ;;
  esac
}

usage()
{
cat <<EOF
test_driver [options] CPU ..  CPU
  -A - enable clean, native, and update
  -1 - build basic tools (default=yes)
  -a - build Ada (default=yes)
  -G - build GCC Go (default=yes)
  -J - build GCJ (default=yes)
  -c - clean install point (also installs auto tools)
  -m - mail results to lists (default=yes)
  -n - build native
  -T - run tests (default=yes)
  -u - update GNU source if version from CVS/SVN
  -U - update RTEMS source if version from CVS/SVN (will bootstrap)
  -v - verbose
EOF
}

doCleanInstallPoint="no"
doUpdateTools="no"
doUpdateRTEMS="no"
doNative="no"
doBasicTools="yes"
verbose="yes"
doAda="yes"
doGccGo="yes"
doGcj="yes"
doMail="yes"
doObjC="yes"
doFORTRAN="yes"
doTests="yes"
justTests="no"
checkOptionsAndExit="no"

while getopts J1AacmnuCGTUfOv OPT
do
  case "$OPT" in
    A) doCleanInstallPoint=`toggle ${doCleanInstallPoint}`
       doNative=`toggle ${doNative}`
       doUpdateTools=`toggle ${doUpdateTools}`
       doUpdateRTEMS=`toggle ${doUpdateRTEMS}`
       ;;
    1) doBasicTools=`toggle ${doBasicTools}` ;;
    a) doAda=`toggle ${doAda}` ;;
    C) checkOptionsAndExit=`toggle ${checkOptionsAndExit}` ;;
    G) doGccGo=`toggle ${doGccGo}` ;;
    J) doGcj=`toggle ${doGcj}` ;;
    f) doFORTRAN=`toggle ${doFORTRAN}` ;;
    O) doObjC=`toggle ${doObjC}` ;;
    c) doCleanInstallPoint=`toggle ${doCleanInstallPoint}` ;;
    j) justTests=`toggle ${justTests}` ;;
    m) doMail=`toggle ${doMail}` ;;
    n) doNative=`toggle ${doNative}` ;;
    T) doTests=`toggle ${doTests}` ;;
    u) doUpdateTools=`toggle ${doUpdateTools}` ;;
    U) doUpdateRTEMS=`toggle ${doUpdateRTEMS}` ;;
    v) verbose=`toggle ${verbose}` ;;
    *) usage; exit 1;
  esac
done

shiftcount=`expr $OPTIND - 1`
shift $shiftcount

args=$*

CPUs=""
for cpu in ${args}
do
  if [ ${cpu} = "native" ] ; then
    doNative="yes"
  else
    CPUs="${CPUs} ${cpu}"
  fi
done

CPUS_PART1="avr arm h8300 i386 m32c mips sh sparc64"
CPUS_PART2="bfin lm32 m32r m68k powerpc sparc"
ALL_CPUs="${CPUS_PART1} ${CPUS_PART2}"

if  [ "X${CPUs}" = "Xall" -o "X${CPUs}" = "X all" ] ; then
  CPUs="${ALL_CPUs}"
elif [ "X${CPUs}" = "X part1" ] ; then
  CPUs="${CPUS_PART1}"
elif [ "X${CPUs}" = "X part2" ] ; then
  CPUs="${CPUS_PART2}"
elif [ "X${CPUs}" = "X" -a ${doNative} = "no" ] ; then
  echo "No CPUs specified to test"
  exit 1
fi

if [ ${verbose} = "yes" ] ; then
  echo "Clean Install Point: " ${doCleanInstallPoint}
  echo "Install Autotools:   " ${doCleanInstallPoint}
  echo "Install Native:      " ${doNative}
  echo "Update Tool Source:  " ${doUpdateTools}
  echo "Update RTEMS:        " ${doUpdateRTEMS}
  echo "Build Basic Tools:   " ${doBasicTools}
  echo "Build Ada:           " ${doAda}
  echo "Build GCC Go:        " ${doGccGo}
  echo "Build GCJ:           " ${doGcj}
  echo "Build Objective-C    " ${doObjC}
  echo "Build FORTRAN        " ${doFORTRAN}
  echo "Email Results:       " ${doMail}
  echo "Run Tests:           " ${doTests}
  echo "CPUs to Build:       " ${CPUs}
fi

test ${checkOptionsAndExit} = "yes" && exit 0

test ${doMail}  = "no"       && mailArg="-M"
test ${doTests} = "yes"      && testArg="-T"
test ${doAda}   = "yes"      && adaArg="-a"
test ${doGccGo} = "yes"      && gccgoArg="-G"
test ${doGcj} = "yes"        && gcjArg="-J"
test ${doObjC} = "yes"       && objcArg="-O"
test ${doFORTRAN} = "yes"    && fortrancArg="-f"
test ${doBasicTools} = "yes" && basicArgs="-b -D -1 -r"

echo "Checking for just tests override"
if [ ${justTests} = "yes" ] ; then
  adaArg=""
  gccgoArg=""
  gcjArg=""
  objcArg=""
  fortranArg=""
  basicArgs=""
fi

start=`date`
echo Started at: ${start}

# HELPER - Update RTEMS
update_rtems()
{
  cd ${RTEMSDIR}
  if [ -d CVS ] ; then
    cvs up -Pd 2>&1 | grep -v ^cvs
    ./bootstrap -c
    ./bootstrap
  fi
}

# HELPER - Update GCC
update_gcc()
{
  cd ${GCCDIR}
  if [ -d .svn ] ; then
    grep "svn+ssh" .svn/entries >/dev/null
    if [ $? -eq 0 ] ; then
      echo "Skipping gcc update -- ssh keyed check out"
    else
      echo "Updating gcc -- anonymous check out"
      ./contrib/gcc_update
      if [ $? -ne 0 ] ; then
        echo "Update of GCC Failed."
        exit 1 
      fi
   fi
  fi
  return 0 
}

# HELPER - Remove all the installed previous builds
clean_up()
{
  rm -rf ${INSTALL}/* ${BSP_INSTALL}/*
}

install_auto()
{
  for auto in ${AUTOCONF} ${AUTOMAKE}
  do
    cd ${auto}
    make distclean
    ./configure --prefix=${INSTALL}
    make all install
  done
}

install_ppl()
{
  if [ x${PPL} != x ] ; then
    if [ ! -r ${INSTALL}/lib/libppl.a ] ; then
      echo "*** Building PPL ***"
      cd ${PPL}
      make distclean
      ./configure --enable-watchdog --prefix=${INSTALL}
      make ${MAKEJOBS} all install
    fi
  fi
}

# This handles GNU tools from CVS
update_others()
{
  for d in ${BINUTILSDIR} ${GDBDIR} ${NEWLIBDIR}
  do
    
    cd ${d} 
    if [ -d .svn ] ; then
      echo "I do not update SVN for ${d}"
      exit 1
   fi
   if [ -d CVS ] ; then
     cvs up -P 2>&1 | grep -v ^cvs
   fi
  done
}

build_cpu()
{
  bsp=

  exitStatus=0
  for cpu in $*
  do
    case $cpu in
      arm)     bsp=edb7312      ;;
      avr)     bsp=avrtest      ;;
      bfin)    bsp=eZKit533     ;;
      h8300)   bsp=h8sim        ;;
      i386)    bsp=pc386        ;;
      lm32)    bsp=lm32_evr     ;;
      m32c)    bsp=m32csim      ;;
      m32r)    bsp=m32rsim      ;;
      m68k)    bsp=uC5282       ;;
      mips)    bsp=jmr3904      ;;
      powerpc) bsp=psim         ;;
      sh)      bsp=simsh1       ;;
      sparc)   bsp=sis          ;;
      sparc64) bsp=niagara      ;;
      *)
	echo "Unknown CPU ${cpu}"
	exit 1
	;;
    esac

    doOne=${SCRIPTDIR}/gcc/do_one 
    echo "Building ${cpu}/${bsp}..." 
    echo "time sh -x ${doOne} -v -d ${basicArgs}  \
        ${gccgoArg} ${gcjArg} ${adaArg} ${objcArg} ${fortranArg} \
        ${mailArg} ${testArg} \ ${cpu} ${bsp} >${BASEDIR}/${bsp}.log 2>&1"
    time sh -x ${doOne} -v -d ${basicArgs}  \
        ${gccgoArg} ${gcjArg} ${adaArg} ${objcArg} ${fortranArg} \
        ${mailArg} ${testArg} \ ${cpu} ${bsp} >${BASEDIR}/${bsp}.log 2>&1
    echo $?
  done

  stopped=`date`
  echo Started at: ${start}
  echo Stopped at: ${stopped}
}

if [ ${doCleanInstallPoint} = "yes" ] ; then
  # Clean the install point
  clean_up
fi

# Update gcc and install autotools in parallel
  if [ ! -r ${INSTALL}/bin/autoconf ] ; then
    install_auto
  fi
  if [ ${doUpdateTools} = "yes" ] ; then
    update_gcc
    update_others
  fi
  if [ ! -r ${INSTALL}/lib/libppl.a ] ; then
    install_ppl
  fi
wait

# Do any remaining prep work in parallel
  if [ ${doUpdateRTEMS} = "yes" ] ; then
    update_rtems
  fi
wait

do_cpus=yes
if [ ${doNative} = "yes" ]; then
  # Build the native compiler as a baseline to build the others
  time sh -x ${SCRIPTDIR}/gcc/do_one -n >${BASEDIR}/native.log 2>&1
  if [ $? -ne 0 ] ; then
    do_cpus=no
  fi
fi

# Now cycle over all these CPUs
if [ ${do_cpus} = yes ] ; then
  for cpu in ${CPUs}
  do
    build_cpu ${cpu}
  done
fi

stopped=`date`
echo Started at: ${start}
echo Stopped at: ${stopped}