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: 'go install' with cgo disabled does not report pure-cgo package #6078
Labels
Milestone
Comments
My current sources are with too many dependencies to share. Will try to construct a small example. Following are the conditions under which problem occurs: 1. hi.go uses another library mylib 2. The mylib library in turn links to a my own 32-bit C library 3. GOHOSTARCH is amd64 4. Install mylib with GOARCH=386 and CGO_ENABLED=1 5. If GOARCH is set to 386 (with default CGO_ENABLED value which is 0) -> happens if one uses another shell or logins in after few days and unsuspectingly just sets GOARCH Now trying to build hi.go gives errors as above. |
Additional hint - probably related issue: Installing a cgo package when CGO_ENABLED=0, fails silently // mylib.go (in exp/cgoerr/mylib package) package mylib /* #include <stdio.h> #include <stdlib.h> void myprint(char* s) { printf("%s", s); } */ import "C" import "unsafe" func Funca() { cs := C.CString("Hello from stdio\n") C.myprint(cs) C.free(unsafe.Pointer(cs)) } func Funcb() { fmt.Println("...in mylib Funcb()") } > cd $GOPATH/src/exp/cgoerr/mylib > export CGO_ENABLED=0 > go install . --> no error message inspite of failure > ls $GOPATH/pkg/linux_386 --> no package is installed |
I see two bugs in your report. 1. Your program hi.go is importing "cglib" but that package has declared some other name for itself (not cglib), which is why you see both `imported and not used: "cglib"` and `undefined: cglib` when you try to use it. I fixed this yesterday. The first error will now say ./hi.go:4: imported and not used: "cglib" as pkgname where pkgname is whatever cglib has declared itself to be. 2. If you are in a directory with only cgo files but cgo is disabled, 'go install .' fails to print an error (it does nothing). I will make this bug about #2. |
This issue was closed by revision 611b182. Status changed to Fixed. |
This issue was closed.
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
The text was updated successfully, but these errors were encountered: