libitm.exp 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  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 prune.exp
  26. load_gcc_lib target-libpath.exp
  27. load_gcc_lib wrapper.exp
  28. load_gcc_lib target-supports.exp
  29. load_gcc_lib target-utils.exp
  30. load_gcc_lib gcc-defs.exp
  31. load_gcc_lib timeout.exp
  32. load_gcc_lib file-format.exp
  33. load_gcc_lib target-supports-dg.exp
  34. load_gcc_lib scanasm.exp
  35. load_gcc_lib scandump.exp
  36. load_gcc_lib scanrtl.exp
  37. load_gcc_lib scantree.exp
  38. load_gcc_lib scanipa.exp
  39. load_gcc_lib timeout-dg.exp
  40. load_gcc_lib torture-options.exp
  41. load_gcc_lib fortran-modules.exp
  42. set dg-do-what-default run
  43. #
  44. # GCC_UNDER_TEST is the compiler under test.
  45. #
  46. set libitm_compile_options ""
  47. #
  48. # libitm_init
  49. #
  50. if [info exists TOOL_OPTIONS] {
  51. set multilibs [get_multilibs $TOOL_OPTIONS]
  52. } else {
  53. set multilibs [get_multilibs]
  54. }
  55. proc libitm_init { args } {
  56. global srcdir blddir objdir tool_root_dir
  57. global libitm_initialized
  58. global tmpdir
  59. global blddir
  60. global gluefile wrap_flags
  61. global ALWAYS_CFLAGS
  62. global CFLAGS
  63. global TOOL_EXECUTABLE TOOL_OPTIONS
  64. global GCC_UNDER_TEST
  65. global TESTING_IN_BUILD_TREE
  66. global target_triplet
  67. global always_ld_library_path
  68. set blddir [lookfor_file [get_multilibs] libitm]
  69. # We set LC_ALL and LANG to C so that we get the same error
  70. # messages as expected.
  71. setenv LC_ALL C
  72. setenv LANG C
  73. if ![info exists GCC_UNDER_TEST] then {
  74. if [info exists TOOL_EXECUTABLE] {
  75. set GCC_UNDER_TEST $TOOL_EXECUTABLE
  76. } else {
  77. set GCC_UNDER_TEST "[find_gcc]"
  78. }
  79. }
  80. if ![info exists tmpdir] {
  81. set tmpdir "/tmp"
  82. }
  83. if [info exists gluefile] {
  84. unset gluefile
  85. }
  86. if {![info exists CFLAGS]} {
  87. set CFLAGS ""
  88. }
  89. # Locate libgcc.a so we don't need to account for different values of
  90. # SHLIB_EXT on different platforms
  91. set gccdir [lookfor_file $tool_root_dir gcc/libgcc.a]
  92. if {$gccdir != ""} {
  93. set gccdir [file dirname $gccdir]
  94. }
  95. # Compute what needs to be put into LD_LIBRARY_PATH
  96. set always_ld_library_path ".:${blddir}/.libs"
  97. # Compute what needs to be added to the existing LD_LIBRARY_PATH.
  98. if {$gccdir != ""} {
  99. # Add AIX pthread directory first.
  100. if { [llength [glob -nocomplain ${gccdir}/pthread/libgcc_s*.a]] >= 1 } {
  101. append always_ld_library_path ":${gccdir}/pthread"
  102. }
  103. append always_ld_library_path ":${gccdir}"
  104. set compiler [lindex $GCC_UNDER_TEST 0]
  105. if { [is_remote host] == 0 && [which $compiler] != 0 } {
  106. foreach i "[exec $compiler --print-multi-lib]" {
  107. set mldir ""
  108. regexp -- "\[a-z0-9=_/\.-\]*;" $i mldir
  109. set mldir [string trimright $mldir "\;@"]
  110. if { "$mldir" == "." } {
  111. continue
  112. }
  113. if { [llength [glob -nocomplain ${gccdir}/${mldir}/libgcc_s*.so.*]] >= 1 } {
  114. append always_ld_library_path ":${gccdir}/${mldir}"
  115. }
  116. }
  117. }
  118. }
  119. set ALWAYS_CFLAGS ""
  120. if { $blddir != "" } {
  121. lappend ALWAYS_CFLAGS "additional_flags=-B${blddir}/"
  122. lappend ALWAYS_CFLAGS "additional_flags=-I${blddir}"
  123. lappend ALWAYS_CFLAGS "ldflags=-L${blddir}/.libs"
  124. }
  125. lappend ALWAYS_CFLAGS "additional_flags=-I${srcdir}/.."
  126. # We use atomic operations in the testcases to validate results.
  127. if { ([istarget i?86-*-*] || [istarget x86_64-*-*])
  128. && [check_effective_target_ia32] } {
  129. lappend ALWAYS_CFLAGS "additional_flags=-march=i486"
  130. }
  131. if [istarget *-*-darwin*] {
  132. lappend ALWAYS_CFLAGS "additional_flags=-shared-libgcc"
  133. }
  134. if [istarget sparc*-*-*] {
  135. lappend ALWAYS_CFLAGS "additional_flags=-mcpu=v9"
  136. }
  137. if [info exists TOOL_OPTIONS] {
  138. lappend ALWAYS_CFLAGS "additional_flags=$TOOL_OPTIONS"
  139. }
  140. # Make sure that lines are not wrapped. That can confuse the
  141. # error-message parsing machinery.
  142. lappend ALWAYS_CFLAGS "additional_flags=-fmessage-length=0"
  143. # Turn on transactional memory support.
  144. lappend ALWAYS_CFLAGS "additional_flags=-fgnu-tm"
  145. }
  146. #
  147. # libitm_target_compile -- compile a source file
  148. #
  149. proc libitm_target_compile { source dest type options } {
  150. global blddir
  151. global libitm_compile_options
  152. global gluefile wrap_flags
  153. global ALWAYS_CFLAGS
  154. global GCC_UNDER_TEST
  155. global lang_test_file
  156. global lang_library_path
  157. global lang_link_flags
  158. if { [info exists lang_test_file] } {
  159. if { $blddir != "" } {
  160. lappend options "ldflags=-L${blddir}/${lang_library_path}"
  161. }
  162. lappend options "ldflags=${lang_link_flags}"
  163. }
  164. if { [target_info needs_status_wrapper] != "" && [info exists gluefile] } {
  165. lappend options "libs=${gluefile}"
  166. lappend options "ldflags=${wrap_flags}"
  167. }
  168. lappend options "additional_flags=[libio_include_flags]"
  169. lappend options "timeout=[timeout_value]"
  170. lappend options "compiler=$GCC_UNDER_TEST"
  171. set options [concat $libitm_compile_options $options]
  172. if [info exists ALWAYS_CFLAGS] {
  173. set options [concat "$ALWAYS_CFLAGS" $options]
  174. }
  175. set options [dg-additional-files-options $options $source]
  176. set result [target_compile $source $dest $type $options]
  177. return $result
  178. }
  179. proc libitm_option_help { } {
  180. send_user " --additional_options,OPTIONS\t\tUse OPTIONS to compile the testcase files. OPTIONS should be comma-separated.\n"
  181. }
  182. proc libitm_option_proc { option } {
  183. if [regexp "^--additional_options," $option] {
  184. global libitm_compile_options
  185. regsub "--additional_options," $option "" option
  186. foreach x [split $option ","] {
  187. lappend libitm_compile_options "additional_flags=$x"
  188. }
  189. return 1
  190. } else {
  191. return 0
  192. }
  193. }