1 # Copyright
(C
) 2017-2020 Free Software Foundation
, Inc.
3 # This
program is free software
; you can redistribute it and
/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation
; either version
3 of the License
, or
6 #
(at your option
) any later version.
8 # This
program is distributed in the hope that it will be useful
,
9 # but WITHOUT
ANY WARRANTY
; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License
for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with GCC
; see the file COPYING3.
If not see
15 #
<http
://www.gnu.org
/licenses
/>.
18 # DejaGnu does not have proper library search paths
for load_lib.
19 # We have to explicitly
load everything that gdc.exp wants to
load.
22 proc load_gcc_lib
{ filename
} {
23 global srcdir loaded_libs
25 load_file $srcdir
/..
/..
/gcc
/testsuite
/lib
/$filename
26 set loaded_libs
($filename
) ""
32 load_gcc_lib target
-supports.exp
33 load_gcc_lib target
-supports
-dg.exp
34 load_gcc_lib dg
-options.exp
35 load_gcc_lib target
-libpath.exp
36 load_gcc_lib timeout.exp
37 load_gcc_lib wrapper.exp
38 load_gcc_lib target
-utils.exp
39 load_gcc_lib gcc
-defs.exp
41 set TESTING_IN_BUILD_TREE
1
43 #
Define libphobos callbacks
for dg.exp.
45 proc libphobos
-dg
-test
{ prog do_what extra_tool_flags
} {
49 global libphobos_test_name
51 if { $libphobos_test_name
!= "" } {
52 set name $libphobos_test_name
55 #
Set up the compiler flags
, based
on what we
're going to do.
58 set compile_type "executable"
59 # FIXME: "./" is to cope with "." not being in $PATH.
60 # Should this be handled elsewhere?
62 set output_file "./[file rootname [file tail $prog]].exe"
63 # This is the only place where we care if an executable was
64 # created or not. If it was, dg.exp will try to run it.
65 catch { remote_file build delete $output_file }
68 set compile_type "executable"
69 set output_file "./[file rootname [file tail $prog]].exe"
72 perror "$do_what: not a valid dg-do keyword"
77 set select_compile "libphobos_target_compile"
79 if { $extra_tool_flags != "" } {
80 lappend options "additional_flags=$extra_tool_flags"
83 set unsupported_message [libphobos_skipped_test_p $name]
84 if { $unsupported_message != "" } {
85 return [list "::unsupported::$unsupported_message" $output_file]
88 set comp_output [$select_compile "$prog" "$output_file" "$compile_type" $options]
89 return [list $comp_output $output_file]
92 proc libphobos-dg-prune { system text } {
100 proc libphobos_init { args } {
102 global srcdir blddir objdir tool_root_dir
105 global gdcpaths gdcldflags
106 global gluefile wrap_flags
107 global ld_library_path
109 global DEFAULT_DFLAGS
111 # If a testcase doesn't have special options
, use these.
112 if ![info exists DEFAULT_DFLAGS
] then {
113 set DEFAULT_DFLAGS
""
116 # By default
, we assume we want to run
program images.
117 global dg
-do-what
-default
119 set dg
-do-what
-default
"run"
121 set dg
-do-what
-default
"link"
124 # What arguments to pass to run
program images.
125 global libphobos_run_args
126 set libphobos_run_args
""
128 #
If the
name of the test should be something
else.
129 global libphobos_test_name
130 set libphobos_test_name
""
132 global libphobos_skip_tests
133 set libphobos_skip_tests
{ }
136 set blddir
[lookfor_file
[get_multilibs
] libphobos
]
137 set flags_file
"${blddir}/testsuite/testsuite_flags"
138 set shlib_ext
[get_shlib_extension
]
140 set gdc
[transform
"gdc"]
141 set gdcflags
"-fmessage-length=0"
142 set gdcpaths
"-I${srcdir}"
145 if { [file
exists $flags_file
] } {
146 set gdc
[exec sh $flags_file
--gdc
]
147 set gdcflags
[exec sh $flags_file
--gdcflags
]
148 set gdcpaths
[exec sh $flags_file
--gdcpaths
]
149 set gdcldflags
[exec sh $flags_file
--gdcldflags
]
153 if [info exists env
(EXEEXT
)] {
154 set exeext $env
(EXEEXT
)
157 # Compute what needs to be added to the existing LD_LIBRARY_PATH.
158 set ld_library_path
"."
160 set gccdir
[lookfor_file $tool_root_dir gcc
/libgcc.a
]
162 set gccdir
[file dirname $gccdir
]
163 append ld_library_path
":${gccdir}"
166 if { [file
exists "${blddir}/src/.libs/libgphobos.${shlib_ext}"] } {
167 append ld_library_path
":${blddir}/src/.libs"
170 # Compute what needs to be added to the existing LD_LIBRARY_PATH.
172 set compiler $
{gccdir
}/gdc
174 if { [is_remote host
] == 0 && [which $compiler
] != 0 } {
175 foreach i
"[exec $compiler --print-multi-lib]" {
177 regexp
-- "\[a-z0-9=_/\.-\]*;" $i mldir
178 set mldir
[string trimright $mldir
"\;@"]
179 if { "$mldir" == "." } {
182 if { [llength
[glob
-nocomplain $
{gccdir
}/$
{mldir
}/libgcc_s
*.so.
*]] >= 1 } {
183 append ld_library_path
":${gccdir}/${mldir}"
189 #
Set the default timeout
for phobos tests.
192 set_ld_library_path_env_vars
194 libphobos_maybe_build_wrapper
"${objdir}/testglue.o"
198 # libphobos_target_compile
-- compile a source file.
201 proc libphobos_target_compile
{ source dest type options
} {
203 global gdcpaths gdcldflags
204 global gluefile wrap_flags
206 lappend options
"additional_flags=-fno-diagnostics-show-caret -fdiagnostics-color=never"
208 if { [target_info needs_status_wrapper
] != "" && [info exists gluefile] } {
209 lappend options
"libs=${gluefile}"
210 lappend options
"ldflags=${wrap_flags}"
213 # Flag setting based
on type
argument.
214 if { $type
== "executable" } {
215 # Link the support objects into executables.
216 lappend options
"additional_flags=$gdcldflags"
219 #
Set the compiler
, only add D flags and paths
if building D sources.
221 if [regexp
".*\.d\$" $source] {
222 set gdc_final
[concat $gdc_final $gdcflags
]
223 set gdc_final
[concat $gdc_final $gdcpaths
]
226 lappend options
"compiler=$gdc_final"
227 lappend options
"timeout=[timeout_value]"
229 set options
[dg
-additional
-files
-options $options $source
]
230 set comp_output
[target_compile $source $dest $type $options
]
236 # Helper used by libphobos and libdruntime unittest runner
, filters out
237 # D sources that may contain a unittest function.
240 proc filter_libphobos_unittests
{ list
} {
242 foreach filename $list
{
243 set fid
[open $filename r
]
244 if [regexp
-- {unittest
} [read $fid
[file size $filename
]]] {
245 lappend res $filename
252 # Skip the unittest
(report it as UNSUPPORTED
) if the module
exists in
253 # libphobos_skip_tests and its target list is matched by dg
-process
-target.
255 # The expected format of the libphobos_skip_tests file is
:
256 #
{ test
{ targets
} }
257 proc libphobos_skipped_test_p
{ test
} {
258 global libphobos_skip_tests
260 set row [lsearch
-inline
-index
0 $libphobos_skip_tests $test
]
265 if { [llength $
row] != 2 } {
266 error
"syntax error in libphobos_skip_tests: $row"
269 set selector
[list target
[lindex $
row 1]]
270 if { [dg
-process
-target
-1 $selector
] != "S" } {
274 return "skipped test"
277 #
Return true
if the curl library is supported
on the target.
278 proc check_effective_target_libcurl_available
{ } {
279 return [check_no_compiler_messages libcurl_available executable
{
280 int main
(void
) { return 0; }
284 #
Return true
if the target is linux version
< 2.6.39
285 proc check_effective_target_linux_pre_2639
{ } {
286 if { ![istarget
*-*-linux
*] } {
290 if { [check_no_compiler_messages linux_pre_2639 assembly
{
291 #
include <linux
/version.h
>
292 #
if !defined LINUX_VERSION_CODE || LINUX_VERSION_CODE
< KERNEL_VERSION
(2,6,39)