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: Copying of _cgo_install.h causes problems when $WORK and $GOPATH are on different disks. #11131

Closed
spetrovic77 opened this issue Jun 9, 2015 · 2 comments
Milestone

Comments

@spetrovic77
Copy link
Contributor

NOTE: this problem only occurs when building using -buildmode=c-shared

Here is my reproducible setup:

export TMPDIR=/tmp
export HOME=/usr/local/google/home/$USER

$ mkdir -p $HOME/gotest/src/test
$ cat > $HOME/gotest/src/test/test.go
package main

import "C"

//export exportedFunc
func exportedFunc() {}

func main() {}

$ GOPATH=$HOME/gotest go install -buildmode=c-shared test

$ cat > $HOME/gotest/src/test/test.go
package main

import "C"

//export exportedFunc
func exportedFunc() {}

func main() {
}

$ GOPATH=$HOME/gotest go install -buildmode=c-shared -x test
....
cp $WORK/test/_obj/_cgo_install.h /usr/local/google/home/spetrovic/gotest/pkg/linux_amd64_shared/test.h
build output "/usr/local/google/home/spetrovic/gotest/pkg/linux_amd64_shared/test.h" already exists and is not an object file

The problem is that $WORK and $HOME are on different devices in my setup, and hence the os.Rename() fails to move the file _cgo_install.h with: "invalid cross-device link"; cmd/go/build.go then tries to copy the file over, but this code causes it to fail as well:

if !isObject(dst) {
return fmt.Errorf("build output %q already exists and is not an object file", dst)
}

My question is, what is the purpose of this isObject() check and can we get rid of it?

@ianlancetaylor ianlancetaylor added this to the Go1.5 milestone Jun 9, 2015
@ianlancetaylor
Copy link
Contributor

The isObject check is not appropriate for _cgo_install.h. It is meaningful for the case where copyFile is called from moveOrCopyFile when called from builder.install, because of http://golang.org/issue/2829 . But we should add a flag parameter, or something along those lines, to skip the test when copying a header file.

@gopherbot
Copy link

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

@mikioh mikioh changed the title Copying of _cgo_install.h causes problems when $WORK and $GOPATH are on different disks. cmd/go: Copying of _cgo_install.h causes problems when $WORK and $GOPATH are on different disks. Jun 13, 2015
@golang golang locked and limited conversation to collaborators Jun 25, 2016
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

3 participants