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/go: different cgo output for gc and gccgo #20910

Closed
msteinert opened this issue Jul 5, 2017 · 1 comment
Closed

cmd/go: different cgo output for gc and gccgo #20910

msteinert opened this issue Jul 5, 2017 · 1 comment
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@msteinert
Copy link
Contributor

msteinert commented Jul 5, 2017

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

$ go version
go version devel +6c4f3a0c16 Tue Jul 4 21:05:41 2017 +0000 linux/amd64
$ gccgo --version
gccgo (Ubuntu/Linaro 6.3.0-18ubuntu2~16.04) 6.3.0 20170519
Copyright (C) 2016 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

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

$ go env
GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/opt/home/mike/go"
GORACE=""
GOROOT="/opt/home/mike/src/git/go"
GOTOOLDIR="/opt/home/mike/src/git/go/pkg/tool/linux_amd64"
GCCGO="/usr/bin/gccgo"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build705281681=/tmp/go-build -gno-record-gcc-switches"
CXX="g++"
CGO_ENABLED="1"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"

What did you do?

I have a wrapper for PAM which involves calling a Go function from C. The Go function returns multiple values.

An issue was reported when compiling with gccgo. After some investigation I noticed the name of the struct generated for gccgo is different:

$ diff _gccgo/_cgo_export.h _obj/_cgo_export.h 
65c65
< struct cbPAMConv_result {
---
> struct cbPAMConv_return {
71c71,72
< extern struct cbPAMConv_result cbPAMConv (int p0, char* p1, GoInt p2);
---
> 
> extern struct cbPAMConv_return cbPAMConv(int p0, char* p1, GoInt p2);

Everything else appears to be the same. Changing the struct name in my C program solves the problem. Is this intended? If so, what is the correct way to detect gccgo in the C program in order to use the alternate definition?

I saw the same result with 1.7 and 1.8.

What did you expect to see?

The same cgo struct names for gc and gccgo.

What did you see instead?

The struct names differ.

@gopherbot gopherbot added this to the Gccgo milestone Jul 5, 2017
@bradfitz bradfitz changed the title Different cgo output for gc and gccgo cmd/go: different cgo output for gc and gccgo Jul 5, 2017
@bradfitz bradfitz added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Jul 5, 2017
@gopherbot
Copy link

CL https://golang.org/cl/49350 mentions this issue.

@golang golang locked and limited conversation to collaborators Aug 16, 2018
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.
Projects
None yet
Development

No branches or pull requests

4 participants