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
LiamHaworth opened this issue Mar 26, 2018 · 6 comments

Comments

@LiamHaworth
Copy link

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

@LiamHaworth

This comment has been minimized.

Copy link
Author

commented Mar 26, 2018

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)
@LiamHaworth

This comment has been minimized.

Copy link
Author

commented Mar 26, 2018

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 this to the Go1.11 milestone Mar 26, 2018

@andybons

This comment has been minimized.

Copy link
Member

commented Mar 26, 2018

@ianlancetaylor

This comment has been minimized.

Copy link
Contributor

commented Mar 26, 2018

@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

This comment has been minimized.

Copy link
Contributor

commented Jun 13, 2018

@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

This comment has been minimized.

Copy link
Contributor

commented Jun 16, 2018

Dup of #24161

@randall77 randall77 closed this Jun 16, 2018

@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.
Projects
None yet
5 participants
You can’t perform that action at this time.