compare-all-tests 3.8 KB

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