Merge branch 'vendor/OPENSSH'
[dragonfly.git] / contrib / gcc-5.0 / libitm / testsuite / lib / libitm.exp
1 # This program is free software; you can redistribute it and/or modify
2 # it under the terms of the GNU General Public License as published by
3 # the Free Software Foundation; either version 2 of the License, or
4 # (at your option) any later version.
5 #
6 # This program is distributed in the hope that it will be useful,
7 # but WITHOUT ANY WARRANTY; without even the implied warranty of
8 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
9 # GNU General Public License for more details.
10 #
11 # You should have received a copy of the GNU General Public License
12 # along with this program; if not, write to the Free Software
13 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
14
15 # Damn dejagnu for not having proper library search paths for load_lib.
16 # We have to explicitly load everything that gcc-dg.exp wants to load.
17
18 proc load_gcc_lib { filename } {
19     global srcdir loaded_libs
20
21     load_file $srcdir/../../gcc/testsuite/lib/$filename
22     set loaded_libs($filename) ""
23 }
24
25 load_lib dg.exp
26
27 # Required to use gcc-dg.exp - however, the latter should NOT be
28 # loaded until ${tool}_target_compile is defined since it uses that
29 # to determine default LTO options.
30
31 load_gcc_lib prune.exp
32 load_gcc_lib target-libpath.exp
33 load_gcc_lib wrapper.exp
34 load_gcc_lib target-supports.exp
35 load_gcc_lib target-utils.exp
36 load_gcc_lib gcc-defs.exp
37 load_gcc_lib timeout.exp
38 load_gcc_lib file-format.exp
39 load_gcc_lib target-supports-dg.exp
40 load_gcc_lib scanasm.exp
41 load_gcc_lib scandump.exp
42 load_gcc_lib scanrtl.exp
43 load_gcc_lib scantree.exp
44 load_gcc_lib scanipa.exp
45 load_gcc_lib timeout-dg.exp
46 load_gcc_lib torture-options.exp
47 load_gcc_lib fortran-modules.exp
48
49 set dg-do-what-default run
50
51 #
52 # GCC_UNDER_TEST is the compiler under test.
53 #
54
55 set libitm_compile_options ""
56
57 #
58 # libitm_init
59 #
60
61 if [info exists TOOL_OPTIONS] {
62     set multilibs [get_multilibs $TOOL_OPTIONS]
63 } else {
64     set multilibs [get_multilibs]
65 }
66
67 proc libitm_init { args } {
68     global srcdir blddir objdir tool_root_dir
69     global libitm_initialized
70     global tmpdir
71     global blddir
72     global gluefile wrap_flags
73     global ALWAYS_CFLAGS
74     global CFLAGS
75     global TOOL_EXECUTABLE TOOL_OPTIONS
76     global GCC_UNDER_TEST
77     global TESTING_IN_BUILD_TREE
78     global target_triplet
79     global always_ld_library_path
80
81     set blddir [lookfor_file [get_multilibs] libitm]
82
83     # We set LC_ALL and LANG to C so that we get the same error
84     # messages as expected.
85     setenv LC_ALL C
86     setenv LANG C
87
88     if ![info exists GCC_UNDER_TEST] then {
89         if [info exists TOOL_EXECUTABLE] {
90             set GCC_UNDER_TEST $TOOL_EXECUTABLE
91         } else {
92             set GCC_UNDER_TEST "[find_gcc]"
93         }
94     }
95
96     if ![info exists tmpdir] {
97         set tmpdir "/tmp"
98     }
99
100     if [info exists gluefile] {
101         unset gluefile
102     }
103
104     if {![info exists CFLAGS]} {
105         set CFLAGS ""
106     }
107
108     # Locate libgcc.a so we don't need to account for different values of
109     # SHLIB_EXT on different platforms
110     set gccdir [lookfor_file $tool_root_dir gcc/libgcc.a]
111     if {$gccdir != ""} {
112         set gccdir [file dirname $gccdir]
113     }
114
115     # Compute what needs to be put into LD_LIBRARY_PATH
116     set always_ld_library_path ".:${blddir}/.libs"
117
118     # Compute what needs to be added to the existing LD_LIBRARY_PATH.
119     if {$gccdir != ""} {
120         # Add AIX pthread directory first.
121         if { [llength [glob -nocomplain ${gccdir}/pthread/libgcc_s*.a]] >= 1 } {
122             append always_ld_library_path ":${gccdir}/pthread"
123         }
124         append always_ld_library_path ":${gccdir}"
125         set compiler [lindex $GCC_UNDER_TEST 0]
126
127         if { [is_remote host] == 0 && [which $compiler] != 0 } {
128           foreach i "[exec $compiler --print-multi-lib]" {
129             set mldir ""
130             regexp -- "\[a-z0-9=_/\.-\]*;" $i mldir
131             set mldir [string trimright $mldir "\;@"]
132             if { "$mldir" == "." } {
133               continue
134             }
135             if { [llength [glob -nocomplain ${gccdir}/${mldir}/libgcc_s*.so.*]] >= 1 } {
136               append always_ld_library_path ":${gccdir}/${mldir}"
137             }
138           }
139         }
140     }
141
142     set ALWAYS_CFLAGS ""
143     if { $blddir != "" } {
144         lappend ALWAYS_CFLAGS "additional_flags=-B${blddir}/"
145         lappend ALWAYS_CFLAGS "additional_flags=-I${blddir}"
146         lappend ALWAYS_CFLAGS "ldflags=-L${blddir}/.libs"
147     }
148     lappend ALWAYS_CFLAGS "additional_flags=-I${srcdir}/.."
149
150     # We use atomic operations in the testcases to validate results.
151     if { ([istarget i?86-*-*] || [istarget x86_64-*-*])
152          && [check_effective_target_ia32] } {
153         lappend ALWAYS_CFLAGS "additional_flags=-march=i486"
154     }
155
156     if [istarget *-*-darwin*] {
157         lappend ALWAYS_CFLAGS "additional_flags=-shared-libgcc"
158     }
159
160     if [istarget sparc*-*-*] {
161         lappend ALWAYS_CFLAGS "additional_flags=-mcpu=v9"
162     }
163
164     if [info exists TOOL_OPTIONS] {
165         lappend ALWAYS_CFLAGS "additional_flags=$TOOL_OPTIONS"
166     }
167
168     # Make sure that lines are not wrapped.  That can confuse the
169     # error-message parsing machinery.
170     lappend ALWAYS_CFLAGS "additional_flags=-fmessage-length=0"
171
172     # Turn on transactional memory support.
173     lappend ALWAYS_CFLAGS "additional_flags=-fgnu-tm"
174 }
175
176 #
177 # libitm_target_compile -- compile a source file
178 #
179
180 proc libitm_target_compile { source dest type options } {
181     global blddir
182     global libitm_compile_options
183     global gluefile wrap_flags
184     global ALWAYS_CFLAGS
185     global GCC_UNDER_TEST
186     global lang_test_file
187     global lang_library_path
188     global lang_link_flags
189
190     if { [info exists lang_test_file] } {
191         if { $blddir != "" } {
192             lappend options "ldflags=-L${blddir}/${lang_library_path}"
193         }
194         lappend options "ldflags=${lang_link_flags}"
195     }
196
197     if { [target_info needs_status_wrapper] != "" && [info exists gluefile] } {
198         lappend options "libs=${gluefile}"
199         lappend options "ldflags=${wrap_flags}"
200     }
201
202     lappend options "additional_flags=[libio_include_flags]"
203     lappend options "timeout=[timeout_value]"
204     lappend options "compiler=$GCC_UNDER_TEST"
205
206     set options [concat $libitm_compile_options $options]
207
208     if [info exists ALWAYS_CFLAGS] {
209         set options [concat "$ALWAYS_CFLAGS" $options]
210     }
211
212     set options [dg-additional-files-options $options $source]
213
214     set result [target_compile $source $dest $type $options]
215
216     return $result
217 }
218
219 proc libitm_option_help { } {
220     send_user " --additional_options,OPTIONS\t\tUse OPTIONS to compile the testcase files. OPTIONS should be comma-separated.\n"
221 }
222
223 proc libitm_option_proc { option } {
224     if [regexp "^--additional_options," $option] {
225         global libitm_compile_options
226         regsub "--additional_options," $option "" option
227         foreach x [split $option ","] {
228             lappend libitm_compile_options "additional_flags=$x"
229         }
230         return 1
231     } else {
232         return 0
233     }
234 }