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 } { |
Mikhail Glushenkov | 922b2a2 | 2009-03-06 12:21:40 +0000 | [diff] [blame] | 49 | global srcroot objroot srcdir objdir subdir target_triplet prcontext |
Gordon Henriksen | 8ef426b | 2007-09-18 12:49:39 +0000 | [diff] [blame] | 50 | global llvmgcc llvmgxx llvmgcc_version llvmgccmajvers ocamlc |
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 |
Reid Spencer | 316abe4 | 2007-04-14 09:39:28 +0000 | [diff] [blame] | 60 | #replace %prcontext with prcontext.tcl (Must replace before %p) |
| 61 | regsub -all {%prcontext} $new_line $prcontext new_line |
| 62 | #replace %llvmgcc with actual path to llvmgcc |
Duncan Sands | 53ebe35 | 2008-06-21 20:22:58 +0000 | [diff] [blame] | 63 | regsub -all {%llvmgcc} $new_line "$llvmgcc -emit-llvm -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 | 53ebe35 | 2008-06-21 20:22:58 +0000 | [diff] [blame] | 65 | regsub -all {%llvmgxx} $new_line "$llvmgxx -emit-llvm -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 |
Gordon Henriksen | 8ef426b | 2007-09-18 12:49:39 +0000 | [diff] [blame] | 74 | #replace %ocamlc with ocaml compiler command |
| 75 | regsub -all {%ocamlc} $new_line "$ocamlc" 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 |
Nuno Lopes | 2bdc07b | 2008-10-07 14:48:14 +0000 | [diff] [blame] | 88 | #replace _#MARKER#_ with % |
| 89 | regsub -all {_#MARKER#_} $new_line % new_line |
| 90 | |
Torok Edwin | 237033e | 2008-10-21 17:21:32 +0000 | [diff] [blame] | 91 | #replace grep with GNU grep |
| 92 | regsub -all { grep } $new_line " $grep " new_line |
| 93 | #replace as with GNU as |
| 94 | regsub -all {\| as } $new_line "| $gas " new_line |
| 95 | |
Nuno Lopes | 2bdc07b | 2008-10-07 14:48:14 +0000 | [diff] [blame] | 96 | #valgind related stuff |
| 97 | # regsub -all {bugpoint } $new_line "$valgrind bugpoint " new_line |
| 98 | regsub -all {llc } $new_line "$valgrind llc " new_line |
| 99 | regsub -all {lli } $new_line "$valgrind lli " new_line |
| 100 | regsub -all {llvm-ar } $new_line "$valgrind llvm-ar " new_line |
| 101 | regsub -all {llvm-as } $new_line "$valgrind llvm-as " new_line |
| 102 | regsub -all {llvm-bcanalyzer } $new_line "$valgrind llvm-bcanalyzer " new_line |
| 103 | regsub -all {llvm-dis } $new_line "$valgrind llvm-dis " new_line |
| 104 | regsub -all {llvm-extract } $new_line "$valgrind llvm-extract " new_line |
| 105 | regsub -all {llvm-ld } $new_line "$valgrind llvm-ld " new_line |
| 106 | regsub -all {llvm-link } $new_line "$valgrind llvm-link " new_line |
| 107 | regsub -all {llvm-nm } $new_line "$valgrind llvm-nm " new_line |
| 108 | regsub -all {llvm-prof } $new_line "$valgrind llvm-prof " new_line |
| 109 | regsub -all {llvm-ranlib } $new_line "$valgrind llvm-ranlib " new_line |
| 110 | regsub -all {([^a-zA-Z_-])opt } $new_line "\\1$valgrind opt " new_line |
| 111 | regsub -all {^opt } $new_line "$valgrind opt " new_line |
| 112 | regsub -all {tblgen } $new_line "$valgrind tblgen " new_line |
| 113 | regsub -all "not $valgrind " $new_line "$valgrind not " new_line |
| 114 | |
Reid Spencer | 316abe4 | 2007-04-14 09:39:28 +0000 | [diff] [blame] | 115 | return $new_line |
| 116 | } |
| 117 | |
Reid Spencer | 12d81f3 | 2007-04-21 21:45:51 +0000 | [diff] [blame] | 118 | # 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] | 119 | proc RunLLVMTests { test_source_files } { |
Reid Spencer | fb7653e | 2007-04-15 20:43:36 +0000 | [diff] [blame] | 120 | global srcroot objroot srcdir objdir subdir target_triplet llvmgcc_version |
Reid Spencer | 316abe4 | 2007-04-14 09:39:28 +0000 | [diff] [blame] | 121 | set timeout 60 |
| 122 | |
| 123 | set path [file join $objdir $subdir] |
Mikhail Glushenkov | 922b2a2 | 2009-03-06 12:21:40 +0000 | [diff] [blame] | 124 | |
Reid Spencer | 316abe4 | 2007-04-14 09:39:28 +0000 | [diff] [blame] | 125 | #Make Output Directory if it does not exist already |
| 126 | if { [file exists path] } { |
| 127 | cd $path |
| 128 | } else { |
| 129 | file mkdir $path |
| 130 | cd $path |
| 131 | } |
Mikhail Glushenkov | 922b2a2 | 2009-03-06 12:21:40 +0000 | [diff] [blame] | 132 | |
Reid Spencer | 316abe4 | 2007-04-14 09:39:28 +0000 | [diff] [blame] | 133 | file mkdir Output |
Duncan Sands | 6c7ada4 | 2007-07-23 15:23:35 +0000 | [diff] [blame] | 134 | cd Output |
Reid Spencer | 316abe4 | 2007-04-14 09:39:28 +0000 | [diff] [blame] | 135 | |
Reid Spencer | 78fb2ac | 2007-04-14 22:51:29 +0000 | [diff] [blame] | 136 | foreach test $test_source_files { |
Reid Spencer | 316abe4 | 2007-04-14 09:39:28 +0000 | [diff] [blame] | 137 | #Should figure out best way to set the timeout |
| 138 | #set timeout 40 |
Mikhail Glushenkov | 922b2a2 | 2009-03-06 12:21:40 +0000 | [diff] [blame] | 139 | |
Reid Spencer | 316abe4 | 2007-04-14 09:39:28 +0000 | [diff] [blame] | 140 | set filename [file tail $test] |
Gabor Greif | 684ed3d | 2008-02-26 12:08:55 +0000 | [diff] [blame] | 141 | verbose "ABOUT TO RUN: $filename" 2 |
Reid Spencer | 316abe4 | 2007-04-14 09:39:28 +0000 | [diff] [blame] | 142 | set outcome PASS |
| 143 | set tmpFile "$filename.tmp" |
Mikhail Glushenkov | 922b2a2 | 2009-03-06 12:21:40 +0000 | [diff] [blame] | 144 | |
Tanya Lattner | a57506e | 2007-11-06 22:32:17 +0000 | [diff] [blame] | 145 | # Mark that it should not be XFAIL for this target. |
| 146 | set targetPASS 0 |
Mikhail Glushenkov | 922b2a2 | 2009-03-06 12:21:40 +0000 | [diff] [blame] | 147 | |
Reid Spencer | 316abe4 | 2007-04-14 09:39:28 +0000 | [diff] [blame] | 148 | #set hasRunline bool to check if testcase has a runline |
| 149 | set numLines 0 |
| 150 | |
| 151 | # Open the test file and start reading lines |
| 152 | set testFileId [ open $test r] |
| 153 | set runline "" |
Reid Spencer | 90016c7 | 2007-04-14 19:37:22 +0000 | [diff] [blame] | 154 | set PRNUMS "" |
Reid Spencer | fb7653e | 2007-04-15 20:43:36 +0000 | [diff] [blame] | 155 | foreach line [split [read $testFileId] \n] { |
Reid Spencer | 316abe4 | 2007-04-14 09:39:28 +0000 | [diff] [blame] | 156 | |
Reid Spencer | 90016c7 | 2007-04-14 19:37:22 +0000 | [diff] [blame] | 157 | # if its the END. line then stop parsing (optimization for big files) |
Mikhail Glushenkov | 922b2a2 | 2009-03-06 12:21:40 +0000 | [diff] [blame] | 158 | if {[regexp {END.[[:space:]]*$} $line match endofscript]} { |
Reid Spencer | 316abe4 | 2007-04-14 09:39:28 +0000 | [diff] [blame] | 159 | break |
Reid Spencer | 90016c7 | 2007-04-14 19:37:22 +0000 | [diff] [blame] | 160 | |
Duncan Sands | 3724df3 | 2007-04-16 21:19:45 +0000 | [diff] [blame] | 161 | # if the line is continued, concatenate and continue the loop |
Reid Spencer | 601e845 | 2007-04-15 18:38:42 +0000 | [diff] [blame] | 162 | } elseif {[regexp {RUN: *(.+)(\\)$} $line match oneline suffix]} { |
Reid Spencer | 316abe4 | 2007-04-14 09:39:28 +0000 | [diff] [blame] | 163 | set runline "$runline$oneline " |
Reid Spencer | 90016c7 | 2007-04-14 19:37:22 +0000 | [diff] [blame] | 164 | |
| 165 | # 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] | 166 | # and then save the line. |
Tanya Lattner | 727842e | 2007-11-28 04:57:00 +0000 | [diff] [blame] | 167 | } elseif {[regexp {RUN: *(.+)$} $line match oneline suffix]} { |
Reid Spencer | 316abe4 | 2007-04-14 09:39:28 +0000 | [diff] [blame] | 168 | set runline "$runline$oneline" |
| 169 | set runline [ substitute $runline $test $tmpFile ] |
| 170 | set lines($numLines) $runline |
| 171 | set numLines [expr $numLines + 1] |
| 172 | set runline "" |
Reid Spencer | 90016c7 | 2007-04-14 19:37:22 +0000 | [diff] [blame] | 173 | |
| 174 | # if its an PR line, save the problem report number |
| 175 | } elseif {[regexp {PR([0-9]+)} $line match prnum]} { |
| 176 | if {$PRNUMS == ""} { |
Reid Spencer | 66959ce | 2007-04-15 10:27:54 +0000 | [diff] [blame] | 177 | set PRNUMS "PR$prnum" |
Reid Spencer | 90016c7 | 2007-04-14 19:37:22 +0000 | [diff] [blame] | 178 | } else { |
| 179 | set PRNUMS "$PRNUMS,$prnum" |
| 180 | } |
| 181 | # 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] | 182 | } elseif {[regexp {XFAIL:[ *](.+)} $line match targets]} { |
| 183 | set targets |
| 184 | |
| 185 | #split up target if more then 1 specified |
| 186 | foreach target [split $targets ,] { |
| 187 | if { [regexp {\*} $target match] } { |
Tanya Lattner | a57506e | 2007-11-06 22:32:17 +0000 | [diff] [blame] | 188 | if {$targetPASS != 1} { |
| 189 | set outcome XFAIL |
| 190 | } |
Reid Spencer | 316abe4 | 2007-04-14 09:39:28 +0000 | [diff] [blame] | 191 | } elseif { [regexp $target $target_triplet match] } { |
Tanya Lattner | a57506e | 2007-11-06 22:32:17 +0000 | [diff] [blame] | 192 | if {$targetPASS != 1} { |
| 193 | set outcome XFAIL |
| 194 | } |
Reid Spencer | 316abe4 | 2007-04-14 09:39:28 +0000 | [diff] [blame] | 195 | } elseif { [regexp {llvmgcc(([0-9]+)|([0-9]+[.][0-9]+))} $target match submatch submatch2] } { |
| 196 | if { [regexp ^($submatch)$|^(($submatch)(\.)) $llvmgcc_version match] } { |
Tanya Lattner | a57506e | 2007-11-06 22:32:17 +0000 | [diff] [blame] | 197 | if {$targetPASS != 1} { |
| 198 | set outcome XFAIL |
| 199 | } |
| 200 | } |
| 201 | } |
| 202 | } |
| 203 | } elseif {[regexp {XTARGET:[ *](.+)} $line match targets]} { |
| 204 | set targets |
| 205 | |
| 206 | #split up target if more then 1 specified |
| 207 | foreach target [split $targets ,] { |
| 208 | if { [regexp {\*} $target match] } { |
| 209 | set targetPASS 1 |
| 210 | set outcome PASS |
| 211 | } elseif { [regexp $target $target_triplet match] } { |
| 212 | set targetPASS 1 |
| 213 | set outcome PASS |
| 214 | } elseif { [regexp {llvmgcc(([0-9]+)|([0-9]+[.][0-9]+))} $target match submatch submatch2] } { |
| 215 | if { [regexp ^($submatch)$|^(($submatch)(\.)) $llvmgcc_version match] } { |
| 216 | set targetPASS 1 |
| 217 | set outcome PASS |
Reid Spencer | 316abe4 | 2007-04-14 09:39:28 +0000 | [diff] [blame] | 218 | } |
| 219 | } |
| 220 | } |
| 221 | } |
| 222 | } |
Mikhail Glushenkov | 922b2a2 | 2009-03-06 12:21:40 +0000 | [diff] [blame] | 223 | |
Reid Spencer | 316abe4 | 2007-04-14 09:39:28 +0000 | [diff] [blame] | 224 | # Done reading the script |
| 225 | close $testFileId |
Mikhail Glushenkov | 922b2a2 | 2009-03-06 12:21:40 +0000 | [diff] [blame] | 226 | |
| 227 | |
Reid Spencer | 316abe4 | 2007-04-14 09:39:28 +0000 | [diff] [blame] | 228 | if { $numLines == 0 } { |
| 229 | fail "$test: \nDoes not have a RUN line\n" |
| 230 | } else { |
| 231 | set failed 0 |
| 232 | for { set i 0 } { $i < $numLines } { set i [ expr $i + 1 ] } { |
| 233 | regsub ^.*RUN:(.*) $lines($i) \1 theLine |
Reid Spencer | 90016c7 | 2007-04-14 19:37:22 +0000 | [diff] [blame] | 234 | set resultmsg [execOneLine $test $PRNUMS $outcome $i $theLine ] |
Reid Spencer | 316abe4 | 2007-04-14 09:39:28 +0000 | [diff] [blame] | 235 | if { $resultmsg != "" } { |
| 236 | if { $outcome == "XFAIL" } { |
| 237 | xfail "$resultmsg" |
| 238 | } else { |
| 239 | fail "$resultmsg" |
| 240 | } |
| 241 | set failed 1 |
| 242 | break |
| 243 | } |
| 244 | } |
Reid Spencer | 0947df4 | 2007-04-15 07:21:26 +0000 | [diff] [blame] | 245 | if { $failed } { |
Reid Spencer | b0feffa | 2007-04-15 07:34:58 +0000 | [diff] [blame] | 246 | continue |
Reid Spencer | 0947df4 | 2007-04-15 07:21:26 +0000 | [diff] [blame] | 247 | } else { |
| 248 | if { $PRNUMS != "" } { |
Reid Spencer | 90016c7 | 2007-04-14 19:37:22 +0000 | [diff] [blame] | 249 | set PRNUMS " for $PRNUMS" |
| 250 | } |
Reid Spencer | 316abe4 | 2007-04-14 09:39:28 +0000 | [diff] [blame] | 251 | if { $outcome == "XFAIL" } { |
Reid Spencer | 90016c7 | 2007-04-14 19:37:22 +0000 | [diff] [blame] | 252 | xpass "$test$PRNUMS" |
Reid Spencer | 316abe4 | 2007-04-14 09:39:28 +0000 | [diff] [blame] | 253 | } else { |
Reid Spencer | 90016c7 | 2007-04-14 19:37:22 +0000 | [diff] [blame] | 254 | pass "$test$PRNUMS" |
Reid Spencer | 316abe4 | 2007-04-14 09:39:28 +0000 | [diff] [blame] | 255 | } |
| 256 | } |
| 257 | } |
| 258 | } |
| 259 | } |
Devang Patel | 9fe9907 | 2007-04-20 21:24:01 +0000 | [diff] [blame] | 260 | |
Reid Spencer | 12d81f3 | 2007-04-21 21:45:51 +0000 | [diff] [blame] | 261 | # This procedure provides an interface to check the LLVMGCC_LANGS makefile |
| 262 | # variable to see if llvm-gcc supports compilation of a particular language. |
| 263 | proc llvm_gcc_supports { lang } { |
| 264 | global llvmgcc llvmgcc_langs |
| 265 | # validate the language choices and determine the name of the compiler |
| 266 | # component responsible for determining if the compiler has been built. |
| 267 | switch "$lang" { |
| 268 | ada { set file gnat1 } |
| 269 | c { set file cc1 } |
| 270 | c++ { set file cc1plus } |
Duncan Sands | c93346a | 2008-08-07 17:59:54 +0000 | [diff] [blame] | 271 | objc { set file cc1obj } |
Duncan Sands | 96f9452 | 2008-10-06 10:31:21 +0000 | [diff] [blame] | 272 | obj-c++ { set file cc1objplus } |
Duncan Sands | 3921266 | 2008-06-27 14:22:20 +0000 | [diff] [blame] | 273 | fortran { set file f951 } |
Reid Spencer | 12d81f3 | 2007-04-21 21:45:51 +0000 | [diff] [blame] | 274 | default { return 0 } |
| 275 | } |
Reid Spencer | 4f6e9ab | 2007-04-23 21:21:53 +0000 | [diff] [blame] | 276 | foreach supported_lang [split "$llvmgcc_langs" ,] { |
| 277 | if { "$lang" == "$supported_lang" } { |
| 278 | # 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] | 279 | # 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] | 280 | # 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] | 281 | # 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] | 282 | # make sure that it is executable and perhaps even try executing it. |
| 283 | return 1; |
| 284 | } |
Reid Spencer | 12d81f3 | 2007-04-21 21:45:51 +0000 | [diff] [blame] | 285 | } |
| 286 | return 0; |
Duncan Sands | 4e9471d | 2007-04-21 20:20:47 +0000 | [diff] [blame] | 287 | } |
| 288 | |
Reid Spencer | 12d81f3 | 2007-04-21 21:45:51 +0000 | [diff] [blame] | 289 | # This procedure provides an interface to check the TARGETS_TO_BUILD makefile |
| 290 | # variable to see if a particular target has been configured to build. This |
| 291 | # helps avoid running tests for targets that aren't available. |
Reid Spencer | 40a4c61 | 2007-04-21 20:40:17 +0000 | [diff] [blame] | 292 | proc llvm_supports_target { tgtName } { |
| 293 | global TARGETS_TO_BUILD |
| 294 | foreach target [split $TARGETS_TO_BUILD] { |
| 295 | if { [regexp $tgtName $target match] } { |
| 296 | return 1 |
| 297 | } |
| 298 | } |
| 299 | return 0 |
| 300 | } |