1 # This whole file adapted from libgomp.fortran
/fortran.exp.
3 load_lib libgomp
-dg.exp
4 load_gcc_lib gcc
-dg.exp
5 load_gcc_lib gfortran
-dg.exp
10 set shlib_ext
[get_shlib_extension
]
11 set lang_library_path
"../libgfortran/.libs"
12 set lang_link_flags
"-lgfortran -foffload=-lgfortran"
13 if [info exists lang_include_flags
] then {
14 unset lang_include_flags
16 set lang_test_file_found
0
17 set quadmath_library_path
"../libquadmath/.libs"
24 lappend ALWAYS_CFLAGS
"additional_flags=-fopenacc"
26 if { $blddir
!= "" } {
27 set lang_source_re
{^.
*\.
[fF
](|
90|
95|
03|
08)$
}
28 set lang_include_flags
"-fintrinsic-modules-path=${blddir}"
29 # Look
for a static libgfortran first.
30 if [file
exists "${blddir}/${lang_library_path}/libgfortran.a"] {
31 set lang_test_file
"${lang_library_path}/libgfortran.a"
32 set lang_test_file_found
1
33 # We may have a shared only build
, so look
for a shared libgfortran.
34 } elseif
[file
exists "${blddir}/${lang_library_path}/libgfortran.${shlib_ext}"] {
35 set lang_test_file
"${lang_library_path}/libgfortran.${shlib_ext}"
36 set lang_test_file_found
1
38 puts
"No libgfortran library found, will not execute fortran tests"
40 } elseif
[info exists GFORTRAN_UNDER_TEST
] {
41 set lang_test_file_found
1
42 # Needs to exist
for libgomp.exp.
45 puts
"GFORTRAN_UNDER_TEST not defined, will not execute fortran tests"
48 if { $lang_test_file_found
} {
49 # Gather a list of all tests.
50 set tests
[lsort
[find $srcdir
/$subdir
*.\
[fF\
]{,90,95,03,08}]]
52 if { $blddir
!= "" } {
53 if { [file
exists "${blddir}/${quadmath_library_path}/libquadmath.a"]
54 ||
[file
exists "${blddir}/${quadmath_library_path}/libquadmath.${shlib_ext}"] } {
55 lappend ALWAYS_CFLAGS
"ldflags=-L${blddir}/${quadmath_library_path}/"
56 # Allow
for spec subsitution.
57 lappend ALWAYS_CFLAGS
"additional_flags=-B${blddir}/${quadmath_library_path}/"
58 set ld_library_path
"$always_ld_library_path:${blddir}/${lang_library_path}:${blddir}/${quadmath_library_path}"
59 append lang_link_flags
" -lquadmath"
61 set ld_library_path
"$always_ld_library_path:${blddir}/${lang_library_path}"
64 set ld_library_path
"$always_ld_library_path"
65 if { [check_no_compiler_messages has_libquadmath executable
{
66 int main
() {return 0;}
67 } "-lgfortran -lquadmath"] } then {
68 append lang_link_flags
" -lquadmath"
71 append ld_library_path
[gcc
-set-multilib
-library
-path $GCC_UNDER_TEST
]
72 set_ld_library_path_env_vars
74 # Test with all available offload targets
, and with offloading disabled.
75 foreach offload_target
[concat
[split $offload_targets
","] "disable"] {
76 global openacc_device_type
77 set openacc_device_type
[offload_target_to_openacc_device_type $offload_target
]
78 set tagopt
"-DACC_DEVICE_TYPE_$openacc_device_type=1"
80 switch $openacc_device_type
{
82 unsupported
"$subdir $offload_target offloading"
89 if { ![check_effective_target_openacc_nvidia_accel_present
] } {
90 # Don
't bother; execution testing is going to FAIL.
91 untested "$subdir $offload_target offloading: supported, but hardware not accessible"
98 if { ![check_effective_target_openacc_radeon_accel_present] } {
99 # Don't bother
; execution testing is going to FAIL.
100 untested
"$subdir $offload_target offloading: supported, but hardware not accessible"
107 error
"Unknown OpenACC device type: $openacc_device_type (offload target: $offload_target)"
110 set tagopt
"$tagopt -DACC_MEM_SHARED=$acc_mem_shared"
112 # To avoid compilation overhead
, and to keep simple
'-foffload=[...]'
113 # handling in test cases
, by default only build
for the offload target
114 # that we
're actually going to test.
115 set tagopt "$tagopt -foffload=$offload_target"
116 # Force usage of the corresponding OpenACC device type.
117 setenv ACC_DEVICE_TYPE $openacc_device_type
119 # For Fortran we're doing torture testing
, as Fortran has far more tests
120 # with arrays etc. that testing just
-O0 or
-O2 is insufficient
, that is
121 # typically not the case
for C
/C
++.
122 gfortran
-dg
-runtest $tests
"$tagopt" ""