-
Notifications
You must be signed in to change notification settings - Fork 17.8k
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
go/internal/srcimporter: TestImportStdLib failing on NetBSD #38649
Comments
Based on the build dashboard, this appears to have been broken by https://golang.org/cl/33677. |
Thanks for the heads up. I don't immediately see why that wouldn't work. If someone can run |
On NetBSD, #ifndef gid_t
typedef __gid_t gid_t; /* group id */
#define gid_t __gid_t
#endif The type Because of the macro definition in |
@ianlancetaylor I see. That's frustrating. Does cgo emit any information about preprocessor macros that go/types can make use of? Could cgo emit a type alias for |
_cgo_gotypes.go on amd64 NetBSD 9.0: //go:cgo_ldflag "-g"
//go:cgo_ldflag "-O2"
// Code generated by cmd/cgo; DO NOT EDIT.
package user
import "unsafe"
import _ "runtime/cgo"
import "syscall"
var _ syscall.Errno
func _Cgo_ptr(ptr unsafe.Pointer) unsafe.Pointer { return ptr }
//go:linkname _Cgo_always_false runtime.cgoAlwaysFalse
var _Cgo_always_false bool
//go:linkname _Cgo_use runtime.cgoUse
func _Cgo_use(interface{})
type _Ctype___gid_t = _Ctype___uint32_t
type _Ctype___int64_t = _Ctype_long
type _Ctype___uid_t = _Ctype___uint32_t
type _Ctype___uint32_t = _Ctype_uint
type _Ctype_char int8
type _Ctype_int int32
type _Ctype_intgo = _Ctype_ptrdiff_t
type _Ctype_long int64
type _Ctype_ptrdiff_t = _Ctype_long
type _Ctype_size_t = _Ctype_ulong
type _Ctype_struct_group struct {
gr_name *_Ctype_char
gr_passwd *_Ctype_char
gr_gid _Ctype___gid_t
gr_mem **_Ctype_char
}
type _Ctype_struct_passwd struct {
pw_name *_Ctype_char
pw_passwd *_Ctype_char
pw_uid _Ctype___uid_t
pw_gid _Ctype___gid_t
pw_change _Ctype_time_t
pw_class *_Ctype_char
pw_gecos *_Ctype_char
pw_dir *_Ctype_char
pw_shell *_Ctype_char
pw_expire _Ctype_time_t
}
type _Ctype_time_t = _Ctype___int64_t
type _Ctype_uint uint32
type _Ctype_ulong uint64
type _Ctype_void [0]byte
//go:linkname _cgo_runtime_cgocall runtime.cgocall
func _cgo_runtime_cgocall(unsafe.Pointer, uintptr) int32
//go:linkname _cgo_runtime_cgocallback runtime.cgocallback
func _cgo_runtime_cgocallback(unsafe.Pointer, unsafe.Pointer, uintptr, uintptr)
//go:linkname _cgoCheckPointer runtime.cgoCheckPointer
func _cgoCheckPointer(interface{}, interface{})
//go:linkname _cgoCheckResult runtime.cgoCheckResult
func _cgoCheckResult(interface{})
const _Ciconst__SC_GETGR_R_SIZE_MAX = 0x2f
const _Ciconst__SC_GETPW_R_SIZE_MAX = 0x30
//go:linkname _cgo_runtime_gostring runtime.gostring
func _cgo_runtime_gostring(*_Ctype_char) string
func _Cfunc_GoString(p *_Ctype_char) string {
return _cgo_runtime_gostring(p)
}
func _Cfunc__CMalloc(n _Ctype_size_t) unsafe.Pointer {
return _cgo_cmalloc(uint64(n))
}
//go:cgo_import_static _cgo_bbce630bddcc_Cfunc_free
//go:linkname __cgofn__cgo_bbce630bddcc_Cfunc_free _cgo_bbce630bddcc_Cfunc_free
var __cgofn__cgo_bbce630bddcc_Cfunc_free byte
var _cgo_bbce630bddcc_Cfunc_free = unsafe.Pointer(&__cgofn__cgo_bbce630bddcc_Cfunc_free)
//go:cgo_unsafe_args
func _Cfunc_free(p0 unsafe.Pointer) (r1 _Ctype_void) {
_cgo_runtime_cgocall(_cgo_bbce630bddcc_Cfunc_free, uintptr(unsafe.Pointer(&p0)))
if _Cgo_always_false {
_Cgo_use(p0)
}
return
}
//go:cgo_import_static _cgo_bbce630bddcc_Cfunc_mygetgrgid_r
//go:linkname __cgofn__cgo_bbce630bddcc_Cfunc_mygetgrgid_r _cgo_bbce630bddcc_Cfunc_mygetgrgid_r
var __cgofn__cgo_bbce630bddcc_Cfunc_mygetgrgid_r byte
var _cgo_bbce630bddcc_Cfunc_mygetgrgid_r = unsafe.Pointer(&__cgofn__cgo_bbce630bddcc_Cfunc_mygetgrgid_r)
//go:cgo_unsafe_args
func _Cfunc_mygetgrgid_r(p0 _Ctype_int, p1 *_Ctype_struct_group, p2 *_Ctype_char, p3 _Ctype_size_t, p4 **_Ctype_struct_group) (r1 _Ctype_int) {
_cgo_runtime_cgocall(_cgo_bbce630bddcc_Cfunc_mygetgrgid_r, uintptr(unsafe.Pointer(&p0)))
if _Cgo_always_false {
_Cgo_use(p0)
_Cgo_use(p1)
_Cgo_use(p2)
_Cgo_use(p3)
_Cgo_use(p4)
}
return
}
//go:cgo_import_static _cgo_bbce630bddcc_Cfunc_mygetgrnam_r
//go:linkname __cgofn__cgo_bbce630bddcc_Cfunc_mygetgrnam_r _cgo_bbce630bddcc_Cfunc_mygetgrnam_r
var __cgofn__cgo_bbce630bddcc_Cfunc_mygetgrnam_r byte
var _cgo_bbce630bddcc_Cfunc_mygetgrnam_r = unsafe.Pointer(&__cgofn__cgo_bbce630bddcc_Cfunc_mygetgrnam_r)
//go:cgo_unsafe_args
func _Cfunc_mygetgrnam_r(p0 *_Ctype_char, p1 *_Ctype_struct_group, p2 *_Ctype_char, p3 _Ctype_size_t, p4 **_Ctype_struct_group) (r1 _Ctype_int) {
_cgo_runtime_cgocall(_cgo_bbce630bddcc_Cfunc_mygetgrnam_r, uintptr(unsafe.Pointer(&p0)))
if _Cgo_always_false {
_Cgo_use(p0)
_Cgo_use(p1)
_Cgo_use(p2)
_Cgo_use(p3)
_Cgo_use(p4)
}
return
}
//go:cgo_import_static _cgo_bbce630bddcc_Cfunc_mygetgrouplist
//go:linkname __cgofn__cgo_bbce630bddcc_Cfunc_mygetgrouplist _cgo_bbce630bddcc_Cfunc_mygetgrouplist
var __cgofn__cgo_bbce630bddcc_Cfunc_mygetgrouplist byte
var _cgo_bbce630bddcc_Cfunc_mygetgrouplist = unsafe.Pointer(&__cgofn__cgo_bbce630bddcc_Cfunc_mygetgrouplist)
//go:cgo_unsafe_args
func _Cfunc_mygetgrouplist(p0 *_Ctype_char, p1 _Ctype___gid_t, p2 *_Ctype___gid_t, p3 *_Ctype_int) (r1 _Ctype_int) {
_cgo_runtime_cgocall(_cgo_bbce630bddcc_Cfunc_mygetgrouplist, uintptr(unsafe.Pointer(&p0)))
if _Cgo_always_false {
_Cgo_use(p0)
_Cgo_use(p1)
_Cgo_use(p2)
_Cgo_use(p3)
}
return
}
//go:cgo_import_static _cgo_bbce630bddcc_Cfunc_mygetpwnam_r
//go:linkname __cgofn__cgo_bbce630bddcc_Cfunc_mygetpwnam_r _cgo_bbce630bddcc_Cfunc_mygetpwnam_r
var __cgofn__cgo_bbce630bddcc_Cfunc_mygetpwnam_r byte
var _cgo_bbce630bddcc_Cfunc_mygetpwnam_r = unsafe.Pointer(&__cgofn__cgo_bbce630bddcc_Cfunc_mygetpwnam_r)
//go:cgo_unsafe_args
func _Cfunc_mygetpwnam_r(p0 *_Ctype_char, p1 *_Ctype_struct_passwd, p2 *_Ctype_char, p3 _Ctype_size_t, p4 **_Ctype_struct_passwd) (r1 _Ctype_int) {
_cgo_runtime_cgocall(_cgo_bbce630bddcc_Cfunc_mygetpwnam_r, uintptr(unsafe.Pointer(&p0)))
if _Cgo_always_false {
_Cgo_use(p0)
_Cgo_use(p1)
_Cgo_use(p2)
_Cgo_use(p3)
_Cgo_use(p4)
}
return
}
//go:cgo_import_static _cgo_bbce630bddcc_Cfunc_mygetpwuid_r
//go:linkname __cgofn__cgo_bbce630bddcc_Cfunc_mygetpwuid_r _cgo_bbce630bddcc_Cfunc_mygetpwuid_r
var __cgofn__cgo_bbce630bddcc_Cfunc_mygetpwuid_r byte
var _cgo_bbce630bddcc_Cfunc_mygetpwuid_r = unsafe.Pointer(&__cgofn__cgo_bbce630bddcc_Cfunc_mygetpwuid_r)
//go:cgo_unsafe_args
func _Cfunc_mygetpwuid_r(p0 _Ctype_int, p1 *_Ctype_struct_passwd, p2 *_Ctype_char, p3 _Ctype_size_t, p4 **_Ctype_struct_passwd) (r1 _Ctype_int) {
_cgo_runtime_cgocall(_cgo_bbce630bddcc_Cfunc_mygetpwuid_r, uintptr(unsafe.Pointer(&p0)))
if _Cgo_always_false {
_Cgo_use(p0)
_Cgo_use(p1)
_Cgo_use(p2)
_Cgo_use(p3)
_Cgo_use(p4)
}
return
}
//go:cgo_import_static _cgo_bbce630bddcc_Cfunc_realloc
//go:linkname __cgofn__cgo_bbce630bddcc_Cfunc_realloc _cgo_bbce630bddcc_Cfunc_realloc
var __cgofn__cgo_bbce630bddcc_Cfunc_realloc byte
var _cgo_bbce630bddcc_Cfunc_realloc = unsafe.Pointer(&__cgofn__cgo_bbce630bddcc_Cfunc_realloc)
//go:cgo_unsafe_args
func _Cfunc_realloc(p0 unsafe.Pointer, p1 _Ctype_size_t) (r1 unsafe.Pointer) {
_cgo_runtime_cgocall(_cgo_bbce630bddcc_Cfunc_realloc, uintptr(unsafe.Pointer(&p0)))
if _Cgo_always_false {
_Cgo_use(p0)
_Cgo_use(p1)
}
return
}
//go:cgo_import_static _cgo_bbce630bddcc_Cfunc_sysconf
//go:linkname __cgofn__cgo_bbce630bddcc_Cfunc_sysconf _cgo_bbce630bddcc_Cfunc_sysconf
var __cgofn__cgo_bbce630bddcc_Cfunc_sysconf byte
var _cgo_bbce630bddcc_Cfunc_sysconf = unsafe.Pointer(&__cgofn__cgo_bbce630bddcc_Cfunc_sysconf)
//go:cgo_unsafe_args
func _Cfunc_sysconf(p0 _Ctype_int) (r1 _Ctype_long) {
_cgo_runtime_cgocall(_cgo_bbce630bddcc_Cfunc_sysconf, uintptr(unsafe.Pointer(&p0)))
if _Cgo_always_false {
_Cgo_use(p0)
}
return
}
//go:cgo_import_static _cgo_bbce630bddcc_Cfunc__Cmalloc
//go:linkname __cgofn__cgo_bbce630bddcc_Cfunc__Cmalloc _cgo_bbce630bddcc_Cfunc__Cmalloc
var __cgofn__cgo_bbce630bddcc_Cfunc__Cmalloc byte
var _cgo_bbce630bddcc_Cfunc__Cmalloc = unsafe.Pointer(&__cgofn__cgo_bbce630bddcc_Cfunc__Cmalloc)
//go:linkname runtime_throw runtime.throw
func runtime_throw(string)
//go:cgo_unsafe_args
func _cgo_cmalloc(p0 uint64) (r1 unsafe.Pointer) {
_cgo_runtime_cgocall(_cgo_bbce630bddcc_Cfunc__Cmalloc, uintptr(unsafe.Pointer(&p0)))
if r1 == nil {
runtime_throw("runtime: C malloc failed")
}
return
} |
If you pass |
Can repro on !netbsd by adding
and then running |
@ianlancetaylor Thanks, I'll take a look at the |
I don't know the issues here, but we could perhaps change cgo to emit special comments for macros in the _cgo_gotypes.go file. |
@ianlancetaylor The goal is given the unmodified original Go source files and the _cgo_gotypes.go file generated from running cgo on them, to have go/types able to figure out the Go type of all C.foo identifiers. The way CL 33677 does that is it has a list of all the prefixes that cgo currently emits, and it tries looking each of them up. E.g., for C.foo it looks up _Ciconst_foo, _Cfconst_foo, _Ctype_foo, _Cvar_foo, ... until one succeeds. It also knows like that _Cvar_foo is actually a pointer to the variable and so it needs an implicit dereference, or that _Cmacro_foo is a function that needs to be called to evaluate to the value. The problem is here C.gid_t is being translated by cgo into an identifier not found using this approach. It would be best for go/types if the special comments were spelled |
Looking at (*Package).rewriteName, it looks like the It looks like those lines predate type aliases. I'd imagine we can just emit the type alias under the normal mangled name, and then use the normal mangling. I'll look into this. |
Change https://golang.org/cl/230037 mentions this issue: |
Change https://golang.org/cl/230038 mentions this issue: |
Seems that there are multiple failures being masked: reverting https://golang.org/cl/33677 gives a different test failure on NetBSD:
If this is due to a different change, I’d really like us to revert liberally and soon to get us back into a passing state. |
Change https://golang.org/cl/230309 mentions this issue: |
That is #38595 and it was supposed to be fixed by https://go-review.googlesource.com/c/go/+/229484. cc @ianlancetaylor |
This reverts CL 33677. Reason for revert: NetBSD is broken Updates #38649 Change-Id: Id60e3c97d3cb4fb0053dea03b95dbbb0b850c883 Reviewed-on: https://go-review.googlesource.com/c/go/+/230038 Run-TryBot: Andrew Bonventre <[email protected]> Reviewed-by: Robert Griesemer <[email protected]> Reviewed-by: Matthew Dempsky <[email protected]>
Thanks, @josharian. Will keep an eye the builders and report back on that issue if it’s still failing with the same |
This reverts CL 33677. Reason for revert: NetBSD is broken Updates golang#38649 Change-Id: Id60e3c97d3cb4fb0053dea03b95dbbb0b850c883 Reviewed-on: https://go-review.googlesource.com/c/go/+/230038 Run-TryBot: Andrew Bonventre <[email protected]> Reviewed-by: Robert Griesemer <[email protected]> Reviewed-by: Matthew Dempsky <[email protected]>
Cgo's initial design for handling "#define foo int*" involved rewriting "C.foo" to "*_Ctype_int" everywhere. But now that we have type aliases, we can declare "type _Ctype_foo = *_Ctype_int" once, and then rewrite "C.foo" to just "_Ctype_foo". This is important for go/types's UsesCgo mode, where go/types needs to be able to figure out a type for each C.foo identifier using only the information written into _cgo_gotypes.go. Fixes golang#38649. Change-Id: Ia0f8c2d82df81efb1be5bc26195ea9154c0af871 Reviewed-on: https://go-review.googlesource.com/c/go/+/230037 Run-TryBot: Matthew Dempsky <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Ian Lance Taylor <[email protected]>
TestImportStdLib
is failing on NetBSD on tip. As seen onhttps://build.golang.org/log/fad56ee11c8b5522a96342ee2a936845758f1ab0
CC @mdempsky @griesemer
The text was updated successfully, but these errors were encountered: