]> git.ipfire.org Git - thirdparty/gcc.git/blame - libitm/testsuite/lib/libitm.exp
Testsuite: allow non-installed testing on darwin
[thirdparty/gcc.git] / libitm / testsuite / lib / libitm.exp
CommitLineData
0a35513e
AH
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
18proc 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
25load_lib dg.exp
6c84d576
IS
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
9e531d37 31load_gcc_lib multiline.exp
6c84d576
IS
32load_gcc_lib prune.exp
33load_gcc_lib target-libpath.exp
34load_gcc_lib wrapper.exp
69aef6dc
KT
35load_gcc_lib target-supports.exp
36load_gcc_lib target-utils.exp
6c84d576
IS
37load_gcc_lib gcc-defs.exp
38load_gcc_lib timeout.exp
6c84d576 39load_gcc_lib file-format.exp
0a35513e
AH
40load_gcc_lib target-supports-dg.exp
41load_gcc_lib scanasm.exp
42load_gcc_lib scandump.exp
62ffe920 43load_gcc_lib scanlang.exp
0a35513e 44load_gcc_lib scanrtl.exp
6cf276dd 45load_gcc_lib scansarif.exp
0a35513e 46load_gcc_lib scantree.exp
9220b511 47load_gcc_lib scanltranstree.exp
0a35513e 48load_gcc_lib scanipa.exp
6c3c13c1 49load_gcc_lib scanwpaipa.exp
0a35513e 50load_gcc_lib timeout-dg.exp
6c84d576 51load_gcc_lib torture-options.exp
6a26a74d 52load_gcc_lib fortran-modules.exp
0a35513e
AH
53
54set dg-do-what-default run
55
56#
57# GCC_UNDER_TEST is the compiler under test.
58#
59
60set libitm_compile_options ""
61
62#
63# libitm_init
64#
65
66if [info exists TOOL_OPTIONS] {
67 set multilibs [get_multilibs $TOOL_OPTIONS]
68} else {
69 set multilibs [get_multilibs]
70}
71
72proc libitm_init { args } {
73 global srcdir blddir objdir tool_root_dir
74 global libitm_initialized
75 global tmpdir
76 global blddir
77 global gluefile wrap_flags
78 global ALWAYS_CFLAGS
79 global CFLAGS
80 global TOOL_EXECUTABLE TOOL_OPTIONS
81 global GCC_UNDER_TEST
82 global TESTING_IN_BUILD_TREE
83 global target_triplet
84 global always_ld_library_path
85
86 set blddir [lookfor_file [get_multilibs] libitm]
87
88 # We set LC_ALL and LANG to C so that we get the same error
89 # messages as expected.
90 setenv LC_ALL C
91 setenv LANG C
92
93 if ![info exists GCC_UNDER_TEST] then {
94 if [info exists TOOL_EXECUTABLE] {
95 set GCC_UNDER_TEST $TOOL_EXECUTABLE
96 } else {
97 set GCC_UNDER_TEST "[find_gcc]"
98 }
99 }
100
101 if ![info exists tmpdir] {
102 set tmpdir "/tmp"
103 }
104
105 if [info exists gluefile] {
106 unset gluefile
107 }
108
109 if {![info exists CFLAGS]} {
110 set CFLAGS ""
111 }
112
113 # Locate libgcc.a so we don't need to account for different values of
114 # SHLIB_EXT on different platforms
115 set gccdir [lookfor_file $tool_root_dir gcc/libgcc.a]
116 if {$gccdir != ""} {
117 set gccdir [file dirname $gccdir]
118 }
119
120 # Compute what needs to be put into LD_LIBRARY_PATH
121 set always_ld_library_path ".:${blddir}/.libs"
122
123 # Compute what needs to be added to the existing LD_LIBRARY_PATH.
124 if {$gccdir != ""} {
125 # Add AIX pthread directory first.
126 if { [llength [glob -nocomplain ${gccdir}/pthread/libgcc_s*.a]] >= 1 } {
127 append always_ld_library_path ":${gccdir}/pthread"
128 }
129 append always_ld_library_path ":${gccdir}"
130 set compiler [lindex $GCC_UNDER_TEST 0]
131
132 if { [is_remote host] == 0 && [which $compiler] != 0 } {
133 foreach i "[exec $compiler --print-multi-lib]" {
134 set mldir ""
135 regexp -- "\[a-z0-9=_/\.-\]*;" $i mldir
136 set mldir [string trimright $mldir "\;@"]
137 if { "$mldir" == "." } {
138 continue
139 }
140 if { [llength [glob -nocomplain ${gccdir}/${mldir}/libgcc_s*.so.*]] >= 1 } {
141 append always_ld_library_path ":${gccdir}/${mldir}"
142 }
143 }
144 }
145 }
146
147 set ALWAYS_CFLAGS ""
148 if { $blddir != "" } {
149 lappend ALWAYS_CFLAGS "additional_flags=-B${blddir}/"
150 lappend ALWAYS_CFLAGS "additional_flags=-I${blddir}"
151 lappend ALWAYS_CFLAGS "ldflags=-L${blddir}/.libs"
152 }
153 lappend ALWAYS_CFLAGS "additional_flags=-I${srcdir}/.."
0a35513e
AH
154
155 # We use atomic operations in the testcases to validate results.
156 if { ([istarget i?86-*-*] || [istarget x86_64-*-*])
2841f85e 157 && [check_effective_target_ia32] } {
0a35513e
AH
158 lappend ALWAYS_CFLAGS "additional_flags=-march=i486"
159 }
160
161 if [istarget *-*-darwin*] {
a0673ec5 162 lappend ALWAYS_CFLAGS "additional_flags=-B${blddir}/.libs"
0a35513e
AH
163 lappend ALWAYS_CFLAGS "additional_flags=-shared-libgcc"
164 }
165
166 if [istarget sparc*-*-*] {
167 lappend ALWAYS_CFLAGS "additional_flags=-mcpu=v9"
168 }
169
170 if [info exists TOOL_OPTIONS] {
171 lappend ALWAYS_CFLAGS "additional_flags=$TOOL_OPTIONS"
172 }
173
174 # Make sure that lines are not wrapped. That can confuse the
175 # error-message parsing machinery.
176 lappend ALWAYS_CFLAGS "additional_flags=-fmessage-length=0"
177
178 # Turn on transactional memory support.
179 lappend ALWAYS_CFLAGS "additional_flags=-fgnu-tm"
1136ba01
NS
180
181 lappend ALWAYS_CFLAGS "additional_flags=-fdiagnostics-color=never"
0a35513e
AH
182}
183
184#
185# libitm_target_compile -- compile a source file
186#
187
188proc libitm_target_compile { source dest type options } {
189 global blddir
190 global libitm_compile_options
191 global gluefile wrap_flags
192 global ALWAYS_CFLAGS
193 global GCC_UNDER_TEST
194 global lang_test_file
195 global lang_library_path
196 global lang_link_flags
197
198 if { [info exists lang_test_file] } {
199 if { $blddir != "" } {
200 lappend options "ldflags=-L${blddir}/${lang_library_path}"
201 }
202 lappend options "ldflags=${lang_link_flags}"
203 }
204
205 if { [target_info needs_status_wrapper] != "" && [info exists gluefile] } {
206 lappend options "libs=${gluefile}"
207 lappend options "ldflags=${wrap_flags}"
208 }
209
210 lappend options "additional_flags=[libio_include_flags]"
211 lappend options "timeout=[timeout_value]"
212 lappend options "compiler=$GCC_UNDER_TEST"
213
214 set options [concat $libitm_compile_options $options]
215
216 if [info exists ALWAYS_CFLAGS] {
217 set options [concat "$ALWAYS_CFLAGS" $options]
218 }
219
220 set options [dg-additional-files-options $options $source]
221
222 set result [target_compile $source $dest $type $options]
223
224 return $result
225}
226
227proc libitm_option_help { } {
228 send_user " --additional_options,OPTIONS\t\tUse OPTIONS to compile the testcase files. OPTIONS should be comma-separated.\n"
229}
230
231proc libitm_option_proc { option } {
232 if [regexp "^--additional_options," $option] {
233 global libitm_compile_options
234 regsub "--additional_options," $option "" option
235 foreach x [split $option ","] {
236 lappend libitm_compile_options "additional_flags=$x"
237 }
238 return 1
239 } else {
240 return 0
241 }
242}