Skip to content

Commit 16b0f4c

Browse files
QuLogicaykevl
authored andcommitted
builder: Fix parsing of external ld.lld error messages
If `ld.lld` is a version-specific binary (e.g., `ld.lld-18`), then its error messages include the version. The parsing previously incorrectly assumed it would be unversioned.
1 parent ff15b47 commit 16b0f4c

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

builder/tools.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,8 @@ func parseLLDErrors(text string) error {
114114

115115
// Check for undefined symbols.
116116
// This can happen in some cases like with CGo and //go:linkname tricker.
117-
if matches := regexp.MustCompile(`^ld.lld: error: undefined symbol: (.*)\n`).FindStringSubmatch(message); matches != nil {
118-
symbolName := matches[1]
117+
if matches := regexp.MustCompile(`^ld.lld(-[0-9]+)?: error: undefined symbol: (.*)\n`).FindStringSubmatch(message); matches != nil {
118+
symbolName := matches[2]
119119
for _, line := range strings.Split(message, "\n") {
120120
matches := regexp.MustCompile(`referenced by .* \(((.*):([0-9]+))\)`).FindStringSubmatch(line)
121121
if matches != nil {
@@ -134,9 +134,9 @@ func parseLLDErrors(text string) error {
134134
}
135135

136136
// Check for flash/RAM overflow.
137-
if matches := regexp.MustCompile(`^ld.lld: error: section '(.*?)' will not fit in region '(.*?)': overflowed by ([0-9]+) bytes$`).FindStringSubmatch(message); matches != nil {
138-
region := matches[2]
139-
n, err := strconv.ParseUint(matches[3], 10, 64)
137+
if matches := regexp.MustCompile(`^ld.lld(-[0-9]+)?: error: section '(.*?)' will not fit in region '(.*?)': overflowed by ([0-9]+) bytes$`).FindStringSubmatch(message); matches != nil {
138+
region := matches[3]
139+
n, err := strconv.ParseUint(matches[4], 10, 64)
140140
if err != nil {
141141
// Should not happen at all (unless it overflows an uint64 for some reason).
142142
continue

0 commit comments

Comments
 (0)