aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/noder/reader.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/cmd/compile/internal/noder/reader.go')
-rw-r--r--src/cmd/compile/internal/noder/reader.go12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/cmd/compile/internal/noder/reader.go b/src/cmd/compile/internal/noder/reader.go
index d03da27a46..bd15729171 100644
--- a/src/cmd/compile/internal/noder/reader.go
+++ b/src/cmd/compile/internal/noder/reader.go
@@ -9,6 +9,7 @@ import (
"go/constant"
"internal/buildcfg"
"internal/pkgbits"
+ "path/filepath"
"strings"
"cmd/compile/internal/base"
@@ -268,13 +269,14 @@ func (pr *pkgReader) posBaseIdx(idx pkgbits.Index) *src.PosBase {
// "$GOROOT" to buildcfg.GOROOT is a close-enough approximation to
// satisfy this.
//
- // TODO(mdempsky): De-duplicate this logic with similar logic in
- // cmd/link/internal/ld's expandGoroot. However, this will probably
- // require being more consistent about when we use native vs UNIX
- // file paths.
+ // The export data format only ever uses slash paths
+ // (for cross-operating-system reproducible builds),
+ // but error messages need to use native paths (backslash on Windows)
+ // as if they had been specified on the command line.
+ // (The go command always passes native paths to the compiler.)
const dollarGOROOT = "$GOROOT"
if buildcfg.GOROOT != "" && strings.HasPrefix(filename, dollarGOROOT) {
- filename = buildcfg.GOROOT + filename[len(dollarGOROOT):]
+ filename = filepath.FromSlash(buildcfg.GOROOT + filename[len(dollarGOROOT):])
}
if r.Bool() {