mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-10 14:03:39 +00:00
main: switch to LLVM 10
This commit also adds a bit of version independence, in particular for external commands. It also adds the LLVM version to the `tinygo version` command, which might help while debugging.
This commit is contained in:
committed by
Ron Evans
parent
584e94ce2f
commit
0afd42c439
@@ -6,6 +6,8 @@ import (
|
||||
"flag"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
@@ -82,6 +84,12 @@ func fuzzyEqualIR(s1, s2 string) bool {
|
||||
// stripped out.
|
||||
func filterIrrelevantIRLines(lines []string) []string {
|
||||
var out []string
|
||||
llvmVersion, err := strconv.Atoi(strings.Split(llvm.Version, ".")[0])
|
||||
if err != nil {
|
||||
// Note: this should never happen and if it does, it will always happen
|
||||
// for a particular build because llvm.Version is a constant.
|
||||
panic(err)
|
||||
}
|
||||
for _, line := range lines {
|
||||
line = strings.Split(line, ";")[0] // strip out comments/info
|
||||
line = strings.TrimRight(line, "\r ") // drop '\r' on Windows and remove trailing spaces from comments
|
||||
@@ -91,6 +99,19 @@ func filterIrrelevantIRLines(lines []string) []string {
|
||||
if strings.HasPrefix(line, "source_filename = ") {
|
||||
continue
|
||||
}
|
||||
if llvmVersion < 10 && strings.HasPrefix(line, "attributes ") {
|
||||
// Ignore attribute groups. These may change between LLVM versions.
|
||||
// Right now test outputs are for LLVM 10.
|
||||
continue
|
||||
}
|
||||
if llvmVersion < 10 && strings.HasPrefix(line, "define ") {
|
||||
// Remove parameter values such as %0 in function definitions. These
|
||||
// were added in LLVM 10 so to get the tests to pass on older
|
||||
// versions, ignore them there (there are other tests that verify
|
||||
// correct behavior).
|
||||
re := regexp.MustCompile(` %[0-9]+(\)|,)`)
|
||||
line = re.ReplaceAllString(line, "$1")
|
||||
}
|
||||
out = append(out, line)
|
||||
}
|
||||
return out
|
||||
|
||||
Reference in New Issue
Block a user