Reid Spencer | 12d81f3 | 2007-04-21 21:45:51 +0000 | [diff] [blame] | 1 | # This procedure executes one line of a test case's execution script. |
Reid Spencer | 90016c7 | 2007-04-14 19:37:22 +0000 | [diff] [blame] | 2 | proc execOneLine { test PRS outcome lineno line } { |
Reid Spencer | 316abe4 | 2007-04-14 09:39:28 +0000 | [diff] [blame] | 3 | set status 0 |
| 4 | set resultmsg "" |
| 5 | set retval [ catch { eval exec -keepnewline -- $line } errmsg ] |
| 6 | if { $retval != 0 } { |
| 7 | set code [lindex $::errorCode 0] |
Reid Spencer | 520b487 | 2007-04-14 16:41:39 +0000 | [diff] [blame] | 8 | set lineno [expr $lineno + 1] |
Reid Spencer | 90016c7 | 2007-04-14 19:37:22 +0000 | [diff] [blame] | 9 | if { $PRS != ""} { |
Mikhail Glushenkov | 922b2a2 | 2009-03-06 12:21:40 +0000 | [diff] [blame] | 10 | set PRS " for $PRS" |
Reid Spencer | 90016c7 | 2007-04-14 19:37:22 +0000 | [diff] [blame] | 11 | } |
Reid Spencer | 6cdf4a9 | 2007-04-21 18:53:12 +0000 | [diff] [blame] | 12 | set errmsg " at line $lineno\nwhile running: $line\n$errmsg" |
Reid Spencer | 316abe4 | 2007-04-14 09:39:28 +0000 | [diff] [blame] | 13 | switch "$code" { |
| 14 | CHILDSTATUS { |
| 15 | set status [lindex $::errorCode 2] |
Duncan Sands | 25d50d6 | 2007-04-16 15:37:00 +0000 | [diff] [blame] | 16 | if { $status != 0 } { |
Reid Spencer | 6cdf4a9 | 2007-04-21 18:53:12 +0000 | [diff] [blame] | 17 | set resultmsg "$test$PRS\nFailed with exit($status)$errmsg" |
Reid Spencer | 316abe4 | 2007-04-14 09:39:28 +0000 | [diff] [blame] | 18 | } |
| 19 | } |
| 20 | CHILDKILLED { |
| 21 | set signal [lindex $::errorCode 2] |
Reid Spencer | 6cdf4a9 | 2007-04-21 18:53:12 +0000 | [diff] [blame] | 22 | set resultmsg "$test$PRS\nFailed with signal($signal)$errmsg" |
Reid Spencer | 316abe4 | 2007-04-14 09:39:28 +0000 | [diff] [blame] | 23 | } |
| 24 | CHILDSUSP { |
| 25 | set signal [lindex $::errorCode 2] |
Reid Spencer | 6cdf4a9 | 2007-04-21 18:53:12 +0000 | [diff] [blame] | 26 | set resultmsg "$test$PRS\nFailed with suspend($signal)$errmsg" |
Reid Spencer | 316abe4 | 2007-04-14 09:39:28 +0000 | [diff] [blame] | 27 | } |
| 28 | POSIX { |
| 29 | set posixNum [lindex $::errorCode 1] |
| 30 | set posixMsg [lindex $::errorCode 2] |
Reid Spencer | 6cdf4a9 | 2007-04-21 18:53:12 +0000 | [diff] [blame] | 31 | set resultmsg "$test$PRS\nFailed with posix($posixNum,$posixMsg)$errmsg" |
Reid Spencer | 316abe4 | 2007-04-14 09:39:28 +0000 | [diff] [blame] | 32 | } |
| 33 | NONE { |
Matthijs Kooijman | c9e0043 | 2008-06-10 12:28:43 +0000 | [diff] [blame] | 34 | # Any other error such as stderr output of a program, or syntax error in |
| 35 | # the RUN line. |
Mikhail Glushenkov | 922b2a2 | 2009-03-06 12:21:40 +0000 | [diff] [blame] | 36 | set resultmsg "$test$PRS\nFailed with unknown error (or has stderr output)$errmsg" |
Reid Spencer | 316abe4 | 2007-04-14 09:39:28 +0000 | [diff] [blame] | 37 | } |
| 38 | default { |
Mikhail Glushenkov | 922b2a2 | 2009-03-06 12:21:40 +0000 | [diff] [blame] | 39 | set resultmsg "$test$PRS\nFailed with unknown error$errmsg" |
Reid Spencer | 316abe4 | 2007-04-14 09:39:28 +0000 | [diff] [blame] | 40 | } |
| 41 | } |
Mikhail Glushenkov | 922b2a2 | 2009-03-06 12:21:40 +0000 | [diff] [blame] | 42 | } |
Reid Spencer | 316abe4 | 2007-04-14 09:39:28 +0000 | [diff] [blame] | 43 | return $resultmsg |
| 44 | } |
| 45 | |
Duncan Sands | 7d841a4 | 2007-05-18 12:13:34 +0000 | [diff] [blame] | 46 | # This procedure performs variable substitutions on the RUN: lines of a test |
Reid Spencer | 12d81f3 | 2007-04-21 21:45:51 +0000 | [diff] [blame] | 47 | # cases. |
Reid Spencer | 316abe4 | 2007-04-14 09:39:28 +0000 | [diff] [blame] | 48 | proc substitute { line test tmpFile } { |
Daniel Dunbar | f3e2d80 | 2009-09-10 04:56:59 +0000 | [diff] [blame] | 49 | global srcroot objroot srcdir objdir subdir target_triplet |
Duncan Sands | 48f296d | 2010-11-25 21:19:52 +0000 | [diff] [blame] | 50 | global llvmgcc llvmgxx emitir ocamlopt |
Evan Cheng | 802cd84 | 2009-03-21 18:12:24 +0000 | [diff] [blame] | 51 | global gccpath gxxpath compile_c compile_cxx link shlibext llvmlibsdir |
| 52 | global llvmdsymutil valgrind grep gas bugpoint_topts |
Reid Spencer | 78fb2ac | 2007-04-14 22:51:29 +0000 | [diff] [blame] | 53 | set path [file join $srcdir $subdir] |
Reid Spencer | 316abe4 | 2007-04-14 09:39:28 +0000 | [diff] [blame] | 54 | |
Reid Spencer | 0947df4 | 2007-04-15 07:21:26 +0000 | [diff] [blame] | 55 | # Substitute all Tcl variables. |
| 56 | set new_line [subst $line ] |
| 57 | |
Nuno Lopes | 2bdc07b | 2008-10-07 14:48:14 +0000 | [diff] [blame] | 58 | #replace %% with _#MARKER#_ to make the replacement of %% more predictable |
| 59 | regsub -all {%%} $new_line {_#MARKER#_} new_line |
Daniel Dunbar | b25f32b | 2009-09-07 19:25:54 +0000 | [diff] [blame] | 60 | #replace %llvmgcc_only with actual path to llvmgcc |
| 61 | regsub -all {%llvmgcc_only} $new_line "$llvmgcc" new_line |
Reid Spencer | 316abe4 | 2007-04-14 09:39:28 +0000 | [diff] [blame] | 62 | #replace %llvmgcc with actual path to llvmgcc |
Duncan Sands | 48f296d | 2010-11-25 21:19:52 +0000 | [diff] [blame] | 63 | regsub -all {%llvmgcc} $new_line "$llvmgcc $emitir -w" new_line |
Reid Spencer | 316abe4 | 2007-04-14 09:39:28 +0000 | [diff] [blame] | 64 | #replace %llvmgxx with actual path to llvmg++ |
Duncan Sands | 48f296d | 2010-11-25 21:19:52 +0000 | [diff] [blame] | 65 | regsub -all {%llvmgxx} $new_line "$llvmgxx $emitir -w" new_line |
Reid Spencer | 316abe4 | 2007-04-14 09:39:28 +0000 | [diff] [blame] | 66 | #replace %compile_cxx with C++ compilation command |
| 67 | regsub -all {%compile_cxx} $new_line "$compile_cxx" new_line |
Chris Lattner | aadbda8 | 2008-03-10 06:45:35 +0000 | [diff] [blame] | 68 | #replace %compile_c with C compilation command |
| 69 | regsub -all {%compile_c} $new_line "$compile_c" new_line |
Reid Spencer | 316abe4 | 2007-04-14 09:39:28 +0000 | [diff] [blame] | 70 | #replace %link with C++ link command |
| 71 | regsub -all {%link} $new_line "$link" new_line |
| 72 | #replace %shlibext with shared library extension |
| 73 | regsub -all {%shlibext} $new_line "$shlibext" new_line |
Erick Tryzelaar | b405bbe | 2009-09-03 23:27:31 +0000 | [diff] [blame] | 74 | #replace %ocamlopt with ocaml compiler command |
| 75 | regsub -all {%ocamlopt} $new_line "$ocamlopt" new_line |
Devang Patel | 6748f04 | 2009-02-02 21:09:36 +0000 | [diff] [blame] | 76 | #replace %llvmdsymutil with dsymutil command |
| 77 | regsub -all {%llvmdsymutil} $new_line "$llvmdsymutil" new_line |
Reid Spencer | 316abe4 | 2007-04-14 09:39:28 +0000 | [diff] [blame] | 78 | #replace %llvmlibsdir with configure library directory |
| 79 | regsub -all {%llvmlibsdir} $new_line "$llvmlibsdir" new_line |
Evan Cheng | 802cd84 | 2009-03-21 18:12:24 +0000 | [diff] [blame] | 80 | #replace %bugpoint_topts with actual bugpoint target options |
| 81 | regsub -all {%bugpoint_topts} $new_line "$bugpoint_topts" new_line |
Mikhail Glushenkov | 922b2a2 | 2009-03-06 12:21:40 +0000 | [diff] [blame] | 82 | #replace %p with path to source, |
Reid Spencer | 316abe4 | 2007-04-14 09:39:28 +0000 | [diff] [blame] | 83 | regsub -all {%p} $new_line [file join $srcdir $subdir] new_line |
| 84 | #replace %s with filename |
| 85 | regsub -all {%s} $new_line $test new_line |
| 86 | #replace %t with temp filenames |
Duncan Sands | 6c7ada4 | 2007-07-23 15:23:35 +0000 | [diff] [blame] | 87 | regsub -all {%t} $new_line $tmpFile new_line |
Daniel Dunbar | 5110609 | 2009-09-13 01:39:50 +0000 | [diff] [blame] | 88 | #replace %abs_tmp with absolute temp filenames |
| 89 | regsub -all {%abs_tmp} $new_line [file join [pwd] $tmpFile] new_line |
Nuno Lopes | 2bdc07b | 2008-10-07 14:48:14 +0000 | [diff] [blame] | 90 | #replace _#MARKER#_ with % |
| 91 | regsub -all {_#MARKER#_} $new_line % new_line |
| 92 | |
Torok Edwin | 237033e | 2008-10-21 17:21:32 +0000 | [diff] [blame] | 93 | #replace grep with GNU grep |
| 94 | regsub -all { grep } $new_line " $grep " new_line |
| 95 | #replace as with GNU as |
| 96 | regsub -all {\| as } $new_line "| $gas " new_line |
| 97 | |
Nuno Lopes | 2bdc07b | 2008-10-07 14:48:14 +0000 | [diff] [blame] | 98 | #valgind related stuff |
| 99 | # regsub -all {bugpoint } $new_line "$valgrind bugpoint " new_line |
| 100 | regsub -all {llc } $new_line "$valgrind llc " new_line |
| 101 | regsub -all {lli } $new_line "$valgrind lli " new_line |
| 102 | regsub -all {llvm-ar } $new_line "$valgrind llvm-ar " new_line |
| 103 | regsub -all {llvm-as } $new_line "$valgrind llvm-as " new_line |
| 104 | regsub -all {llvm-bcanalyzer } $new_line "$valgrind llvm-bcanalyzer " new_line |
| 105 | regsub -all {llvm-dis } $new_line "$valgrind llvm-dis " new_line |
| 106 | regsub -all {llvm-extract } $new_line "$valgrind llvm-extract " new_line |
| 107 | regsub -all {llvm-ld } $new_line "$valgrind llvm-ld " new_line |
| 108 | regsub -all {llvm-link } $new_line "$valgrind llvm-link " new_line |
| 109 | regsub -all {llvm-nm } $new_line "$valgrind llvm-nm " new_line |
| 110 | regsub -all {llvm-prof } $new_line "$valgrind llvm-prof " new_line |
| 111 | regsub -all {llvm-ranlib } $new_line "$valgrind llvm-ranlib " new_line |
| 112 | regsub -all {([^a-zA-Z_-])opt } $new_line "\\1$valgrind opt " new_line |
| 113 | regsub -all {^opt } $new_line "$valgrind opt " new_line |
| 114 | regsub -all {tblgen } $new_line "$valgrind tblgen " new_line |
| 115 | regsub -all "not $valgrind " $new_line "$valgrind not " new_line |
| 116 | |
Reid Spencer | 316abe4 | 2007-04-14 09:39:28 +0000 | [diff] [blame] | 117 | return $new_line |
| 118 | } |
| 119 | |
Reid Spencer | 12d81f3 | 2007-04-21 21:45:51 +0000 | [diff] [blame] | 120 | # This procedure runs the set of tests for the test_source_files array. |
Reid Spencer | 78fb2ac | 2007-04-14 22:51:29 +0000 | [diff] [blame] | 121 | proc RunLLVMTests { test_source_files } { |
Daniel Dunbar | 3d4d01b | 2010-02-23 07:56:28 +0000 | [diff] [blame] | 122 | global srcroot objroot srcdir objdir subdir target_triplet |
Reid Spencer | 316abe4 | 2007-04-14 09:39:28 +0000 | [diff] [blame] | 123 | set timeout 60 |
| 124 | |
| 125 | set path [file join $objdir $subdir] |
Mikhail Glushenkov | 922b2a2 | 2009-03-06 12:21:40 +0000 | [diff] [blame] | 126 | |
Reid Spencer | 316abe4 | 2007-04-14 09:39:28 +0000 | [diff] [blame] | 127 | #Make Output Directory if it does not exist already |
| 128 | if { [file exists path] } { |
| 129 | cd $path |
| 130 | } else { |
| 131 | file mkdir $path |
| 132 | cd $path |
| 133 | } |
Mikhail Glushenkov | 922b2a2 | 2009-03-06 12:21:40 +0000 | [diff] [blame] | 134 | |
Reid Spencer | 316abe4 | 2007-04-14 09:39:28 +0000 | [diff] [blame] | 135 | file mkdir Output |
Duncan Sands | 6c7ada4 | 2007-07-23 15:23:35 +0000 | [diff] [blame] | 136 | cd Output |
Reid Spencer | 316abe4 | 2007-04-14 09:39:28 +0000 | [diff] [blame] | 137 | |
Reid Spencer | 78fb2ac | 2007-04-14 22:51:29 +0000 | [diff] [blame] | 138 | foreach test $test_source_files { |
Reid Spencer | 316abe4 | 2007-04-14 09:39:28 +0000 | [diff] [blame] | 139 | #Should figure out best way to set the timeout |
| 140 | #set timeout 40 |
Mikhail Glushenkov | 922b2a2 | 2009-03-06 12:21:40 +0000 | [diff] [blame] | 141 | |
Reid Spencer | 316abe4 | 2007-04-14 09:39:28 +0000 | [diff] [blame] | 142 | set filename [file tail $test] |
Gabor Greif | 684ed3d | 2008-02-26 12:08:55 +0000 | [diff] [blame] | 143 | verbose "ABOUT TO RUN: $filename" 2 |
Reid Spencer | 316abe4 | 2007-04-14 09:39:28 +0000 | [diff] [blame] | 144 | set outcome PASS |
| 145 | set tmpFile "$filename.tmp" |
Mikhail Glushenkov | 922b2a2 | 2009-03-06 12:21:40 +0000 | [diff] [blame] | 146 | |
Tanya Lattner | a57506e | 2007-11-06 22:32:17 +0000 | [diff] [blame] | 147 | # Mark that it should not be XFAIL for this target. |
| 148 | set targetPASS 0 |
Mikhail Glushenkov | 922b2a2 | 2009-03-06 12:21:40 +0000 | [diff] [blame] | 149 | |
Reid Spencer | 316abe4 | 2007-04-14 09:39:28 +0000 | [diff] [blame] | 150 | #set hasRunline bool to check if testcase has a runline |
| 151 | set numLines 0 |
| 152 | |
| 153 | # Open the test file and start reading lines |
| 154 | set testFileId [ open $test r] |
| 155 | set runline "" |
Reid Spencer | 90016c7 | 2007-04-14 19:37:22 +0000 | [diff] [blame] | 156 | set PRNUMS "" |
Reid Spencer | fb7653e | 2007-04-15 20:43:36 +0000 | [diff] [blame] | 157 | foreach line [split [read $testFileId] \n] { |
Reid Spencer | 316abe4 | 2007-04-14 09:39:28 +0000 | [diff] [blame] | 158 | |
Reid Spencer | 90016c7 | 2007-04-14 19:37:22 +0000 | [diff] [blame] | 159 | # if its the END. line then stop parsing (optimization for big files) |
Mikhail Glushenkov | 922b2a2 | 2009-03-06 12:21:40 +0000 | [diff] [blame] | 160 | if {[regexp {END.[[:space:]]*$} $line match endofscript]} { |
Reid Spencer | 316abe4 | 2007-04-14 09:39:28 +0000 | [diff] [blame] | 161 | break |
Reid Spencer | 90016c7 | 2007-04-14 19:37:22 +0000 | [diff] [blame] | 162 | |
Duncan Sands | 3724df3 | 2007-04-16 21:19:45 +0000 | [diff] [blame] | 163 | # if the line is continued, concatenate and continue the loop |
Reid Spencer | 601e845 | 2007-04-15 18:38:42 +0000 | [diff] [blame] | 164 | } elseif {[regexp {RUN: *(.+)(\\)$} $line match oneline suffix]} { |
Reid Spencer | 316abe4 | 2007-04-14 09:39:28 +0000 | [diff] [blame] | 165 | set runline "$runline$oneline " |
Reid Spencer | 90016c7 | 2007-04-14 19:37:22 +0000 | [diff] [blame] | 166 | |
| 167 | # if its a terminating RUN: line then do substitution on the whole line |
Mikhail Glushenkov | 922b2a2 | 2009-03-06 12:21:40 +0000 | [diff] [blame] | 168 | # and then save the line. |
Tanya Lattner | 727842e | 2007-11-28 04:57:00 +0000 | [diff] [blame] | 169 | } elseif {[regexp {RUN: *(.+)$} $line match oneline suffix]} { |
Reid Spencer | 316abe4 | 2007-04-14 09:39:28 +0000 | [diff] [blame] | 170 | set runline "$runline$oneline" |
| 171 | set runline [ substitute $runline $test $tmpFile ] |
| 172 | set lines($numLines) $runline |
| 173 | set numLines [expr $numLines + 1] |
| 174 | set runline "" |
Reid Spencer | 90016c7 | 2007-04-14 19:37:22 +0000 | [diff] [blame] | 175 | |
| 176 | # if its an PR line, save the problem report number |
| 177 | } elseif {[regexp {PR([0-9]+)} $line match prnum]} { |
| 178 | if {$PRNUMS == ""} { |
Reid Spencer | 66959ce | 2007-04-15 10:27:54 +0000 | [diff] [blame] | 179 | set PRNUMS "PR$prnum" |
Reid Spencer | 90016c7 | 2007-04-14 19:37:22 +0000 | [diff] [blame] | 180 | } else { |
| 181 | set PRNUMS "$PRNUMS,$prnum" |
| 182 | } |
| 183 | # if its an XFAIL line, see if we should be XFAILing or not. |
Reid Spencer | 316abe4 | 2007-04-14 09:39:28 +0000 | [diff] [blame] | 184 | } elseif {[regexp {XFAIL:[ *](.+)} $line match targets]} { |
| 185 | set targets |
| 186 | |
| 187 | #split up target if more then 1 specified |
| 188 | foreach target [split $targets ,] { |
Nick Lewycky | 084f7bf | 2009-06-12 05:18:32 +0000 | [diff] [blame] | 189 | if { $target == "*" } { |
Tanya Lattner | a57506e | 2007-11-06 22:32:17 +0000 | [diff] [blame] | 190 | if {$targetPASS != 1} { |
| 191 | set outcome XFAIL |
| 192 | } |
Reid Spencer | 316abe4 | 2007-04-14 09:39:28 +0000 | [diff] [blame] | 193 | } elseif { [regexp $target $target_triplet match] } { |
Tanya Lattner | a57506e | 2007-11-06 22:32:17 +0000 | [diff] [blame] | 194 | if {$targetPASS != 1} { |
| 195 | set outcome XFAIL |
| 196 | } |
Tanya Lattner | a57506e | 2007-11-06 22:32:17 +0000 | [diff] [blame] | 197 | } |
| 198 | } |
| 199 | } elseif {[regexp {XTARGET:[ *](.+)} $line match targets]} { |
| 200 | set targets |
| 201 | |
| 202 | #split up target if more then 1 specified |
| 203 | foreach target [split $targets ,] { |
| 204 | if { [regexp {\*} $target match] } { |
| 205 | set targetPASS 1 |
| 206 | set outcome PASS |
| 207 | } elseif { [regexp $target $target_triplet match] } { |
| 208 | set targetPASS 1 |
| 209 | set outcome PASS |
Reid Spencer | 316abe4 | 2007-04-14 09:39:28 +0000 | [diff] [blame] | 210 | } |
| 211 | } |
| 212 | } |
| 213 | } |
Mikhail Glushenkov | 922b2a2 | 2009-03-06 12:21:40 +0000 | [diff] [blame] | 214 | |
Reid Spencer | 316abe4 | 2007-04-14 09:39:28 +0000 | [diff] [blame] | 215 | # Done reading the script |
| 216 | close $testFileId |
Mikhail Glushenkov | 922b2a2 | 2009-03-06 12:21:40 +0000 | [diff] [blame] | 217 | |
| 218 | |
Reid Spencer | 316abe4 | 2007-04-14 09:39:28 +0000 | [diff] [blame] | 219 | if { $numLines == 0 } { |
| 220 | fail "$test: \nDoes not have a RUN line\n" |
| 221 | } else { |
| 222 | set failed 0 |
| 223 | for { set i 0 } { $i < $numLines } { set i [ expr $i + 1 ] } { |
| 224 | regsub ^.*RUN:(.*) $lines($i) \1 theLine |
Reid Spencer | 90016c7 | 2007-04-14 19:37:22 +0000 | [diff] [blame] | 225 | set resultmsg [execOneLine $test $PRNUMS $outcome $i $theLine ] |
Reid Spencer | 316abe4 | 2007-04-14 09:39:28 +0000 | [diff] [blame] | 226 | if { $resultmsg != "" } { |
| 227 | if { $outcome == "XFAIL" } { |
| 228 | xfail "$resultmsg" |
| 229 | } else { |
| 230 | fail "$resultmsg" |
| 231 | } |
| 232 | set failed 1 |
| 233 | break |
| 234 | } |
| 235 | } |
Reid Spencer | 0947df4 | 2007-04-15 07:21:26 +0000 | [diff] [blame] | 236 | if { $failed } { |
Reid Spencer | b0feffa | 2007-04-15 07:34:58 +0000 | [diff] [blame] | 237 | continue |
Reid Spencer | 0947df4 | 2007-04-15 07:21:26 +0000 | [diff] [blame] | 238 | } else { |
| 239 | if { $PRNUMS != "" } { |
Reid Spencer | 90016c7 | 2007-04-14 19:37:22 +0000 | [diff] [blame] | 240 | set PRNUMS " for $PRNUMS" |
| 241 | } |
Reid Spencer | 316abe4 | 2007-04-14 09:39:28 +0000 | [diff] [blame] | 242 | if { $outcome == "XFAIL" } { |
Reid Spencer | 90016c7 | 2007-04-14 19:37:22 +0000 | [diff] [blame] | 243 | xpass "$test$PRNUMS" |
Reid Spencer | 316abe4 | 2007-04-14 09:39:28 +0000 | [diff] [blame] | 244 | } else { |
Reid Spencer | 90016c7 | 2007-04-14 19:37:22 +0000 | [diff] [blame] | 245 | pass "$test$PRNUMS" |
Reid Spencer | 316abe4 | 2007-04-14 09:39:28 +0000 | [diff] [blame] | 246 | } |
| 247 | } |
| 248 | } |
| 249 | } |
| 250 | } |
Devang Patel | 9fe9907 | 2007-04-20 21:24:01 +0000 | [diff] [blame] | 251 | |
Reid Spencer | 12d81f3 | 2007-04-21 21:45:51 +0000 | [diff] [blame] | 252 | # This procedure provides an interface to check the LLVMGCC_LANGS makefile |
| 253 | # variable to see if llvm-gcc supports compilation of a particular language. |
| 254 | proc llvm_gcc_supports { lang } { |
| 255 | global llvmgcc llvmgcc_langs |
| 256 | # validate the language choices and determine the name of the compiler |
| 257 | # component responsible for determining if the compiler has been built. |
| 258 | switch "$lang" { |
| 259 | ada { set file gnat1 } |
| 260 | c { set file cc1 } |
| 261 | c++ { set file cc1plus } |
Duncan Sands | c93346a | 2008-08-07 17:59:54 +0000 | [diff] [blame] | 262 | objc { set file cc1obj } |
Duncan Sands | 96f9452 | 2008-10-06 10:31:21 +0000 | [diff] [blame] | 263 | obj-c++ { set file cc1objplus } |
Duncan Sands | 3921266 | 2008-06-27 14:22:20 +0000 | [diff] [blame] | 264 | fortran { set file f951 } |
Reid Spencer | 12d81f3 | 2007-04-21 21:45:51 +0000 | [diff] [blame] | 265 | default { return 0 } |
| 266 | } |
Reid Spencer | 4f6e9ab | 2007-04-23 21:21:53 +0000 | [diff] [blame] | 267 | foreach supported_lang [split "$llvmgcc_langs" ,] { |
| 268 | if { "$lang" == "$supported_lang" } { |
| 269 | # FIXME: Knowing it is configured is not enough. We should do two more |
Mikhail Glushenkov | 922b2a2 | 2009-03-06 12:21:40 +0000 | [diff] [blame] | 270 | # checks here. First, we need to run llvm-gcc -print-prog-name=$file to |
Reid Spencer | 4f6e9ab | 2007-04-23 21:21:53 +0000 | [diff] [blame] | 271 | # get the path to the compiler. If we don't get a path, the language isn't |
Mikhail Glushenkov | 922b2a2 | 2009-03-06 12:21:40 +0000 | [diff] [blame] | 272 | # properly configured or built. If we do get a path, we should check to |
Reid Spencer | 4f6e9ab | 2007-04-23 21:21:53 +0000 | [diff] [blame] | 273 | # make sure that it is executable and perhaps even try executing it. |
| 274 | return 1; |
| 275 | } |
Reid Spencer | 12d81f3 | 2007-04-21 21:45:51 +0000 | [diff] [blame] | 276 | } |
| 277 | return 0; |
Duncan Sands | 4e9471d | 2007-04-21 20:20:47 +0000 | [diff] [blame] | 278 | } |
| 279 | |
Reid Spencer | 12d81f3 | 2007-04-21 21:45:51 +0000 | [diff] [blame] | 280 | # This procedure provides an interface to check the TARGETS_TO_BUILD makefile |
| 281 | # variable to see if a particular target has been configured to build. This |
| 282 | # helps avoid running tests for targets that aren't available. |
Reid Spencer | 40a4c61 | 2007-04-21 20:40:17 +0000 | [diff] [blame] | 283 | proc llvm_supports_target { tgtName } { |
| 284 | global TARGETS_TO_BUILD |
| 285 | foreach target [split $TARGETS_TO_BUILD] { |
| 286 | if { [regexp $tgtName $target match] } { |
| 287 | return 1 |
| 288 | } |
| 289 | } |
| 290 | return 0 |
| 291 | } |
Daniel Dunbar | 840a718 | 2009-09-13 01:41:18 +0000 | [diff] [blame] | 292 | |
Daniel Dunbar | 9e2556c | 2010-02-03 18:43:46 +0000 | [diff] [blame] | 293 | proc llvm_supports_darwin_and_target { tgtName } { |
| 294 | global target_triplet |
| 295 | if { [ llvm_supports_target $tgtName ] } { |
| 296 | if { [regexp darwin $target_triplet match] } { |
| 297 | return 1 |
| 298 | } |
| 299 | } |
| 300 | return 0 |
| 301 | } |
| 302 | |
Daniel Dunbar | 840a718 | 2009-09-13 01:41:18 +0000 | [diff] [blame] | 303 | # This procedure provides an interface to check the BINDINGS_TO_BUILD makefile |
| 304 | # variable to see if a particular binding has been configured to build. |
| 305 | proc llvm_supports_binding { name } { |
| 306 | global llvm_bindings |
| 307 | foreach item [split $llvm_bindings] { |
| 308 | if { [regexp $name $item match] } { |
| 309 | return 1 |
| 310 | } |
| 311 | } |
| 312 | return 0 |
| 313 | } |