Home | History | Annotate | Line # | Download | only in contrib
compare-all-tests revision 1.1.1.6
      1      1.1  mrg #! /bin/bash
      2      1.1  mrg 
      3      1.1  mrg # Compare the assembly language output for all the gcc tests.
      4  1.1.1.6  mrg # Copyright (C) 2009-2024 Free Software Foundation, Inc.
      5      1.1  mrg # Contributed by Paolo Bonzini.
      6      1.1  mrg #
      7      1.1  mrg # Invoke it as "bash compare-all-tests target1 target2 ... targetN".
      8      1.1  mrg # Assumptions are:
      9      1.1  mrg #
     10      1.1  mrg # 1) that the base and patched compilers reside respectively in
     11      1.1  mrg # base-$target-build and $target-build, where $target is the commandline
     12      1.1  mrg # argument to compare-all-tests, and should match the variables in the
     13      1.1  mrg # script itself so that the correct set of options is tested.  Both
     14      1.1  mrg # compilers should be fully built (including target libraries).
     15      1.1  mrg # 
     16      1.1  mrg # 2) that the testsuite has been run on the base compiler (since it's
     17      1.1  mrg # just compilation testing, using RUNTESTFLAGS=--target_board=basic-sim
     18      1.1  mrg # usually suffices).
     19      1.1  mrg # 
     20      1.1  mrg # Tests that fail to compile on the base compiler are not compared.
     21      1.1  mrg 
     22      1.1  mrg alpha_opts='-mlong-double-64/-mieee -mlong-double-64 -mlong-double-128/-mieee -mlong-double-128'
     23      1.1  mrg arm_opts='-mthumb/-march=armv5t -mthumb/-march=armv6t2 -march=armv5 -mthumb/-march=armv6t2/-mfpu=vfp/-mfloat-abi=softfp -march=armv5/-mfpu=vfp/-mfloat-abi=softfp'
     24      1.1  mrg cris_opts='-march=v32 -march=v1'
     25      1.1  mrg h8300_opts='/ -mh -mh/-mn -ms -ms/-mn -msx -msx/-mn -mint32 -mh/-mint32 -mh/-mn/-mint32 -ms/-mint32 -ms/-mn/-mint32 -msx/-mint32 -msx/-mn/-mint32'
     26      1.1  mrg i386_opts='-m32 -m64 -m32/-msse/-msse2/-mfpmath=sse'
     27      1.1  mrg m32c_opts='-mcpu=r8c -mcpu=m16c -mcpu=m32c'
     28      1.1  mrg m68k_opts='-m68000 -m68020 -m68020/-m68881 -m68040/-m68881 -m68060/-m68881 -mcfv4e'
     29      1.1  mrg mips_opts='-msoft-float/-mgp32/-mips16 -mabi=32/-mfp32/-mgp32/-mips16 -mabi=o64/-mfp64/-mgp64/-mips16 -msoft-float/-mgp32 -mfp32/-mgp32 -march=mips64r2/-mabi=32/-mfp64/-mgp32 -msoft-float/-mgp64 -msingle-float/-mfp32/-mgp64 -mfp64/-mgp64'
     30      1.1  mrg mn10300_opts='-mam33 -mam33-2'
     31      1.1  mrg pa_opts='-march=2.0 -march=1.0 -march=1.1'
     32      1.1  mrg ppc_opts='-m32 -m64'
     33      1.1  mrg s390_opts='-m31 -m31/-mzarch -m64'
     34      1.1  mrg sh_opts='-m3 -m3e -m4 -m4a -m4al -m4/-mieee -m1 -m1/-mno-cbranchdi -m2a -m2a/-mieee -m2e -m2e/-mieee'
     35      1.1  mrg sparc_opts='-mcpu=v8/-m32 -mcpu=v9/-m32 -m64'
     36      1.1  mrg 
     37  1.1.1.5  mrg all_targets='alpha arm avr bfin cris fr30 frv h8300 ia64 iq2000 m32c m32r m68k mcore mips mmix mn10300 pa pdp11 ppc sh sparc v850 vax xstormy16 xtensa' # e500 
     38      1.1  mrg 
     39      1.1  mrg test_one_file ()
     40      1.1  mrg {
     41      1.1  mrg   local bdir pdir opts bline pline
     42      1.1  mrg   bdir=base-$1-gcc-build
     43      1.1  mrg   pdir=$1-gcc-build
     44      1.1  mrg   bline=$2
     45      1.1  mrg   pline=${2//$bdir/$pdir}
     46      1.1  mrg   opts=${3//\// }
     47      1.1  mrg   echo "$pline $opts"
     48      1.1  mrg   $bline $opts 2>/dev/null >/dev/null || return 0
     49      1.1  mrg   diff -L "$bdir/gcc/cc1 $opts" -L "$pdir/gcc/cc1 $opts" -u \
     50      1.1  mrg     <( $bline $opts 2>&1 ) <( $pline $opts 2>&1 ) || { echo -n . >&2; return 1; }
     51      1.1  mrg }
     52      1.1  mrg   
     53      1.1  mrg test_all_opts ()
     54      1.1  mrg {
     55      1.1  mrg   eval opts=\$${1}_opts
     56      1.1  mrg   if test -z "$opts"; then
     57      1.1  mrg     test_one_file $1 "$2"
     58      1.1  mrg   else
     59      1.1  mrg     for opt in $opts; do
     60      1.1  mrg       test_one_file $1 "$2" $opt
     61      1.1  mrg     done
     62      1.1  mrg   fi
     63      1.1  mrg }
     64      1.1  mrg 
     65      1.1  mrg for target in ${*-$all_targets}; do
     66      1.1  mrg   mkdir -p $target-gcc-build/gcc/testsuite/gcc
     67      1.1  mrg   cp -R base-$target-gcc-build/gcc/testsuite/gcc/gcc.dg-struct-layout-1 \
     68      1.1  mrg     $target-gcc-build/gcc/testsuite/gcc/gcc.dg-struct-layout-1 
     69      1.1  mrg 
     70      1.1  mrg   # Provide targ-include files for newlib
     71      1.1  mrg   # for newlib_path in `echo base-$target-gcc-build/*/newlib`; do
     72      1.1  mrg   #   test -d $newlib_path && ln -sf ../../$newlib_path ${newlib_path/base-}
     73      1.1  mrg   # done
     74      1.1  mrg 
     75      1.1  mrg   echo -n Testing $target >&2
     76      1.1  mrg   sed '/^Executing on host: /!d
     77      1.1  mrg     /xgcc -B/!d
     78      1.1  mrg     / -E /d
     79      1.1  mrg     / -g/d
     80      1.1  mrg     / -print-prog-name=/d
     81      1.1  mrg     s/^Executing on host: //
     82      1.1  mrg     s/   *(timeout.*//
     83      1.1  mrg     s/ -fverbose-asm / /
     84      1.1  mrg     s/ -frtl-abstract-sequences / /
     85      1.1  mrg     s/ -fdump[-a-z0-9]* / /g
     86      1.1  mrg     s/ -da / /g
     87      1.1  mrg     s/ -\{1,2\}save-temps / /
     88      1.1  mrg     s/ -c / -S /
     89      1.1  mrg     / -S /! s/ -o / -S -o /
     90      1.1  mrg     s/ -o [^ ]*/ -frandom-seed=0 -o -/' base-$target-gcc-build/gcc/testsuite/gcc/gcc.log | while read line; do
     91      1.1  mrg     case "$line" in
     92      1.1  mrg       *" -m"*) test_one_file $target "$line" "" ;;
     93      1.1  mrg       *) test_all_opts $target "$line" ;;
     94      1.1  mrg     esac
     95      1.1  mrg   done > compare-$target.log
     96      1.1  mrg   echo >&2
     97      1.1  mrg done
     98