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: ignores arguments in $CC #14551

Closed
hirochachacha opened this issue Feb 28, 2016 · 7 comments
Closed

cmd/cgo: ignores arguments in $CC #14551

hirochachacha opened this issue Feb 28, 2016 · 7 comments

Comments

@hirochachacha
Copy link
Contributor

Please answer these questions before submitting your issue. Thanks!

  1. What version of Go are you using (go version)?
    go version devel +ff27421 Sun Feb 28 11:06:40 2016 +0000 darwin/amd64
  2. What operating system and processor architecture are you using (go env)?
    GOARCH="amd64"
    GOBIN=""
    GOEXE=""
    GOHOSTARCH="amd64"
    GOHOSTOS="darwin"
    GOOS="darwin"
    GOPATH="/Users/hiro/.go"
    GORACE=""
    GOROOT="/Users/hiro/work/go"
    GOTOOLDIR="/Users/hiro/work/go/pkg/tool/darwin_amd64"
    CC="clang"
    GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -gno-record-gcc-switches -fno-common"
    CXX="clang++"
    CGO_ENABLED="1"
  3. What did you do?
    (Use play.golang.org to provide a runnable example, if possible.)

$ CC="$(xcrun --sdk iphoneos --find clang) -arch armv7 -isysroot $(xcrun --sdk iphoneos --show-sdk-path)" GOARCH=arm go tool cgo -godefs input.go

input.go

package p

/*
typedef void * ptr;
*/
import "C"

type Ptr C.ptr
  1. What did you expect to see?
    No errors.
  2. What did you see instead?
unexpected: 8-byte pointer type - *void

XCode 7.2.1 (latest)

$(xcrun --sdk iphoneos --find clang) --version

Apple LLVM version 7.0.2 (clang-700.1.81)
Target: x86_64-apple-darwin15.3.0
Thread model: posix

Thank you.

@hirochachacha hirochachacha changed the title cmd/cgo: unexpected: 8-byte pointer type - *void on darwin/arm cmd/cgo: godefs failed with message "unexpected: 8-byte pointer type - *void" on darwin/arm Feb 28, 2016
@hirochachacha hirochachacha changed the title cmd/cgo: godefs failed with message "unexpected: 8-byte pointer type - *void" on darwin/arm cmd/cgo: -godefs failed with message "unexpected: 8-byte pointer type - *void" when darwin/arm is target Feb 28, 2016
@hirochachacha hirochachacha changed the title cmd/cgo: -godefs failed with message "unexpected: 8-byte pointer type - *void" when darwin/arm is target cmd/cgo: -godefs fail with message "unexpected: 8-byte pointer type - *void" when darwin/arm is target Feb 28, 2016
@ianlancetaylor ianlancetaylor added this to the Go1.7 milestone Feb 28, 2016
@ianlancetaylor
Copy link
Contributor

Your C compiler seems to be generating debug info that says that the size of the type "void*" is 8 bytes. cgo is complaining because you set GOARCH=arm, so cgo expects 4 byte pointers.

Look closely at the compiler in

CC="$(xcrun --sdk iphoneos --find clang) -arch armv7 -isysroot $(xcrun --sdk iphoneos --show-sdk-path)"

Are you sure that compiler will generate 32-bit ARM code? (I don't know who XCode works myself).

You may want to run cgo with -debug-gcc to see precisely how cgo is invoking the compiler.

@hirochachacha
Copy link
Contributor Author

You may want to run cgo with -debug-gcc to see precisely how cgo is invoking the compiler.

It helps me.

I guess I understand the problem.

$ CC="foo bar" go env CC

foo

Is this work as intended?

@hirochachacha
Copy link
Contributor Author

CXX has same problem.

@minux
Copy link
Member

minux commented Feb 29, 2016 via email

@hirochachacha
Copy link
Contributor Author

Yes. But is this desirable behavior?

@ianlancetaylor
Copy link
Contributor

No, it's not. But the cgo tool does provide another way to specify compiler options, so it's not urgent.

@ianlancetaylor ianlancetaylor changed the title cmd/cgo: -godefs fail with message "unexpected: 8-byte pointer type - *void" when darwin/arm is target cmd/cgo: ignores arguments in $CC Feb 29, 2016
@ianlancetaylor ianlancetaylor modified the milestones: Unplanned, Go1.7 Feb 29, 2016
@seankhliao
Copy link
Member

seankhliao commented Jan 26, 2021

resolved with #43808 and CL 284780
tracking with #43078

@golang golang locked and limited conversation to collaborators Jan 26, 2022
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

5 participants