Skip to content
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: unexpected: 8-byte pointer type errors with GOARCH=arm #12442

Closed
jacobsa opened this issue Sep 1, 2015 · 4 comments
Closed

cmd/cgo: unexpected: 8-byte pointer type errors with GOARCH=arm #12442

jacobsa opened this issue Sep 1, 2015 · 4 comments
Milestone

Comments

@jacobsa
Copy link
Contributor

jacobsa commented Sep 1, 2015

I'm attempting to regenerate the darwin/arm code for golang.org/x/sys/unix from the latest iOS SDK, but running into a problem with go tool cgo -godefs on that architecture. Here is a file that reproduces the issue:

package blah

/*
typedef struct foo {
    void* a;
} foo_t;
*/
import "C"

type Foo_t C.struct_foo

Put that in foo.go and this happens:

% GOARCH=arm go tool cgo -godefs foo.go
/Users/jacobsa/go/src/golang.org/x/sys/unix/foo.go:10:12: unexpected: 8-byte pointer type - *void

I'm not sure what that message means in this context, since I haven't given cgo any input on the size of that pointer except by setting GOARCH. I wonder if I've misconfigured something, but can't find any relevant documentation so I'm not sure. It may be relevant that this doesn't happen when GOARCH is set to 386.

This happens at tip on OS X:

% go version
go version devel +dd42eff Tue Sep 1 22:13:16 2015 +0000 darwin/amd64
@ianlancetaylor ianlancetaylor added this to the Go1.6 milestone Sep 2, 2015
@ianlancetaylor
Copy link
Contributor

cgo works by building a C file, compiling it, and examining the debug info. In this case it is complaining because it expects pointer types to have the size of a pointer. For GOARCH=386 a pointer is obviously 4 bytes, but the debug info is indicating that the pointer is 8 bytes.

In order to use cgo in a cross-compilation situaiton like this one, you need to set CC tin the environment o a cross-compiler for ARM. Look for "when cross-compiling" in https://golang.org/cmd/cgo .

I'm going to close this on the assumption that you didn't set CC. Please reopen if I've misunderstood.

@jacobsa
Copy link
Contributor Author

jacobsa commented Sep 2, 2015

@iant: Thanks. Do you happen to know what an appropriate value of CC is for building arm and arm64 respectively on OS X?

@minux
Copy link
Member

minux commented Sep 2, 2015 via email

@jacobsa
Copy link
Contributor Author

jacobsa commented Sep 2, 2015

Whoa, that's exactly what I've been looking for this whole time! Thank you. :-)

@golang golang locked and limited conversation to collaborators Sep 4, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants