1# Damn dejagnu for not having proper library search paths for load_lib. 2# We have to explicitly load everything that gcc-dg.exp wants to load. 3 4proc load_gcc_lib { filename } { 5 global srcdir loaded_libs 6 7 load_file $srcdir/../../gcc/testsuite/lib/$filename 8 set loaded_libs($filename) "" 9} 10 11load_lib dg.exp 12load_gcc_lib file-format.exp 13load_gcc_lib target-supports.exp 14load_gcc_lib target-supports-dg.exp 15load_gcc_lib scanasm.exp 16load_gcc_lib scandump.exp 17load_gcc_lib scanrtl.exp 18load_gcc_lib scantree.exp 19load_gcc_lib scanipa.exp 20load_gcc_lib prune.exp 21load_gcc_lib target-libpath.exp 22load_gcc_lib wrapper.exp 23load_gcc_lib gcc-defs.exp 24load_gcc_lib gcc-dg.exp 25load_gcc_lib gfortran-dg.exp 26 27set dg-do-what-default run 28 29# 30# GCC_UNDER_TEST is the compiler under test. 31# 32 33set libgomp_compile_options "" 34 35# 36# libgomp_init -- This gets run more than it should be.... 37# 38 39if [info exists TOOL_OPTIONS] { 40 set multilibs [get_multilibs $TOOL_OPTIONS] 41} else { 42 set multilibs [get_multilibs] 43} 44 45proc libgomp_init { args } { 46 global srcdir blddir objdir tool_root_dir 47 global libgomp_initialized 48 global tmpdir 49 global gluefile wrap_flags 50 global ALWAYS_CFLAGS 51 global CFLAGS 52 global TOOL_EXECUTABLE TOOL_OPTIONS 53 global GCC_UNDER_TEST 54 global TESTING_IN_BUILD_TREE 55 global target_triplet 56 global ld_library_path 57 global lang_test_file 58 global lang_library_path 59 global lang_link_flags 60 61 set blddir [lookfor_file [get_multilibs] libgomp] 62 63 # We set LC_ALL and LANG to C so that we get the same error 64 # messages as expected. 65 setenv LC_ALL C 66 setenv LANG C 67 68 if ![info exists GCC_UNDER_TEST] then { 69 if [info exists TOOL_EXECUTABLE] { 70 set GCC_UNDER_TEST $TOOL_EXECUTABLE 71 } else { 72 set GCC_UNDER_TEST "[find_gcc]" 73 } 74 } 75 76 if ![info exists tmpdir] { 77 set tmpdir "/tmp" 78 } 79 80 if [info exists gluefile] { 81 unset gluefile 82 } 83 84 if {![info exists CFLAGS]} { 85 set CFLAGS "" 86 } 87 88 # Locate libgcc.a so we don't need to account for different values of 89 # SHLIB_EXT on different platforms 90 set gccdir [lookfor_file $tool_root_dir gcc/libgcc.a] 91 if {$gccdir != ""} { 92 set gccdir [file dirname $gccdir] 93 } 94 95 # Compute what needs to be put into LD_LIBRARY_PATH 96 set ld_library_path ".:${blddir}/.libs" 97 98 if { [info exists lang_test_file] && [file exists "${blddir}/"] } { 99 append ld_library_path ":${blddir}/${lang_library_path}" 100 } 101 102 # Compute what needs to be added to the existing LD_LIBRARY_PATH. 103 if {$gccdir != ""} { 104 append ld_library_path ":${gccdir}" 105 set compiler [lindex $GCC_UNDER_TEST 0] 106 107 if { [is_remote host] == 0 && [which $compiler] != 0 } { 108 foreach i "[exec $compiler --print-multi-lib]" { 109 set mldir "" 110 regexp -- "\[a-z0-9=_/\.-\]*;" $i mldir 111 set mldir [string trimright $mldir "\;@"] 112 if { "$mldir" == "." } { 113 continue 114 } 115 if { [llength [glob -nocomplain ${gccdir}/${mldir}/libgcc_s*.so.*]] >= 1 } { 116 append ld_library_path ":${gccdir}/${mldir}" 117 } 118 } 119 } 120 } 121 set_ld_library_path_env_vars 122 123 set ALWAYS_CFLAGS "" 124 lappend ALWAYS_CFLAGS "additional_flags=-B${blddir}/" 125 lappend ALWAYS_CFLAGS "additional_flags=-I${blddir}" 126 lappend ALWAYS_CFLAGS "additional_flags=-I${srcdir}/.." 127 lappend ALWAYS_CFLAGS "ldflags=-L${blddir}/.libs -lgomp" 128 if { [info exists lang_test_file] && [file exists "${blddir}/"] } { 129 lappend ALWAYS_CFLAGS "ldflags=-L${blddir}/${lang_library_path} ${lang_link_flags}" 130 } 131 132 # We use atomic operations in the testcases to validate results. 133 if [istarget i?86-*-*] { 134 lappend ALWAYS_CFLAGS "additional_flags=-march=i486" 135 } 136 if [istarget sparc*-*-*] { 137 lappend ALWAYS_CFLAGS "additional_flags=-mcpu=v9" 138 } 139 140 if [info exists TOOL_OPTIONS] { 141 lappend ALWAYS_CFLAGS "additional_flags=$TOOL_OPTIONS" 142 } 143 144 # Make sure that lines are not wrapped. That can confuse the 145 # error-message parsing machinery. 146 lappend ALWAYS_CFLAGS "additional_flags=-fmessage-length=0" 147 148 # And, gee, turn on OpenMP. 149 lappend ALWAYS_CFLAGS "additional_flags=-fopenmp" 150} 151 152# 153# libgomp_target_compile -- compile a source file 154# 155 156proc libgomp_target_compile { source dest type options } { 157 global tmpdir 158 global libgomp_compile_options 159 global gluefile wrap_flags 160 global ALWAYS_CFLAGS 161 global GCC_UNDER_TEST 162 163 libgomp_init 164 165 if { [target_info needs_status_wrapper] != "" && [info exists gluefile] } { 166 lappend options "libs=${gluefile}" 167 lappend options "ldflags=${wrap_flags}" 168 } 169 170 lappend options "additional_flags=[libio_include_flags]" 171 lappend options "compiler=$GCC_UNDER_TEST" 172 173 set options [concat $libgomp_compile_options $options] 174 175 set options [concat "$ALWAYS_CFLAGS" $options] 176 177 set options [dg-additional-files-options $options $source] 178 179 set result [target_compile $source $dest $type $options] 180 181 return $result 182} 183 184# ??? The same as in standard.exp. Why doesn't anyone else have to 185# define this? 186 187proc libgomp_load { program args } { 188 if { [llength $args] > 0 } { 189 set program_args [lindex $args 0] 190 } else { 191 set program_args "" 192 } 193 194 if { [llength $args] > 1 } { 195 set input_file [lindex $args 1] 196 } else { 197 set input_file "" 198 } 199 return [remote_load target $program $program_args $input_file] 200} 201 202proc libgomp_option_help { } { 203 send_user " --additional_options,OPTIONS\t\tUse OPTIONS to compile the testcase files. OPTIONS should be comma-separated.\n" 204} 205 206proc libgomp_option_proc { option } { 207 if [regexp "^--additional_options," $option] { 208 global libgomp_compile_options 209 regsub "--additional_options," $option "" option 210 foreach x [split $option ","] { 211 lappend libgomp_compile_options "additional_flags=$x" 212 } 213 return 1 214 } else { 215 return 0 216 } 217} 218 219proc libgomp-dg-test { prog do_what extra_tool_flags } { 220 return [gcc-dg-test-1 libgomp_target_compile $prog $do_what $extra_tool_flags] 221} 222 223proc libgomp-dg-prune { system text } { 224 return [gcc-dg-prune $system $text] 225} 226