Skip to content

Missing struct fields when using CGO on macOS #35640

@t0rr3sp3dr0

Description

@t0rr3sp3dr0

When importing MIT Kerberos krb5.h on macOS some struct fields are not defined, while on Linux the same header causes the structs to have these fields as expected. This behavior can be replicated by trying to use github.com/zephyr-im/krb5-go library on macOS Catalina 10.15 (19A603).

What version of Go are you using (go version)?

$ go version
go version go1.13.4 darwin/amd64

Does this issue reproduce with the latest release?

Yes

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/pedro/Library/Caches/go-build"
GOENV="/Users/pedro/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/pedro/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/Cellar/go/1.13.4/libexec"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.13.4/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD=""
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 -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/h8/24ggm1b922xdhz91lg7krpqh0000gn/T/go-build346701707=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

go test github.com/zephyr-im/krb5-go

What did you expect to see?

# github.com/zephyr-im/krb5-go
../go/src/github.com/zephyr-im/krb5-go/krb5.go:241:58: princ.data undefined (type _Ctype_krb5_principal has no field or method data)
../go/src/github.com/zephyr-im/krb5-go/krb5.go:248:33: princ.realm undefined (type _Ctype_krb5_principal has no field or method realm)
../go/src/github.com/zephyr-im/krb5-go/krb5.go:269:3: unknown field 'realm' in struct literal of type _Ctype_struct_krb5_principal_data
../go/src/github.com/zephyr-im/krb5-go/krb5.go:270:3: unknown field 'data' in struct literal of type _Ctype_struct_krb5_principal_data
../go/src/github.com/zephyr-im/krb5-go/krb5.go:276:17: p.realm undefined (type *_Ctype_struct_krb5_principal_data has no field or method realm)
../go/src/github.com/zephyr-im/krb5-go/krb5.go:277:54: p.data undefined (type *_Ctype_struct_krb5_principal_data has no field or method data)
../go/src/github.com/zephyr-im/krb5-go/krb5.go:332:43: cksum.contents undefined (type *_Ctype_struct__krb5_checksum has no field or method contents)
../go/src/github.com/zephyr-im/krb5-go/krb5.go:339:3: unknown field 'contents' in struct literal of type _Ctype_struct__krb5_checksum
../go/src/github.com/zephyr-im/krb5-go/krb5.go:352:39: k.contents undefined (type *_Ctype_struct__krb5_keyblock has no field or method contents)
../go/src/github.com/zephyr-im/krb5-go/krb5.go:359:3: unknown field 'contents' in struct literal of type _Ctype_struct__krb5_keyblock
../go/src/github.com/zephyr-im/krb5-go/krb5.go:359:3: too many errors
FAIL	github.com/zephyr-im/krb5-go [build failed]
FAIL

What did you see instead?

ok  	github.com/zephyr-im/krb5-go	0.009s

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions