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

Open
hirochachacha opened this Issue Feb 28, 2016 · 6 comments

Comments

Projects
None yet
3 participants
@hirochachacha
Contributor

hirochachacha commented Feb 28, 2016

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 from cmd/cgo: unexpected: 8-byte pointer type - *void on darwin/arm to cmd/cgo: godefs failed with message "unexpected: 8-byte pointer type - *void" on darwin/arm Feb 28, 2016

@hirochachacha hirochachacha changed the title from cmd/cgo: godefs failed with message "unexpected: 8-byte pointer type - *void" on darwin/arm to 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 from cmd/cgo: -godefs failed with message "unexpected: 8-byte pointer type - *void" when darwin/arm is target to 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

This comment has been minimized.

Contributor

ianlancetaylor commented Feb 28, 2016

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

This comment has been minimized.

Contributor

hirochachacha commented Feb 29, 2016

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

This comment has been minimized.

Contributor

hirochachacha commented Feb 29, 2016

CXX has same problem.

@minux

This comment has been minimized.

Member

minux commented Feb 29, 2016

@hirochachacha

This comment has been minimized.

Contributor

hirochachacha commented Feb 29, 2016

Yes. But is this desirable behavior?

@ianlancetaylor

This comment has been minimized.

Contributor

ianlancetaylor commented Feb 29, 2016

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 from cmd/cgo: -godefs fail with message "unexpected: 8-byte pointer type - *void" when darwin/arm is target to cmd/cgo: ignores arguments in $CC Feb 29, 2016

@ianlancetaylor ianlancetaylor modified the milestones: Unplanned, Go1.7 Feb 29, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment