svn merge -r 219681:219682 svn+ssh://gcc.gnu.org/svn/gcc/trunk
[official-gcc.git] / libgomp / testsuite / lib / libgomp.exp
blobdded36a6ce564e1292f027ac5ed2259e167f1f91
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.
4 proc load_gcc_lib { filename } {
5 global srcdir loaded_libs
7 load_file $srcdir/../../gcc/testsuite/lib/$filename
8 set loaded_libs($filename) ""
11 load_lib dg.exp
13 # Required to use gcc-dg.exp - however, the latter should NOT be
14 # loaded until ${tool}_target_compile is defined since it uses that
15 # to determine default LTO options.
17 load_gcc_lib prune.exp
18 load_gcc_lib target-libpath.exp
19 load_gcc_lib wrapper.exp
20 load_gcc_lib target-supports.exp
21 load_gcc_lib target-utils.exp
22 load_gcc_lib gcc-defs.exp
23 load_gcc_lib timeout.exp
24 load_gcc_lib file-format.exp
25 load_gcc_lib target-supports-dg.exp
26 load_gcc_lib scanasm.exp
27 load_gcc_lib scandump.exp
28 load_gcc_lib scanrtl.exp
29 load_gcc_lib scantree.exp
30 load_gcc_lib scanipa.exp
31 load_gcc_lib timeout-dg.exp
32 load_gcc_lib torture-options.exp
33 load_gcc_lib fortran-modules.exp
35 # Try to load a test support file, built during libgomp configuration.
36 load_file libgomp-test-support.exp
38 # Populate offload_targets_s (offloading targets separated by a space), and
39 # offload_targets_s_openacc (the same, but with OpenACC names; OpenACC spells
40 # some of them a little differently).
41 set offload_targets_s [split $offload_targets ","]
42 set offload_targets_s_openacc {}
43 foreach offload_target_openacc $offload_targets_s {
44 switch $offload_target_openacc {
45 intelmic {
46 # TODO. Skip; will all FAIL because of missing
47 # GOMP_OFFLOAD_CAP_OPENACC_200.
48 continue
50 nvptx {
51 set offload_target_openacc "nvidia"
54 lappend offload_targets_s_openacc "$offload_target_openacc"
56 lappend offload_targets_s_openacc "host"
58 set dg-do-what-default run
61 # GCC_UNDER_TEST is the compiler under test.
64 set libgomp_compile_options ""
67 # libgomp_init
70 if [info exists TOOL_OPTIONS] {
71 set multilibs [get_multilibs $TOOL_OPTIONS]
72 } else {
73 set multilibs [get_multilibs]
76 proc libgomp_init { args } {
77 global srcdir blddir objdir tool_root_dir
78 global libgomp_initialized
79 global tmpdir
80 global blddir
81 global gluefile wrap_flags
82 global ALWAYS_CFLAGS
83 global CFLAGS
84 global TOOL_EXECUTABLE TOOL_OPTIONS
85 global GCC_UNDER_TEST
86 global TESTING_IN_BUILD_TREE
87 global target_triplet
88 global always_ld_library_path
90 set blddir [lookfor_file [get_multilibs] libgomp]
92 # We set LC_ALL and LANG to C so that we get the same error
93 # messages as expected.
94 setenv LC_ALL C
95 setenv LANG C
97 # Many hosts now default to a non-ASCII C locale, however, so
98 # they can set a charset encoding here if they need.
99 if { [ishost "*-*-cygwin*"] } {
100 setenv LC_ALL C.ASCII
101 setenv LANG C.ASCII
104 if ![info exists GCC_UNDER_TEST] then {
105 if [info exists TOOL_EXECUTABLE] {
106 set GCC_UNDER_TEST $TOOL_EXECUTABLE
107 } else {
108 set GCC_UNDER_TEST "[find_gcc]"
112 if ![info exists tmpdir] {
113 set tmpdir "/tmp"
116 if [info exists gluefile] {
117 unset gluefile
120 if {![info exists CFLAGS]} {
121 set CFLAGS ""
124 # Locate libgcc.a so we don't need to account for different values of
125 # SHLIB_EXT on different platforms
126 set gccdir [lookfor_file $tool_root_dir gcc/libgcc.a]
127 if {$gccdir != ""} {
128 set gccdir [file dirname $gccdir]
131 # Compute what needs to be put into LD_LIBRARY_PATH
132 set always_ld_library_path ".:${blddir}/.libs"
134 # Add liboffloadmic build directory in LD_LIBRARY_PATH to support
135 # non-fallback testing for Intel MIC targets
136 global offload_targets
137 if { [string match "*,intelmic,*" ",$offload_targets,"] } {
138 append always_ld_library_path ":${blddir}/../liboffloadmic/.libs"
139 append always_ld_library_path ":${blddir}/../liboffloadmic/plugin/.libs"
140 # libstdc++ is required by liboffloadmic
141 append always_ld_library_path ":${blddir}/../libstdc++-v3/src/.libs"
144 global offload_additional_lib_paths
145 if { $offload_additional_lib_paths != "" } {
146 append always_ld_library_path "${offload_additional_lib_paths}"
149 # Compute what needs to be added to the existing LD_LIBRARY_PATH.
150 if {$gccdir != ""} {
151 # Add AIX pthread directory first.
152 if { [llength [glob -nocomplain ${gccdir}/pthread/libgcc_s*.a]] >= 1 } {
153 append always_ld_library_path ":${gccdir}/pthread"
155 append always_ld_library_path ":${gccdir}"
156 set compiler [lindex $GCC_UNDER_TEST 0]
158 if { [is_remote host] == 0 && [which $compiler] != 0 } {
159 foreach i "[exec $compiler --print-multi-lib]" {
160 set mldir ""
161 regexp -- "\[a-z0-9=_/\.-\]*;" $i mldir
162 set mldir [string trimright $mldir "\;@"]
163 if { "$mldir" == "." } {
164 continue
166 if { [llength [glob -nocomplain ${gccdir}/${mldir}/libgcc_s*.so.*]] >= 1 } {
167 append always_ld_library_path ":${gccdir}/${mldir}"
173 set ALWAYS_CFLAGS ""
174 if { $blddir != "" } {
175 lappend ALWAYS_CFLAGS "additional_flags=-B${blddir}/"
176 # targets that use libgomp.a%s in their specs need a -B option
177 # for uninstalled testing.
178 lappend ALWAYS_CFLAGS "additional_flags=-B${blddir}/.libs"
179 lappend ALWAYS_CFLAGS "additional_flags=-I${blddir}"
180 lappend ALWAYS_CFLAGS "ldflags=-L${blddir}/.libs"
181 # The top-level include directory, for gomp-constants.h.
182 lappend ALWAYS_CFLAGS "additional_flags=-I${srcdir}/../../include"
184 lappend ALWAYS_CFLAGS "additional_flags=-I${srcdir}/.."
186 # For build-tree testing, also consider the CUDA paths used for builing.
187 # For installed testing, we assume all that to be provided in the sysroot.
188 if { $blddir != "" } {
189 global cuda_driver_include
190 global cuda_driver_lib
191 if { $cuda_driver_include != "" } {
192 # Stop gfortran from freaking out:
193 # Warning: Nonexistent include directory "[...]"
194 if {[file exists $cuda_driver_include]} {
195 lappend ALWAYS_CFLAGS "additional_flags=-I$cuda_driver_include"
198 if { $cuda_driver_lib != "" } {
199 lappend ALWAYS_CFLAGS "additional_flags=-L$cuda_driver_lib"
200 append always_ld_library_path ":$cuda_driver_lib"
204 # We use atomic operations in the testcases to validate results.
205 if { ([istarget i?86-*-*] || [istarget x86_64-*-*])
206 && [check_effective_target_ia32] } {
207 lappend ALWAYS_CFLAGS "additional_flags=-march=i486"
210 if [istarget *-*-darwin*] {
211 lappend ALWAYS_CFLAGS "additional_flags=-shared-libgcc"
214 if [istarget sparc*-*-*] {
215 lappend ALWAYS_CFLAGS "additional_flags=-mcpu=v9"
218 if [info exists TOOL_OPTIONS] {
219 lappend ALWAYS_CFLAGS "additional_flags=$TOOL_OPTIONS"
222 # Make sure that lines are not wrapped. That can confuse the
223 # error-message parsing machinery.
224 lappend ALWAYS_CFLAGS "additional_flags=-fmessage-length=0"
226 # Disable caret
227 lappend ALWAYS_CFLAGS "additional_flags=-fno-diagnostics-show-caret"
229 # Disable color diagnostics
230 lappend ALWAYS_CFLAGS "additional_flags=-fdiagnostics-color=never"
232 # Used for support non-fallback offloading.
233 # Help GCC to find target mkoffload.
234 global offload_additional_options
235 if { $offload_additional_options != "" } {
236 lappend ALWAYS_CFLAGS "additional_flags=${offload_additional_options}"
241 # libgomp_target_compile -- compile a source file
244 proc libgomp_target_compile { source dest type options } {
245 global blddir
246 global libgomp_compile_options
247 global gluefile wrap_flags
248 global ALWAYS_CFLAGS
249 global GCC_UNDER_TEST
250 global lang_test_file
251 global lang_library_path
252 global lang_link_flags
253 global lang_include_flags
254 global lang_source_re
256 if { [info exists lang_test_file] } {
257 if { $blddir != "" } {
258 # Some targets use libgfortran.a%s in their specs, so they need
259 # a -B option for uninstalled testing.
260 lappend options "additional_flags=-B${blddir}/${lang_library_path}"
261 lappend options "ldflags=-L${blddir}/${lang_library_path}"
263 lappend options "ldflags=${lang_link_flags}"
264 if { [info exists lang_include_flags] \
265 && [regexp ${lang_source_re} ${source}] } {
266 lappend options "additional_flags=${lang_include_flags}"
270 if { [target_info needs_status_wrapper] != "" && [info exists gluefile] } {
271 lappend options "libs=${gluefile}"
272 lappend options "ldflags=${wrap_flags}"
275 lappend options "additional_flags=[libio_include_flags]"
276 lappend options "timeout=[timeout_value]"
277 lappend options "compiler=$GCC_UNDER_TEST"
279 set options [concat $libgomp_compile_options $options]
281 if [info exists ALWAYS_CFLAGS] {
282 set options [concat "$ALWAYS_CFLAGS" $options]
285 set options [dg-additional-files-options $options $source]
287 set result [target_compile $source $dest $type $options]
289 return $result
292 proc libgomp_option_help { } {
293 send_user " --additional_options,OPTIONS\t\tUse OPTIONS to compile the testcase files. OPTIONS should be comma-separated.\n"
296 proc libgomp_option_proc { option } {
297 if [regexp "^--additional_options," $option] {
298 global libgomp_compile_options
299 regsub "--additional_options," $option "" option
300 foreach x [split $option ","] {
301 lappend libgomp_compile_options "additional_flags=$x"
303 return 1
304 } else {
305 return 0
309 # Return 1 if offload device is available.
310 proc check_effective_target_offload_device { } {
311 return [check_runtime_nocache offload_device_available_ {
312 #include <omp.h>
313 int main ()
315 int a;
316 #pragma omp target map(from: a)
317 a = omp_is_initial_device ();
318 return a;
323 # Return 1 if at least one nvidia board is present.
325 proc check_effective_target_openacc_nvidia_accel_present { } {
326 return [check_runtime openacc_nvidia_accel_present {
327 #include <openacc.h>
328 int main () {
329 return !(acc_get_num_devices (acc_device_nvidia) > 0);
331 } "" ]
334 # Return 1 if at least one nvidia board is present, and the nvidia device type
335 # is selected by default by means of setting the environment variable
336 # ACC_DEVICE_TYPE.
338 proc check_effective_target_openacc_nvidia_accel_selected { } {
339 if { ![check_effective_target_openacc_nvidia_accel_present] } {
340 return 0;
342 global offload_target_openacc
343 if { $offload_target_openacc == "nvidia" } {
344 return 1;
346 return 0;