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
) ""
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 ..
/plugin
/libgomp
-test
-support.exp
38 set dg
-do-what
-default run
41 # GCC_UNDER_TEST is the compiler under test.
44 set libgomp_compile_options
""
50 if [info exists TOOL_OPTIONS
] {
51 set multilibs
[get_multilibs $TOOL_OPTIONS
]
53 set multilibs
[get_multilibs
]
56 proc libgomp_init
{ args } {
57 global srcdir blddir objdir tool_root_dir
58 global libgomp_initialized
61 global gluefile wrap_flags
64 global TOOL_EXECUTABLE TOOL_OPTIONS
66 global TESTING_IN_BUILD_TREE
68 global always_ld_library_path
70 set blddir
[lookfor_file
[get_multilibs
] libgomp
]
72 # We
set LC_ALL and LANG to C so that we
get the same error
73 # messages as expected.
77 # Many hosts now default to a non
-ASCII C locale
, however
, so
78 # they can
set a
charset encoding here
if they need.
79 if { [ishost
"*-*-cygwin*"] } {
84 if ![info exists GCC_UNDER_TEST
] then {
85 if [info exists TOOL_EXECUTABLE
] {
86 set GCC_UNDER_TEST $TOOL_EXECUTABLE
88 set GCC_UNDER_TEST
"[find_gcc]"
92 if ![info exists tmpdir
] {
96 if [info exists gluefile
] {
100 if {![info exists CFLAGS
]} {
104 # Locate libgcc.a so we don
't need to account for different values of
105 # SHLIB_EXT on different platforms
106 set gccdir [lookfor_file $tool_root_dir gcc/libgcc.a]
108 set gccdir [file dirname $gccdir]
111 # Compute what needs to be put into LD_LIBRARY_PATH
112 set always_ld_library_path ".:${blddir}/.libs:${blddir}/plugin/.libs"
114 # Get offload-related variables from environment (exported by Makefile)
115 set offload_targets [getenv OFFLOAD_TARGETS]
116 set offload_additional_options [getenv OFFLOAD_ADDITIONAL_OPTIONS]
117 set offload_additional_lib_paths [getenv OFFLOAD_ADDITIONAL_LIB_PATHS]
119 # Add liboffloadmic build directory in LD_LIBRARY_PATH to support
120 # non-fallback testing for Intel MIC targets
121 if { [string match "*-intelmic-*" $offload_targets]
122 || [string match "*-intelmicemul-*" $offload_targets] } {
123 append always_ld_library_path ":${blddir}/../liboffloadmic/.libs"
124 append always_ld_library_path ":${blddir}/../liboffloadmic/plugin/.libs"
125 # libstdc++ is required by liboffloadmic
126 append always_ld_library_path ":${blddir}/../libstdc++-v3/src/.libs"
129 if { $offload_additional_lib_paths != "" } {
130 append always_ld_library_path "${offload_additional_lib_paths}"
133 # Compute what needs to be added to the existing LD_LIBRARY_PATH.
135 # Add AIX pthread directory first.
136 if { [llength [glob -nocomplain ${gccdir}/pthread/libgcc_s*.a]] >= 1 } {
137 append always_ld_library_path ":${gccdir}/pthread"
139 append always_ld_library_path ":${gccdir}"
140 set compiler [lindex $GCC_UNDER_TEST 0]
142 if { [is_remote host] == 0 && [which $compiler] != 0 } {
143 foreach i "[exec $compiler --print-multi-lib]" {
145 regexp -- "\[a-z0-9=_/\.-\]*;" $i mldir
146 set mldir [string trimright $mldir "\;@"]
147 if { "$mldir" == "." } {
150 if { [llength [glob -nocomplain ${gccdir}/${mldir}/libgcc_s*.so.*]] >= 1 } {
151 append always_ld_library_path ":${gccdir}/${mldir}"
158 if { $blddir != "" } {
159 lappend ALWAYS_CFLAGS "additional_flags=-B${blddir}/"
160 # targets that use libgomp.a%s in their specs need a -B option
161 # for uninstalled testing.
162 lappend ALWAYS_CFLAGS "additional_flags=-B${blddir}/.libs"
163 lappend ALWAYS_CFLAGS "additional_flags=-I${blddir}"
164 lappend ALWAYS_CFLAGS "ldflags=-L${blddir}/.libs"
165 # The top-level include directory, for libgomp-constants.h.
166 lappend ALWAYS_CFLAGS "additional_flags=-I${srcdir}/../../include"
168 lappend ALWAYS_CFLAGS "additional_flags=-I${srcdir}/.."
170 # For build-tree testing, also consider the CUDA paths used for builing.
171 # For installed testing, we assume all that to be provided in the sysroot.
172 if { $blddir != "" } {
173 global cuda_driver_include
174 global cuda_driver_lib
175 if { $cuda_driver_include != "" } {
176 # Stop gfortran from freaking out:
177 # Warning: Nonexistent include directory "[...]"
178 if {[file exists $cuda_driver_include]} {
179 lappend ALWAYS_CFLAGS "additional_flags=-I$cuda_driver_include"
182 if { $cuda_driver_lib != "" } {
183 lappend ALWAYS_CFLAGS "additional_flags=-L$cuda_driver_lib"
184 append always_ld_library_path ":$cuda_driver_lib"
188 # We use atomic operations in the testcases to validate results.
189 if { ([istarget i?86-*-*] || [istarget x86_64-*-*])
190 && [check_effective_target_ia32] } {
191 lappend ALWAYS_CFLAGS "additional_flags=-march=i486"
194 if [istarget *-*-darwin*] {
195 lappend ALWAYS_CFLAGS "additional_flags=-shared-libgcc"
198 if [istarget sparc*-*-*] {
199 lappend ALWAYS_CFLAGS "additional_flags=-mcpu=v9"
202 if [info exists TOOL_OPTIONS] {
203 lappend ALWAYS_CFLAGS "additional_flags=$TOOL_OPTIONS"
206 # Make sure that lines are not wrapped. That can confuse the
207 # error-message parsing machinery.
208 lappend ALWAYS_CFLAGS "additional_flags=-fmessage-length=0"
211 lappend ALWAYS_CFLAGS "additional_flags=-fno-diagnostics-show-caret"
213 # Disable color diagnostics
214 lappend ALWAYS_CFLAGS "additional_flags=-fdiagnostics-color=never"
216 # Used for support non-fallback offloading.
217 # Help GCC to find target mkoffload.
218 if { $offload_additional_options != "" } {
219 lappend ALWAYS_CFLAGS "additional_flags=${offload_additional_options}"
224 # libgomp_target_compile -- compile a source file
227 proc libgomp_target_compile { source dest type options } {
229 global libgomp_compile_options
230 global gluefile wrap_flags
232 global GCC_UNDER_TEST
233 global lang_test_file
234 global lang_library_path
235 global lang_link_flags
236 global lang_include_flags
237 global lang_source_re
239 if { [info exists lang_test_file] } {
240 if { $blddir != "" } {
241 # Some targets use libgfortran.a%s in their specs, so they need
242 # a -B option for uninstalled testing.
243 lappend options "additional_flags=-B${blddir}/${lang_library_path}"
244 lappend options "ldflags=-L${blddir}/${lang_library_path}"
246 lappend options "ldflags=${lang_link_flags}"
247 if { [info exists lang_include_flags] \
248 && [regexp ${lang_source_re} ${source}] } {
249 lappend options "additional_flags=${lang_include_flags}"
253 if { [target_info needs_status_wrapper] != "" && [info exists gluefile] } {
254 lappend options "libs=${gluefile}"
255 lappend options "ldflags=${wrap_flags}"
258 lappend options "additional_flags=[libio_include_flags]"
259 lappend options "timeout=[timeout_value]"
260 lappend options "compiler=$GCC_UNDER_TEST"
262 set options [concat $libgomp_compile_options $options]
264 if [info exists ALWAYS_CFLAGS] {
265 set options [concat "$ALWAYS_CFLAGS" $options]
268 set options [dg-additional-files-options $options $source]
270 set result [target_compile $source $dest $type $options]
275 proc libgomp_option_help { } {
276 send_user " --additional_options,OPTIONS\t\tUse OPTIONS to compile the testcase files. OPTIONS should be comma-separated.\n"
279 proc libgomp_option_proc { option } {
280 if [regexp "^--additional_options," $option] {
281 global libgomp_compile_options
282 regsub "--additional_options," $option "" option
283 foreach x [split $option ","] {
284 lappend libgomp_compile_options "additional_flags=$x"
292 # Return 1 if offload device is available.
293 proc check_effective_target_offload_device { } {
294 return [check_runtime_nocache offload_device_available_ {
299 #pragma omp target map(from: a)
300 a = omp_is_initial_device ();
306 # Return 1 if at least one nvidia board is present.
308 proc check_effective_target_openacc_nvidia_accel_present { } {
309 return [check_runtime openacc_nvidia_accel_present {
312 return !(acc_get_num_devices (acc_device_nvidia) > 0);
317 # Return 1 if at least one nvidia board is present, and the nvidia device type
318 # is selected by default by means of setting the environment variable
321 proc check_effective_target_openacc_nvidia_accel_selected { } {
322 if { ![check_effective_target_openacc_nvidia_accel_present] } {
325 if { ![info exists ::env(ACC_DEVICE_TYPE)] } {
328 if { $::env(ACC_DEVICE_TYPE) == "nvidia" } {