mirror of
https://github.com/golang/go
synced 2024-11-18 19:44:46 -07:00
cmd/go: clean cgo compiler errors
Cut out temporary cgo file in error message. Show C.foo instead of _Ctype_foo. Before: x.go:20[/var/folders/00/05_b8000h01000cxqpysvccm000n9d/T/go-build242036121/command-line-arguments/_obj/x.cgo1.go:19]: cannot use tv.Usec (type int32) as type _Ctype___darwin_suseconds_t in assignment After: x.go:20: cannot use tv.Usec (type int32) as type C.__darwin_suseconds_t in assignment Fixes #4255. R=golang-dev, iant CC=golang-dev https://golang.org/cl/7231075
This commit is contained in:
parent
f20e3a1065
commit
32a6097fde
@ -814,11 +814,11 @@ func (b *builder) build(a *action) (err error) {
|
|||||||
|
|
||||||
// Compile Go.
|
// Compile Go.
|
||||||
if len(gofiles) > 0 {
|
if len(gofiles) > 0 {
|
||||||
if out, err := buildToolchain.gc(b, a.p, obj, inc, gofiles); err != nil {
|
out, err := buildToolchain.gc(b, a.p, obj, inc, gofiles)
|
||||||
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
} else {
|
|
||||||
objects = append(objects, out)
|
|
||||||
}
|
}
|
||||||
|
objects = append(objects, out)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Copy .h files named for goos or goarch or goos_goarch
|
// Copy .h files named for goos or goarch or goos_goarch
|
||||||
@ -1177,6 +1177,8 @@ func relPaths(paths []string) []string {
|
|||||||
// print this error.
|
// print this error.
|
||||||
var errPrintedOutput = errors.New("already printed output - no need to show error")
|
var errPrintedOutput = errors.New("already printed output - no need to show error")
|
||||||
|
|
||||||
|
var cgoLine = regexp.MustCompile(`\[[^\[\]]+\.cgo1\.go:[0-9]+\]`)
|
||||||
|
|
||||||
// run runs the command given by cmdline in the directory dir.
|
// run runs the command given by cmdline in the directory dir.
|
||||||
// If the command fails, run prints information about the failure
|
// If the command fails, run prints information about the failure
|
||||||
// and returns a non-nil error.
|
// and returns a non-nil error.
|
||||||
@ -1189,7 +1191,16 @@ func (b *builder) run(dir string, desc string, cmdargs ...interface{}) error {
|
|||||||
if desc == "" {
|
if desc == "" {
|
||||||
desc = b.fmtcmd(dir, "%s", strings.Join(stringList(cmdargs...), " "))
|
desc = b.fmtcmd(dir, "%s", strings.Join(stringList(cmdargs...), " "))
|
||||||
}
|
}
|
||||||
b.showOutput(dir, desc, string(out))
|
out := string(out)
|
||||||
|
// Fix up output referring to cgo-generated code to be more readable.
|
||||||
|
// Replace x.go:19[/tmp/.../x.cgo1.go:18] with x.go:19.
|
||||||
|
// Replace _Ctype_foo with C.foo.
|
||||||
|
// If we're using -x, assume we're debugging and want the full dump, so disable the rewrite.
|
||||||
|
if !buildX && cgoLine.MatchString(out) {
|
||||||
|
out = cgoLine.ReplaceAllString(out, "")
|
||||||
|
out = strings.Replace(out, "type _Ctype_", "type C.", -1)
|
||||||
|
}
|
||||||
|
b.showOutput(dir, desc, out)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
err = errPrintedOutput
|
err = errPrintedOutput
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user