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 -buildmode=shared with no directory name generates bad shared library name #12236
Comments
It would be very helpful if you could provide complete reproduction instructions, by which I mean the contents of the files you are compiling, the names of the directories they are in, etc. Your current description is sort of vague; when I do the exact same steps it works fine. There is something different about what you are doing, and the more details you can provide the more likely it is that we can figure out what it is. Thanks. |
package lib
func init() {
print("package lib")
}
package main
import (
_ "lib"
)
func main() {
}
|
Thanks. I can recreate the problem. It's a bug in how the go tool generates the library name. The workaround is: don't cd DIR and run "go install -buildmode=shared -linkshared". Instead, run "go install -buildmode=shared -linkshared DIR". The go tool is using the explicit argument to construct the library name. When you don't give it any argument, the go tool generates "lib.so". That then confuses the linker. CC @mwhudson |
Thank you for your assistance. I am really glad to be helpful for this project) |
Oh right, this is sort of the same problem as #10473 then. |
There's a clear workaround here. Better to use that for the 1.5 cycle. Thanks. |
CL https://golang.org/cl/13921 mentions this issue. |
Go v 1.5. Fedora 22 x86_64
go install -buildmode=shared -linkshared
go build -linkshared
go/pkg/tool/linux_amd64/link: running gcc failed: exit status 1 gcc: error: missing argument to ‘-l’
Output with the '-x' option:
/home/user/dev/go/pkg/tool/linux_amd64/link -o $WORK/godev/proj/_obj/exe/a.out -L $WORK -L /home/user/dev/godev/pkg/linux_amd64_dynlink -installsuffix dynlink -extld=gcc -buildmode=exe -buildid=98b4ec39a65525d2ee4614652117b2ad4dfdeb26 -linkshared -w $WORK/godev/proj.a /home/user/dev/go/pkg/tool/linux_amd64/link: running gcc failed: exit status 1 gcc: error: missing argument to ‘-l
The same command with '-x --compiler=gccgo' option produces the following:
/usr/bin/gccgo -o $WORK/godev/testgo/_obj/exe/a.out $WORK/godev/testgo/_obj/_go_.o -Wl,-( -m64 -Wl,-) -L/home/user/dev/godev/pkg/gccgo_linux_amd64_fPIC/shlibs -Wl, -rpath=/home/user/dev/godev/pkg/gccgo_linux_amd64_fPIC/shlibs -l -Wl,-E -fPIC
The output is:
/usr/bin/ld: cannot find -l-Wl,-E collect2: error: ld returned 1 exit status
It compiles well without -linkshared. Is there an error, or I just misuse these options?
The text was updated successfully, but these errors were encountered: