Skip to content

Commit b76ea29

Browse files
aykevldeadprogram
authored andcommitted
builder: work around bug in DWARF paths in Clang
See bug: llvm/llvm-project#117317
1 parent 9172cc1 commit b76ea29

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

builder/sizes.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
"os"
1313
"path/filepath"
1414
"regexp"
15+
"runtime"
1516
"sort"
1617
"strings"
1718

@@ -194,11 +195,17 @@ func readProgramSizeFromDWARF(data *dwarf.Data, codeOffset, codeAlignment uint64
194195
if !prevLineEntry.EndSequence {
195196
// The chunk describes the code from prevLineEntry to
196197
// lineEntry.
198+
path := prevLineEntry.File.Name
199+
if runtime.GOOS == "windows" {
200+
// Work around a Clang bug on Windows:
201+
// https://github.com/llvm/llvm-project/issues/117317
202+
path = strings.ReplaceAll(path, "\\\\", "\\")
203+
}
197204
line := addressLine{
198205
Address: prevLineEntry.Address + codeOffset,
199206
Length: lineEntry.Address - prevLineEntry.Address,
200207
Align: codeAlignment,
201-
File: prevLineEntry.File.Name,
208+
File: path,
202209
}
203210
if line.Length != 0 {
204211
addresses = append(addresses, line)

0 commit comments

Comments
 (0)