-
Notifications
You must be signed in to change notification settings - Fork 17.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cmd/cgo: -godefs doesn't work with structures fields inside another structure. #26644
Labels
Comments
Pretty sure https://golang.org/cl/125995 fixes this. |
Change https://golang.org/cl/125995 mentions this issue: |
Change https://golang.org/cl/128395 mentions this issue: |
gopherbot
pushed a commit
that referenced
this issue
Aug 8, 2018
In -godefs mode any typedefs that appear in struct fields and the like will presumably be defined in the input file. If we resolve to the base type, those cross-references will not work. So for -godefs mode, keep the Go 1.10 behavior and don't resolve the typedefs in a loop. Fixes #26644 Change-Id: I48cf72d9eb5016353c43074e6aff6495af326f35 Reviewed-on: https://go-review.googlesource.com/125995 Reviewed-by: Keith Randall <khr@golang.org> (cherry picked from commit ead59f4) Reviewed-on: https://go-review.googlesource.com/128395 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Please answer these questions before submitting your issue. Thanks!
What version of Go are you using (
go version
)?go version devel +c814ac4 Thu Jul 19 21:30:27 2018 +0000 linux/amd64
-> go1.11beta2
Does this issue reproduce with the latest release?
No, it wasn't the case in go1.11beta1
What operating system and processor architecture are you using (
go env
)?GOARCH="amd64"
GOBIN=""
GOCACHE="/home/chigotc/.cache/go-build"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/chigotc/go"
GOPROXY=""
GORACE=""
GOROOT="/home/chigotc/go/golangMaster"
GOTMPDIR=""
GOTOOLDIR="/home/chigotc/go/golangMaster/pkg/tool/linux_amd64"
GCCGO="/usr/bin/gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build447974166=/tmp/go-build -gno-record-gcc-switches"
What did you do?
I uses go tool cgo -godefs godefs.go with godefs.go :
package godefs
/*
typedef struct st_timespec {
int tv_sec;
int tv_nsec;
} st_timespec_t;
struct stat {
int var1;
st_timespec_t atim;
int var2;
};
*/
import "C"
type Stat_t C.struct_stat
type StTimespec_t C.st_timespec_t
What did you expect to see?
// Code generated by cmd/cgo -godefs; DO NOT EDIT.
// cgo -godefs godefs.go
package godefs
type Stat_t struct {
Var1 int32
Atim StTimespec_t
Var2 int32
}
type StTimespec_t struct {
Sec int32
Nsec int32
}
What did you see instead?
// Code generated by cmd/cgo -godefs; DO NOT EDIT.
// cgo -godefs godefs.go
package godefs
type Stat_t struct {
Var1 int32
Atim _Ctype_struct_st_timespec
Var2 int32
}
type StTimespec_t struct {
Sec int32
Nsec int32
}
If the new feature "recordTypedefs" is removed, everything is alright:
Commenting this line: https://github.com/golang/go/blob/master/src/cmd/cgo/gcc.go#L567, is enough to bypass this bug.
The text was updated successfully, but these errors were encountered: