[patch] allow '-' for stdout dump
[official-gcc.git] / libatomic / testsuite / lib / libatomic.exp
blob0a53f9e11f1bf00a953f007fb7a29894ceb8c494
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.
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.
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.
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.
18 proc load_gcc_lib { filename } {
19 global srcdir loaded_libs
21 load_file $srcdir/../../gcc/testsuite/lib/$filename
22 set loaded_libs($filename) ""
25 load_lib dg.exp
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.
31 load_gcc_lib file-format.exp
32 load_gcc_lib target-supports.exp
33 load_gcc_lib target-utils.exp
34 load_gcc_lib target-supports-dg.exp
35 load_gcc_lib scanasm.exp
36 load_gcc_lib scandump.exp
37 load_gcc_lib scanlang.exp
38 load_gcc_lib scanrtl.exp
39 load_gcc_lib scantree.exp
40 load_gcc_lib scanipa.exp
41 load_gcc_lib multiline.exp
42 load_gcc_lib prune.exp
43 load_gcc_lib target-libpath.exp
44 load_gcc_lib wrapper.exp
45 load_gcc_lib gcc-defs.exp
46 load_gcc_lib torture-options.exp
47 load_gcc_lib timeout.exp
48 load_gcc_lib timeout-dg.exp
49 load_gcc_lib fortran-modules.exp
51 set dg-do-what-default run
54 # GCC_UNDER_TEST is the compiler under test.
57 set libatomic_compile_options ""
60 # libatomic_init
63 if [info exists TOOL_OPTIONS] {
64 set multilibs [get_multilibs $TOOL_OPTIONS]
65 } else {
66 set multilibs [get_multilibs]
69 proc libatomic_init { args } {
70 global srcdir blddir objdir tool_root_dir
71 global libatomic_initialized
72 global tmpdir
73 global blddir
74 global gluefile wrap_flags
75 global ALWAYS_CFLAGS
76 global CFLAGS
77 global TOOL_EXECUTABLE TOOL_OPTIONS
78 global GCC_UNDER_TEST
79 global TESTING_IN_BUILD_TREE
80 global target_triplet
81 global always_ld_library_path
83 set blddir [lookfor_file [get_multilibs] libatomic]
85 # We set LC_ALL and LANG to C so that we get the same error
86 # messages as expected.
87 setenv LC_ALL C
88 setenv LANG C
90 if ![info exists GCC_UNDER_TEST] then {
91 if [info exists TOOL_EXECUTABLE] {
92 set GCC_UNDER_TEST $TOOL_EXECUTABLE
93 } else {
94 set GCC_UNDER_TEST "[find_gcc]"
98 if ![info exists tmpdir] {
99 set tmpdir "/tmp"
102 if [info exists gluefile] {
103 unset gluefile
106 if {![info exists CFLAGS]} {
107 set CFLAGS ""
110 # Locate libgcc.a so we don't need to account for different values of
111 # SHLIB_EXT on different platforms
112 set gccdir [lookfor_file $tool_root_dir gcc/libgcc.a]
113 if {$gccdir != ""} {
114 set gccdir [file dirname $gccdir]
117 # Compute what needs to be put into LD_LIBRARY_PATH
118 set always_ld_library_path ".:${blddir}/.libs"
120 # Compute what needs to be added to the existing LD_LIBRARY_PATH.
121 if {$gccdir != ""} {
122 # Add AIX pthread directory first.
123 if { [llength [glob -nocomplain ${gccdir}/pthread/libgcc_s*.a]] >= 1 } {
124 append always_ld_library_path ":${gccdir}/pthread"
126 append always_ld_library_path ":${gccdir}"
127 set compiler [lindex $GCC_UNDER_TEST 0]
129 if { [is_remote host] == 0 && [which $compiler] != 0 } {
130 foreach i "[exec $compiler --print-multi-lib]" {
131 set mldir ""
132 regexp -- "\[a-z0-9=_/\.-\]*;" $i mldir
133 set mldir [string trimright $mldir "\;@"]
134 if { "$mldir" == "." } {
135 continue
137 if { [llength [glob -nocomplain ${gccdir}/${mldir}/libgcc_s*.so.*]] >= 1 } {
138 append always_ld_library_path ":${gccdir}/${mldir}"
144 set ALWAYS_CFLAGS ""
145 if { $blddir != "" } {
146 lappend ALWAYS_CFLAGS "additional_flags=-B${blddir}/"
147 lappend ALWAYS_CFLAGS "additional_flags=-I${blddir}"
148 lappend ALWAYS_CFLAGS "ldflags=-L${blddir}/.libs"
150 lappend ALWAYS_CFLAGS "additional_flags=-I${srcdir}/.."
152 if [istarget *-*-darwin*] {
153 lappend ALWAYS_CFLAGS "additional_flags=-shared-libgcc"
156 if [info exists TOOL_OPTIONS] {
157 lappend ALWAYS_CFLAGS "additional_flags=$TOOL_OPTIONS"
160 # Make sure that lines are not wrapped. That can confuse the
161 # error-message parsing machinery.
162 lappend ALWAYS_CFLAGS "additional_flags=-fmessage-length=0"
164 # Turn off builtin support for atomics so that we test the library.
165 lappend ALWAYS_CFLAGS "additional_flags=-fno-inline-atomics"
166 lappend ALWAYS_CFLAGS "ldflags=-latomic"
170 # libatomic_target_compile -- compile a source file
173 proc libatomic_target_compile { source dest type options } {
174 global blddir
175 global libatomic_compile_options
176 global gluefile wrap_flags
177 global ALWAYS_CFLAGS
178 global GCC_UNDER_TEST
179 global lang_test_file
180 global lang_library_path
181 global lang_link_flags
183 if { [info exists lang_test_file] } {
184 if { $blddir != "" } {
185 lappend options "ldflags=-L${blddir}/${lang_library_path}"
187 lappend options "ldflags=${lang_link_flags}"
190 if { [target_info needs_status_wrapper] != "" && [info exists gluefile] } {
191 lappend options "libs=${gluefile}"
192 lappend options "ldflags=${wrap_flags}"
195 lappend options "additional_flags=[libio_include_flags]"
196 lappend options "timeout=[timeout_value]"
197 lappend options "compiler=$GCC_UNDER_TEST"
199 set options [concat $libatomic_compile_options $options]
201 if [info exists ALWAYS_CFLAGS] {
202 set options [concat "$ALWAYS_CFLAGS" $options]
205 set options [dg-additional-files-options $options $source]
207 set result [target_compile $source $dest $type $options]
209 return $result
212 proc libatomic_option_help { } {
213 send_user " --additional_options,OPTIONS\t\tUse OPTIONS to compile the testcase files. OPTIONS should be comma-separated.\n"
216 proc libatomic_option_proc { option } {
217 if [regexp "^--additional_options," $option] {
218 global libatomic_compile_options
219 regsub "--additional_options," $option "" option
220 foreach x [split $option ","] {
221 lappend libatomic_compile_options "additional_flags=$x"
223 return 1
224 } else {
225 return 0