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

os/user: listgroups_unix.go: missing build directive line #16252

Closed
cznic opened this issue Jul 2, 2016 · 7 comments
Closed

os/user: listgroups_unix.go: missing build directive line #16252

cznic opened this issue Jul 2, 2016 · 7 comments

Comments

@cznic
Copy link
Contributor

cznic commented Jul 2, 2016

tip @ 519b469

AFAICT, there is a line missing:

 // +build cgo

The missing directive causes load errors when the cgo build tag is not defined, for example:

/home/jnml/go/src/os/user/lookup_stubs.go:65:6: listGroups redeclared,
        previous declaration at /home/jnml/go/src/os/user/listgroups_unix.go:22:6

I believe getgrouplist_darwin.go and getgrouplist_unix.go have the same problem.

@mikioh mikioh changed the title os/user/listgroups_unix.go: missing build directive line os/user: listgroups_unix.go: missing build directive line Jul 2, 2016
@mikioh
Copy link
Contributor

mikioh commented Jul 2, 2016

@cznic,

I guess that it happens when CGO_ENABLED=0 and using go build --tags cgo, not only on os/user package but net package, right?

@cznic
Copy link
Contributor Author

cznic commented Jul 2, 2016

It's triggered by a 3rd party package loader (work in progress), which does not support CGO, so the cgo tag is undefined.

Do you need a exact reproduction case/steps? I can prepare that, it's just it involves unfinished/unstable stuff.

OTOH, CGO_ENABLED= 0 ./all.bash should do the same, in theory, and I did not try that.

@mikioh
Copy link
Contributor

mikioh commented Jul 3, 2016

It's triggered by a 3rd party package loader (work in progress), which does not support CGO, so the cgo tag is undefined.

But cross-compiling, maybe?

Do you need a exact reproduction case/steps?

I think it's better.

@dsnet
Copy link
Member

dsnet commented Jul 3, 2016

/cc @zombiezen

@cznic
Copy link
Contributor Author

cznic commented Jul 3, 2016

Cannot reproduce using CGO_ENABLED=0. For example

$ CGO_ENABLED=0 go build -x -a os/user
...
mkdir -p $WORK/os/user/_obj/
mkdir -p $WORK/os/
cd /home/jnml/go/src/os/user
/home/jnml/go/pkg/tool/linux_amd64/compile -o $WORK/os/user.a -trimpath $WORK
-p os/user -complete -buildid 5ea22e2e3f690c420c76db9f6b3a981a0173d286
-D _/home/jnml/go/src/os/user -I $WORK -pack ./lookup.go ./lookup_stubs.go ./user.go
$

I don't know why the build does not include getgrouplist_unix.go and listgroups_unix.go. unix is not an item in syslist, the suffix _unix should not exclude the file from build on linux and the build directive seems to be satisfied:

// +build dragonfly darwin freebsd !android,linux netbsd openbsd

Particulary, !androind and linux should be true in my case and thus the whole expression as well. I must be missing something. I'm no more sure if there really is a bug.

My env

$ go env
GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/jnml"
GORACE=""
GOROOT="/home/jnml/go"
GOTOOLDIR="/home/jnml/go/pkg/tool/linux_amd64"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build543108208=/tmp/go-build -gno-record-gcc-switches"
CXX="g++"
CGO_ENABLED="1"
$ 

@ianlancetaylor
Copy link
Contributor

Normally if cgo is enabled then files with import "C" are built, and if cgo is not enabled then files with import "C" are ignored. Search for isCgo in go/build/build.go.

I don't know what the problem is here, but it would help to know how to reproduce it.

@cznic
Copy link
Contributor Author

cznic commented Jul 4, 2016

Thanks for clarifying. It means the bug is not in the Go project. Sorry for the noise.

@cznic cznic closed this as completed Jul 4, 2016
@golang golang locked and limited conversation to collaborators Jul 4, 2017
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