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: can't pass kCFRunLoopDefaultMode as CFRunLoopMode #24531

Closed
KatelynHaworth opened this issue Mar 26, 2018 · 6 comments
Closed

cmd/cgo: can't pass kCFRunLoopDefaultMode as CFRunLoopMode #24531

KatelynHaworth opened this issue Mar 26, 2018 · 6 comments
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. OS-Darwin
Milestone

Comments

@KatelynHaworth
Copy link
Contributor

KatelynHaworth commented Mar 26, 2018

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

go version go1.10 darwin/amd64

and

go version devel +dc3a92edaa Mon Mar 26 19:42:08 2018 +0000 darwin/amd64

Does this issue reproduce with the latest release?

Yes

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

GOARCH="amd64"
GOBIN="/Volumes/Storage/git/git/go_path/bin"
GOCACHE="/Users/liam/Library/Caches/go-build"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Volumes/Storage/git/git/go_path"
GORACE=""
GOROOT="/usr/local/Cellar/go/1.10/libexec"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.10/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
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/xx/mdt3785n0js3yrk67_ftskdr0000gn/T/go-build744503608=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

Trying to compile CGO code on darwin that makes calls to C functions, it would compile correctly on go 1.9.2 but now fails to build on go 1.10

What did you expect to see?

A successful build

What did you see instead?

# command-line-arguments
./main.go:150: cannot use *_Cvar_kCFRunLoopDefaultMode (type _Ctype_CFStringRef) as type *_Ctype_struct___CFString in argument to func literal
./main.go:157: cannot use *_Cvar_kCFRunLoopDefaultMode (type _Ctype_CFStringRef) as type *_Ctype_struct___CFString in argument to func literal

More information

I understand in go 1.10 there where changes made to how CGO is handled for darwin platforms, I did update some other parts of my code to comply with the new nil variable setting (val =0 vs val = nil) but this error doesn't seem to make sense.

The function being called is CFRunLoopRemoveSource who's third parameter accepts a type of CFRunLoopMode which is just a typedef of CFStringRef.

For the third parameter I am passing kCFRunLoopDefaultMode which should comply with the type matching as it has a type of CFRunLoopMode.

Example Code

https://gist.github.com/LiamHaworth/d50ce9167fe0377cd20d6585d77a70b4

@KatelynHaworth
Copy link
Contributor Author

To add to this, when a dummy function is specified in Go code with the name signature it compiles without a complaint.

func CFRunLoopRemoveSource(rl C.CFRunLoopRef, source C.CFRunLoopSourceRef, mode C.CFRunLoopMode)

@KatelynHaworth
Copy link
Contributor Author

The C signature is defined in the CoreFoundation library in this file https://opensource.apple.com/source/CF/CF-744/CFRunLoop.h on line 81

@andybons andybons added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Mar 26, 2018
@andybons andybons added this to the Go1.11 milestone Mar 26, 2018
@andybons
Copy link
Member

@ianlancetaylor

@ianlancetaylor
Copy link
Contributor

CC @randall77

@ianlancetaylor ianlancetaylor changed the title cmd/compile: type assertion throwing false positive for darwin CGO cmd/cgo: can't pass kCFRunLoopDefaultMode as CFRunLoopMode Mar 26, 2018
@ianlancetaylor
Copy link
Contributor

@randall77 Would be nice to fix this for 1.11 if possible. I hope that you have more state on this stuff than I do.

@randall77 randall77 self-assigned this Jun 15, 2018
@randall77
Copy link
Contributor

Dup of #24161

@golang golang locked and limited conversation to collaborators Jun 16, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. OS-Darwin
Projects
None yet
Development

No branches or pull requests

5 participants