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