OSDN Git Service

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