OSDN Git Service

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