Description
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.