libgomp.exp 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348
  1. # Damn dejagnu for not having proper library search paths for load_lib.
  2. # We have to explicitly load everything that gcc-dg.exp wants to load.
  3. proc load_gcc_lib { filename } {
  4. global srcdir loaded_libs
  5. load_file $srcdir/../../gcc/testsuite/lib/$filename
  6. set loaded_libs($filename) ""
  7. }
  8. load_lib dg.exp
  9. # Required to use gcc-dg.exp - however, the latter should NOT be
  10. # loaded until ${tool}_target_compile is defined since it uses that
  11. # to determine default LTO options.
  12. load_gcc_lib prune.exp
  13. load_gcc_lib target-libpath.exp
  14. load_gcc_lib wrapper.exp
  15. load_gcc_lib target-supports.exp
  16. load_gcc_lib target-utils.exp
  17. load_gcc_lib gcc-defs.exp
  18. load_gcc_lib timeout.exp
  19. load_gcc_lib file-format.exp
  20. load_gcc_lib target-supports-dg.exp
  21. load_gcc_lib scanasm.exp
  22. load_gcc_lib scandump.exp
  23. load_gcc_lib scanrtl.exp
  24. load_gcc_lib scantree.exp
  25. load_gcc_lib scanipa.exp
  26. load_gcc_lib timeout-dg.exp
  27. load_gcc_lib torture-options.exp
  28. load_gcc_lib fortran-modules.exp
  29. # Try to load a test support file, built during libgomp configuration.
  30. load_file libgomp-test-support.exp
  31. # Populate offload_targets_s (offloading targets separated by a space), and
  32. # offload_targets_s_openacc (the same, but with OpenACC names; OpenACC spells
  33. # some of them a little differently).
  34. set offload_targets_s [split $offload_targets ","]
  35. set offload_targets_s_openacc {}
  36. foreach offload_target_openacc $offload_targets_s {
  37. switch $offload_target_openacc {
  38. intelmic {
  39. # Skip; will all FAIL because of missing
  40. # GOMP_OFFLOAD_CAP_OPENACC_200.
  41. continue
  42. }
  43. nvptx {
  44. set offload_target_openacc "nvidia"
  45. }
  46. }
  47. lappend offload_targets_s_openacc "$offload_target_openacc"
  48. }
  49. lappend offload_targets_s_openacc "host"
  50. set dg-do-what-default run
  51. #
  52. # GCC_UNDER_TEST is the compiler under test.
  53. #
  54. set libgomp_compile_options ""
  55. #
  56. # libgomp_init
  57. #
  58. if [info exists TOOL_OPTIONS] {
  59. set multilibs [get_multilibs $TOOL_OPTIONS]
  60. } else {
  61. set multilibs [get_multilibs]
  62. }
  63. proc libgomp_init { args } {
  64. global srcdir blddir objdir tool_root_dir
  65. global libgomp_initialized
  66. global tmpdir
  67. global blddir
  68. global gluefile wrap_flags
  69. global ALWAYS_CFLAGS
  70. global CFLAGS
  71. global TOOL_EXECUTABLE TOOL_OPTIONS
  72. global GCC_UNDER_TEST
  73. global TESTING_IN_BUILD_TREE
  74. global target_triplet
  75. global always_ld_library_path
  76. set blddir [lookfor_file [get_multilibs] libgomp]
  77. # We set LC_ALL and LANG to C so that we get the same error
  78. # messages as expected.
  79. setenv LC_ALL C
  80. setenv LANG C
  81. # Many hosts now default to a non-ASCII C locale, however, so
  82. # they can set a charset encoding here if they need.
  83. if { [ishost "*-*-cygwin*"] } {
  84. setenv LC_ALL C.ASCII
  85. setenv LANG C.ASCII
  86. }
  87. if ![info exists GCC_UNDER_TEST] then {
  88. if [info exists TOOL_EXECUTABLE] {
  89. set GCC_UNDER_TEST $TOOL_EXECUTABLE
  90. } else {
  91. set GCC_UNDER_TEST "[find_gcc]"
  92. }
  93. }
  94. if ![info exists tmpdir] {
  95. set tmpdir "/tmp"
  96. }
  97. if [info exists gluefile] {
  98. unset gluefile
  99. }
  100. if {![info exists CFLAGS]} {
  101. set CFLAGS ""
  102. }
  103. # Locate libgcc.a so we don't need to account for different values of
  104. # SHLIB_EXT on different platforms
  105. set gccdir [lookfor_file $tool_root_dir gcc/libgcc.a]
  106. if {$gccdir != ""} {
  107. set gccdir [file dirname $gccdir]
  108. }
  109. # Compute what needs to be put into LD_LIBRARY_PATH
  110. set always_ld_library_path ".:${blddir}/.libs"
  111. # Add liboffloadmic build directory in LD_LIBRARY_PATH to support
  112. # non-fallback testing for Intel MIC targets
  113. global offload_targets
  114. if { [string match "*,intelmic,*" ",$offload_targets,"] } {
  115. append always_ld_library_path ":${blddir}/../liboffloadmic/.libs"
  116. append always_ld_library_path ":${blddir}/../liboffloadmic/plugin/.libs"
  117. # libstdc++ is required by liboffloadmic
  118. append always_ld_library_path ":${blddir}/../libstdc++-v3/src/.libs"
  119. }
  120. global offload_additional_lib_paths
  121. if { $offload_additional_lib_paths != "" } {
  122. append always_ld_library_path "${offload_additional_lib_paths}"
  123. }
  124. # Compute what needs to be added to the existing LD_LIBRARY_PATH.
  125. if {$gccdir != ""} {
  126. # Add AIX pthread directory first.
  127. if { [llength [glob -nocomplain ${gccdir}/pthread/libgcc_s*.a]] >= 1 } {
  128. append always_ld_library_path ":${gccdir}/pthread"
  129. }
  130. append always_ld_library_path ":${gccdir}"
  131. set compiler [lindex $GCC_UNDER_TEST 0]
  132. if { [is_remote host] == 0 && [which $compiler] != 0 } {
  133. foreach i "[exec $compiler --print-multi-lib]" {
  134. set mldir ""
  135. regexp -- "\[a-z0-9=_/\.-\]*;" $i mldir
  136. set mldir [string trimright $mldir "\;@"]
  137. if { "$mldir" == "." } {
  138. continue
  139. }
  140. if { [llength [glob -nocomplain ${gccdir}/${mldir}/libgcc_s*.so.*]] >= 1 } {
  141. append always_ld_library_path ":${gccdir}/${mldir}"
  142. }
  143. }
  144. }
  145. }
  146. set ALWAYS_CFLAGS ""
  147. if { $blddir != "" } {
  148. lappend ALWAYS_CFLAGS "additional_flags=-B${blddir}/"
  149. # targets that use libgomp.a%s in their specs need a -B option
  150. # for uninstalled testing.
  151. lappend ALWAYS_CFLAGS "additional_flags=-B${blddir}/.libs"
  152. lappend ALWAYS_CFLAGS "additional_flags=-I${blddir}"
  153. lappend ALWAYS_CFLAGS "ldflags=-L${blddir}/.libs"
  154. # The top-level include directory, for gomp-constants.h.
  155. lappend ALWAYS_CFLAGS "additional_flags=-I${srcdir}/../../include"
  156. }
  157. lappend ALWAYS_CFLAGS "additional_flags=-I${srcdir}/.."
  158. # For build-tree testing, also consider the CUDA paths used for builing.
  159. # For installed testing, we assume all that to be provided in the sysroot.
  160. if { $blddir != "" } {
  161. global cuda_driver_include
  162. global cuda_driver_lib
  163. if { $cuda_driver_include != "" } {
  164. # Stop gfortran from freaking out:
  165. # Warning: Nonexistent include directory "[...]"
  166. if {[file exists $cuda_driver_include]} {
  167. lappend ALWAYS_CFLAGS "additional_flags=-I$cuda_driver_include"
  168. }
  169. }
  170. if { $cuda_driver_lib != "" } {
  171. lappend ALWAYS_CFLAGS "additional_flags=-L$cuda_driver_lib"
  172. append always_ld_library_path ":$cuda_driver_lib"
  173. }
  174. }
  175. # We use atomic operations in the testcases to validate results.
  176. if { ([istarget i?86-*-*] || [istarget x86_64-*-*])
  177. && [check_effective_target_ia32] } {
  178. lappend ALWAYS_CFLAGS "additional_flags=-march=i486"
  179. }
  180. if [istarget *-*-darwin*] {
  181. lappend ALWAYS_CFLAGS "additional_flags=-shared-libgcc"
  182. }
  183. if [istarget sparc*-*-*] {
  184. lappend ALWAYS_CFLAGS "additional_flags=-mcpu=v9"
  185. }
  186. if [info exists TOOL_OPTIONS] {
  187. lappend ALWAYS_CFLAGS "additional_flags=$TOOL_OPTIONS"
  188. }
  189. # Make sure that lines are not wrapped. That can confuse the
  190. # error-message parsing machinery.
  191. lappend ALWAYS_CFLAGS "additional_flags=-fmessage-length=0"
  192. # Disable caret
  193. lappend ALWAYS_CFLAGS "additional_flags=-fno-diagnostics-show-caret"
  194. # Disable color diagnostics
  195. lappend ALWAYS_CFLAGS "additional_flags=-fdiagnostics-color=never"
  196. # Used for support non-fallback offloading.
  197. # Help GCC to find target mkoffload.
  198. global offload_additional_options
  199. if { $offload_additional_options != "" } {
  200. lappend ALWAYS_CFLAGS "additional_flags=${offload_additional_options}"
  201. }
  202. }
  203. #
  204. # libgomp_target_compile -- compile a source file
  205. #
  206. proc libgomp_target_compile { source dest type options } {
  207. global blddir
  208. global libgomp_compile_options
  209. global gluefile wrap_flags
  210. global ALWAYS_CFLAGS
  211. global GCC_UNDER_TEST
  212. global lang_test_file
  213. global lang_library_path
  214. global lang_link_flags
  215. global lang_include_flags
  216. global lang_source_re
  217. if { [info exists lang_test_file] } {
  218. if { $blddir != "" } {
  219. # Some targets use libgfortran.a%s in their specs, so they need
  220. # a -B option for uninstalled testing.
  221. lappend options "additional_flags=-B${blddir}/${lang_library_path}"
  222. lappend options "ldflags=-L${blddir}/${lang_library_path}"
  223. }
  224. lappend options "ldflags=${lang_link_flags}"
  225. if { [info exists lang_include_flags] \
  226. && [regexp ${lang_source_re} ${source}] } {
  227. lappend options "additional_flags=${lang_include_flags}"
  228. }
  229. }
  230. if { [target_info needs_status_wrapper] != "" && [info exists gluefile] } {
  231. lappend options "libs=${gluefile}"
  232. lappend options "ldflags=${wrap_flags}"
  233. }
  234. lappend options "additional_flags=[libio_include_flags]"
  235. lappend options "timeout=[timeout_value]"
  236. lappend options "compiler=$GCC_UNDER_TEST"
  237. set options [concat $libgomp_compile_options $options]
  238. if [info exists ALWAYS_CFLAGS] {
  239. set options [concat "$ALWAYS_CFLAGS" $options]
  240. }
  241. set options [dg-additional-files-options $options $source]
  242. set result [target_compile $source $dest $type $options]
  243. return $result
  244. }
  245. proc libgomp_option_help { } {
  246. send_user " --additional_options,OPTIONS\t\tUse OPTIONS to compile the testcase files. OPTIONS should be comma-separated.\n"
  247. }
  248. proc libgomp_option_proc { option } {
  249. if [regexp "^--additional_options," $option] {
  250. global libgomp_compile_options
  251. regsub "--additional_options," $option "" option
  252. foreach x [split $option ","] {
  253. lappend libgomp_compile_options "additional_flags=$x"
  254. }
  255. return 1
  256. } else {
  257. return 0
  258. }
  259. }
  260. # Return 1 if offload device is available.
  261. proc check_effective_target_offload_device { } {
  262. return [check_runtime_nocache offload_device_available_ {
  263. #include <omp.h>
  264. int main ()
  265. {
  266. int a;
  267. #pragma omp target map(from: a)
  268. a = omp_is_initial_device ();
  269. return a;
  270. }
  271. } ]
  272. }
  273. # Return 1 if at least one nvidia board is present.
  274. proc check_effective_target_openacc_nvidia_accel_present { } {
  275. return [check_runtime openacc_nvidia_accel_present {
  276. #include <openacc.h>
  277. int main () {
  278. return !(acc_get_num_devices (acc_device_nvidia) > 0);
  279. }
  280. } "" ]
  281. }
  282. # Return 1 if at least one nvidia board is present, and the nvidia device type
  283. # is selected by default by means of setting the environment variable
  284. # ACC_DEVICE_TYPE.
  285. proc check_effective_target_openacc_nvidia_accel_selected { } {
  286. if { ![check_effective_target_openacc_nvidia_accel_present] } {
  287. return 0;
  288. }
  289. global offload_target_openacc
  290. if { $offload_target_openacc == "nvidia" } {
  291. return 1;
  292. }
  293. return 0;
  294. }