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: can't find import: "syscall" when doing build of cgo package #5048

Closed
alberts opened this issue Mar 14, 2013 · 11 comments
Closed

cmd/go: can't find import: "syscall" when doing build of cgo package #5048

alberts opened this issue Mar 14, 2013 · 11 comments
Milestone

Comments

@alberts
Copy link
Contributor

alberts commented Mar 14, 2013

What steps will reproduce the problem?

put http://play.golang.org/p/zF9uZNJHFb in $GOPATH/src/foo/foo.go

rm -rf $GOROOT/pkg/linux_amd64_race
go install -v -race ./...

What is the expected output?

a working build

What do you see instead?

/tmp/go-build390630312/foo/_obj/_cgo_gotypes.go:7: can't find import: "syscall"

Which compiler are you using (5g, 6g, 8g, gccgo)?

6g

Which operating system are you using?

linux

Which version are you using?  (run 'go version')

go version devel +90c75b8f9526 Wed Mar 13 23:32:12 2013 -0400 linux/amd64

Please provide any additional information below.

seems to happen when the package uses cgo
@dvyukov
Copy link
Member

dvyukov commented Mar 14, 2013

Comment 1:

Please try
$ rm -Rf $GOROOT/pkg $GOROOT/bin
$ all.bash

@alberts
Copy link
Contributor Author

alberts commented Mar 14, 2013

Comment 2:

I did this:
#!/bin/bash
set -xe
export GOPATH=`pwd`
rm -Rf $GOROOT/pkg $GOROOT/bin
cd $GOROOT/src
./make.bash
cd $GOPATH
rm -rf $GOROOT/pkg/linux_amd64_race
go install -v -race ./...
same issue.

@dvyukov
Copy link
Member

dvyukov commented Mar 14, 2013

Comment 3:

The script says:
go install: no install location for directory /.../gopath/src/foo outside GOPATH

@dvyukov
Copy link
Member

dvyukov commented Mar 14, 2013

Comment 4:

OK, I am able to reproduce it by copying foo to code.google.com/p/foo

@dvyukov
Copy link
Member

dvyukov commented Mar 14, 2013

Comment 5:

The workaround is to type:
$ go install -race -v ./...
again

@alberts
Copy link
Contributor Author

alberts commented Mar 14, 2013

Comment 6:

Mmm... strange. Here's my script and build log. Where do our setups differ?

Attachments:

  1. build.log (3181 bytes)
  2. build.sh (193 bytes)

@alberts
Copy link
Contributor Author

alberts commented Mar 14, 2013

Comment 7:

Thanks, I found the workaround.

@dvyukov
Copy link
Member

dvyukov commented Mar 14, 2013

Comment 8:

The same happens with normal (non -race) build, if you don't preinstall syscall.
$ go install [-race] std
fixes it in both cases.
So this is low-priority bug in cmd/go. Normal uses who have all preinstalled packages
should not hit it.

@rsc
Copy link
Contributor

rsc commented Jul 30, 2013

Comment 9:

Labels changed: added priority-later, go1.2maybe, removed priority-triage.

Status changed to Accepted.

@alberts
Copy link
Contributor Author

alberts commented Aug 5, 2013

Comment 10:

This bug leads to other fun.
Steps to reproduce:
1. Know about this bug
2. Sometimes run go install -race std before doing a race build of your command
3. Some days after that, run gofmt over all your source code
4. Be confused about why gofmt takes minutes instead of seconds
Turns out go install -race std installed a race-enabled gofmt. Maybe a tweak somewhere
will save a few people the confusion I've been experiencing.

@rsc
Copy link
Contributor

rsc commented Aug 9, 2013

Comment 11:

This issue was closed by revision b0a1b82.

Status changed to Fixed.

@rsc rsc added this to the Go1.2 milestone Apr 14, 2015
@rsc rsc removed the go1.2maybe label Apr 14, 2015
@golang golang locked and limited conversation to collaborators Jun 24, 2016
This issue was closed.
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

4 participants