libvtv.exp 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  1. # This program is free software; you can redistribute it and/or modify
  2. # it under the terms of the GNU General Public License as published by
  3. # the Free Software Foundation; either version 2 of the License, or
  4. # (at your option) any later version.
  5. #
  6. # This program is distributed in the hope that it will be useful,
  7. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  8. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  9. # GNU General Public License for more details.
  10. #
  11. # You should have received a copy of the GNU General Public License
  12. # along with this program; if not, write to the Free Software
  13. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  14. # Damn dejagnu for not having proper library search paths for load_lib.
  15. # We have to explicitly load everything that gcc-dg.exp wants to load.
  16. proc load_gcc_lib { filename } {
  17. global srcdir loaded_libs
  18. load_file $srcdir/../../gcc/testsuite/lib/$filename
  19. set loaded_libs($filename) ""
  20. }
  21. load_lib dg.exp
  22. # Required to use gcc-dg.exp - however, the latter should NOT be
  23. # loaded until ${tool}_target_compile is defined since it uses that
  24. # to determine default LTO options.
  25. load_gcc_lib multiline.exp
  26. load_gcc_lib prune.exp
  27. load_gcc_lib target-libpath.exp
  28. load_gcc_lib wrapper.exp
  29. load_gcc_lib target-supports.exp
  30. load_gcc_lib target-utils.exp
  31. load_gcc_lib gcc-defs.exp
  32. load_gcc_lib timeout.exp
  33. load_gcc_lib file-format.exp
  34. load_gcc_lib target-supports-dg.exp
  35. load_gcc_lib scanasm.exp
  36. load_gcc_lib scandump.exp
  37. load_gcc_lib scanrtl.exp
  38. load_gcc_lib scantree.exp
  39. load_gcc_lib scanltranstree.exp
  40. load_gcc_lib scanipa.exp
  41. load_gcc_lib scanwpaipa.exp
  42. load_gcc_lib timeout-dg.exp
  43. load_gcc_lib torture-options.exp
  44. load_gcc_lib fortran-modules.exp
  45. set dg-do-what-default run
  46. #
  47. # GCC_UNDER_TEST is the compiler under test.
  48. #
  49. set libvtv_compile_options ""
  50. #
  51. # libvtv_init
  52. #
  53. if [info exists TOOL_OPTIONS] {
  54. set multilibs [get_multilibs $TOOL_OPTIONS]
  55. } else {
  56. set multilibs [get_multilibs]
  57. }
  58. proc libvtv_init { args } {
  59. global srcdir blddir objdir tool_root_dir
  60. global libvtv_initialized
  61. global tmpdir
  62. global blddir
  63. global gluefile wrap_flags
  64. global ALWAYS_CFLAGS
  65. global CFLAGS
  66. global TOOL_EXECUTABLE TOOL_OPTIONS
  67. global GCC_UNDER_TEST
  68. global TESTING_IN_BUILD_TREE
  69. global target_triplet
  70. global always_ld_library_path
  71. set blddir [lookfor_file [get_multilibs] libvtv]
  72. # We set LC_ALL and LANG to C so that we get the same error
  73. # messages as expected.
  74. setenv LC_ALL C
  75. setenv LANG C
  76. if ![info exists GCC_UNDER_TEST] then {
  77. if [info exists TOOL_EXECUTABLE] {
  78. set GCC_UNDER_TEST $TOOL_EXECUTABLE
  79. } else {
  80. set GCC_UNDER_TEST "[find_gcc]"
  81. }
  82. }
  83. if ![info exists tmpdir] {
  84. set tmpdir "/tmp"
  85. }
  86. if [info exists gluefile] {
  87. unset gluefile
  88. }
  89. if {![info exists CFLAGS]} {
  90. set CFLAGS ""
  91. }
  92. # Locate libgcc.a so we don't need to account for different values of
  93. # SHLIB_EXT on different platforms
  94. set gccdir [lookfor_file $tool_root_dir gcc/libgcc.a]
  95. if {$gccdir != ""} {
  96. set gccdir [file dirname $gccdir]
  97. }
  98. # Compute what needs to be put into LD_LIBRARY_PATH
  99. set always_ld_library_path ".:${blddir}/.libs"
  100. # Compute what needs to be added to the existing LD_LIBRARY_PATH.
  101. if {$gccdir != ""} {
  102. # Add AIX pthread directory first.
  103. if { [llength [glob -nocomplain ${gccdir}/pthread/libgcc_s*.a]] >= 1 } {
  104. append always_ld_library_path ":${gccdir}/pthread"
  105. }
  106. append always_ld_library_path ":${gccdir}"
  107. set compiler [lindex $GCC_UNDER_TEST 0]
  108. if { [is_remote host] == 0 && [which $compiler] != 0 } {
  109. foreach i "[exec $compiler --print-multi-lib]" {
  110. set mldir ""
  111. regexp -- "\[a-z0-9=_/\.-\]*;" $i mldir
  112. set mldir [string trimright $mldir "\;@"]
  113. if { "$mldir" == "." } {
  114. continue
  115. }
  116. if { [llength [glob -nocomplain ${gccdir}/${mldir}/libgcc_s*.so.*]] >= 1 } {
  117. append always_ld_library_path ":${gccdir}/${mldir}"
  118. }
  119. }
  120. }
  121. }
  122. set ALWAYS_CFLAGS ""
  123. if { $blddir != "" } {
  124. lappend ALWAYS_CFLAGS "additional_flags=-B${blddir}/"
  125. lappend ALWAYS_CFLAGS "additional_flags=-I${blddir}"
  126. lappend ALWAYS_CFLAGS "ldflags=-L${blddir}/.libs"
  127. }
  128. lappend ALWAYS_CFLAGS "additional_flags=-I${srcdir}/.."
  129. # We use atomic operations in the testcases to validate results.
  130. if { ([istarget i?86-*-*] || [istarget x86_64-*-*])
  131. && [check_effective_target_ia32] } {
  132. lappend ALWAYS_CFLAGS "additional_flags=-march=i486"
  133. }
  134. if [istarget *-*-darwin*] {
  135. lappend ALWAYS_CFLAGS "additional_flags=-shared-libgcc"
  136. }
  137. if [istarget sparc*-*-*] {
  138. lappend ALWAYS_CFLAGS "additional_flags=-mcpu=v9"
  139. }
  140. if [info exists TOOL_OPTIONS] {
  141. lappend ALWAYS_CFLAGS "additional_flags=$TOOL_OPTIONS"
  142. }
  143. # Make sure that lines are not wrapped. That can confuse the
  144. # error-message parsing machinery.
  145. lappend ALWAYS_CFLAGS "additional_flags=-fmessage-length=0"
  146. # Turn on vtable verification.
  147. lappend ALWAYS_CFLAGS "additional_flags=-fvtable-verify=std"
  148. }
  149. #
  150. # libvtv_target_compile -- compile a source file
  151. #
  152. proc libvtv_target_compile { source dest type options } {
  153. global blddir
  154. global libvtv_compile_options
  155. global gluefile wrap_flags
  156. global ALWAYS_CFLAGS
  157. global GCC_UNDER_TEST
  158. global lang_test_file
  159. global lang_library_path
  160. global lang_link_flags
  161. if { [info exists lang_test_file] } {
  162. if { $blddir != "" } {
  163. lappend options "ldflags=-L${blddir}/${lang_library_path}"
  164. }
  165. lappend options "ldflags=${lang_link_flags}"
  166. }
  167. if { [target_info needs_status_wrapper] != "" && [info exists gluefile] } {
  168. lappend options "libs=${gluefile}"
  169. lappend options "ldflags=${wrap_flags}"
  170. }
  171. lappend options "additional_flags=[libio_include_flags]"
  172. lappend options "timeout=[timeout_value]"
  173. lappend options "compiler=$GCC_UNDER_TEST"
  174. set options [concat $libvtv_compile_options $options]
  175. if [info exists ALWAYS_CFLAGS] {
  176. set options [concat "$ALWAYS_CFLAGS" $options]
  177. }
  178. set options [dg-additional-files-options $options $source]
  179. set result [target_compile $source $dest $type $options]
  180. return $result
  181. }
  182. proc libvtv_option_help { } {
  183. send_user " --additional_options,OPTIONS\t\tUse OPTIONS to compile the testcase files. OPTIONS should be comma-separated.\n"
  184. }
  185. proc libvtv_option_proc { option } {
  186. if [regexp "^--additional_options," $option] {
  187. global libvtv_compile_options
  188. regsub "--additional_options," $option "" option
  189. foreach x [split $option ","] {
  190. lappend libvtv_compile_options "additional_flags=$x"
  191. }
  192. return 1
  193. } else {
  194. return 0
  195. }
  196. }