diff options
author | Matthew Dempsky <mdempsky@google.com> | 2017-11-29 11:58:03 -0800 |
---|---|---|
committer | Ian Lance Taylor <iant@golang.org> | 2018-06-13 17:13:05 +0000 |
commit | 1746cff738c7c801988f18cd25ca0cb488889873 (patch) | |
tree | c2e2d1d8f8bd62f808cb00b500011a69837cbd48 | |
parent | 7df09b4a03f9e53334672674ba7983d5e7128646 (diff) | |
download | go-1746cff738c7c801988f18cd25ca0cb488889873.tar.gz go-1746cff738c7c801988f18cd25ca0cb488889873.zip |
[release-branch.go1.9] cmd/compile: make -asmhdr work with type aliases
For "type T = U" we were accidentally emitting a #define for "U__size"
instead of "T__size".
Updates #22877.
Fixes #25561.
Change-Id: I5ed6757d697753ed6d944077c16150759f6e1285
Reviewed-on: https://go-review.googlesource.com/80759
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
(cherry picked from commit 2f588ff08f0330864b2e8d16e850c51642d9c5ca)
Reviewed-on: https://go-review.googlesource.com/118475
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Andrew Bonventre <andybons@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
-rw-r--r-- | src/cmd/compile/internal/gc/export.go | 8 | ||||
-rw-r--r-- | test/fixedbugs/issue22877.dir/p.go | 14 | ||||
-rw-r--r-- | test/fixedbugs/issue22877.dir/p.s | 8 | ||||
-rw-r--r-- | test/fixedbugs/issue22877.go | 7 | ||||
-rw-r--r-- | test/run.go | 3 |
5 files changed, 36 insertions, 4 deletions
diff --git a/src/cmd/compile/internal/gc/export.go b/src/cmd/compile/internal/gc/export.go index a92a41c5ce..1dc02a8d71 100644 --- a/src/cmd/compile/internal/gc/export.go +++ b/src/cmd/compile/internal/gc/export.go @@ -386,10 +386,10 @@ func dumpasmhdr() { if !t.IsStruct() || t.StructType().Map != nil || t.IsFuncArgStruct() { break } - fmt.Fprintf(b, "#define %s__size %d\n", t.Sym.Name, int(t.Width)) - for _, t := range t.Fields().Slice() { - if !t.Sym.IsBlank() { - fmt.Fprintf(b, "#define %s_%s %d\n", n.Sym.Name, t.Sym.Name, int(t.Offset)) + fmt.Fprintf(b, "#define %s__size %d\n", n.Sym.Name, int(t.Width)) + for _, f := range t.Fields().Slice() { + if !f.Sym.IsBlank() { + fmt.Fprintf(b, "#define %s_%s %d\n", n.Sym.Name, f.Sym.Name, int(f.Offset)) } } } diff --git a/test/fixedbugs/issue22877.dir/p.go b/test/fixedbugs/issue22877.dir/p.go new file mode 100644 index 0000000000..fc86cb9e1e --- /dev/null +++ b/test/fixedbugs/issue22877.dir/p.go @@ -0,0 +1,14 @@ +// Copyright 2017 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package main + +type S struct{ i int } +type SS = S + +func sub() + +func main() { + sub() +} diff --git a/test/fixedbugs/issue22877.dir/p.s b/test/fixedbugs/issue22877.dir/p.s new file mode 100644 index 0000000000..8b14358cdc --- /dev/null +++ b/test/fixedbugs/issue22877.dir/p.s @@ -0,0 +1,8 @@ +// Copyright 2017 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +#include "go_asm.h" + +TEXT ·sub(SB), 0, $0 + RET diff --git a/test/fixedbugs/issue22877.go b/test/fixedbugs/issue22877.go new file mode 100644 index 0000000000..284b6807eb --- /dev/null +++ b/test/fixedbugs/issue22877.go @@ -0,0 +1,7 @@ +// builddir + +// Copyright 2017 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package ignored diff --git a/test/run.go b/test/run.go index 2fa206746b..e3cb684e55 100644 --- a/test/run.go +++ b/test/run.go @@ -728,6 +728,9 @@ func (t *test) run() { } var objs []string cmd := []string{"go", "tool", "compile", "-e", "-D", ".", "-I", ".", "-o", "go.o"} + if len(asms) > 0 { + cmd = append(cmd, "-asmhdr", "go_asm.h") + } for _, file := range gos { cmd = append(cmd, filepath.Join(longdir, file.Name())) } |