-
Notifications
You must be signed in to change notification settings - Fork 17.7k
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/link: duplicate symbol reference pow on Windows #8756
Comments
Possibly related to: https://golang.org/issue/8702 |
Issue #8702 has been merged into this issue. |
I'm working on it. |
@frederich Can you clarify a bit? Working on getting |
That would be great, thanks for doing it. |
It should be easy to accept both undefined variables and variables declared as strings but nothing else. |
@slimsag can you check to see if this is still broken on current tip? Thank you. Alex |
It still doesn't work for me with external linker using git master. What does 'go version' print? What steps reproduce the problem? What happened?
What should have happened instead? Please provide any additional information below. tdm64-gcc-4.9.2-3, msys+7za+wget+svn+git+mercurial+cvs-rev13 and mingw-w64-bin-x86_64-20150316(mingw-w64-dgn) were used. |
Yes it fails here for me too. Alex |
Hello, I'd just like to report that this problem still happens in the latest go version (tip) with the code given in: Cheers. |
We have a similar issue
any suggested workarounds? |
For mingw I think you are using the GNU linker. Try using The real fix may be to avoid adding |
I agree. I have been playing with this a while ago. The way I understand build process here (and you can read full gory details of cgo process in $GOROOT/src/cmd/cgo/doc.go), there are 2 steps: 1) each package (that is part of your final executable) is compiled into a compiled form (the bits that go into your $GOPATH/pkg directory); 2) final executable is built from all compiled packages. When cmd/go runs steps 1, it calls So, when it is time to do step 2, the linker will discover that two different compiled packages have function with the same name (pow). It cannot have that. I think what needs to happen is the "resolving pow symbol" bit should happen during step 2, not step 1. You can stop "resolving pow symbol" during step 1 by removing "-lmingwex -lmingw32" parameters from that call above. I am not sure how to add them during step 2. For "external" linking (the default mode), I think gcc will resolve symbols automatically (I had to revert https://go-review.googlesource.com/14472 to make "go test" pass in $GOROOT/misc/cgo/test - I still don't know why). For "internal" linking, I was toying with idea of calling
I think, if you apply this:
to the current tip, it will work for you. Assuming you are not doing anything fancy - for example, this will not work with "internal" linker. Alex |
Recompiling go is not an option as we're trying to ship a production-ready library.
|
My apologies, it needs to be |
By the way, yes, Go runs |
Sorry, but where should I put -linkopt? Go build does not recognize it. My command line is now: and the output goes:
|
You are doing what I suggested; sorry for the flag name error. You are now running into a different problem. I don't know what that is or how to fix it. It seems that it must affect other non-Go mingw builds. |
Whoever is still interested in fixing this, please test https://go-review.googlesource.com/#/c/26670/. Alex |
@alexbrainman what's the chance of getting this into the next golang release? |
It won't be part of go1.7, because go1.7 is few days away. Does the change fixes your problem? Alex |
I'm not sure how to test it. should I build the compiler by myself? |
You need to have Go install from source - see https://golang.org/doc/install/source for instructions. Once you have Go git repo, you should go to https://go-review.googlesource.com/#/c/26670/ and click "Download" button in the right top corner, Copy long command listed next to "Checkout" into your clipboard. Paste the command into your command line (while you current directory is somewhere inside of Go repo). Run the command to update the source. Then rebuild Go again. Alex |
Thanks. Not sure if I'll have time this week, but will try to test this some day |
Hey, It seems to work! |
Thanks for checking. Alex |
Hello everyone, I've prepared a GitHub Gist and a set of Videos illustrating the whole process from installing a C/Fortran based tool named LAPACK, it's connection with Go, the patching process, and the successful execution. The issue (before the patch with Go1.6.3 on Windows) is illustrated here After the patch, the code works as seen here Thanks again Alex and everyone. |
@alexbrainman Any plans on this getting released? I am facing the same issue C:/Program Files/mingw-w64/x86_64-6.2.0-posix-seh-rt_v5-rev1/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/6.2.0/../../../../x86_64-w64-mingw32/lib/../lib/libntdll.a(dkbgs01971.o).idata$5+0x0): multiple definition of Adding //#cgo LDFLAGS: -Wl,--allow-multiple-definition resolved this but brought up something else C:\Go\pkg\tool\windows_amd64\link.exe: running gcc failed: exit status 1 Your patch worked perfectly fine. Any workarounds for this time being? |
@shethchintan7 This issue is closed. The fix will be in the next Go release, 1.8, scheduled for February 1, 2017. The first problem you mention should be fixed on tip. Please open a separate issue for the second problem. We will probably need a way to reproduce the error ourselves. |
@ianlancetaylor This patch fixes the second issue also |
The text was updated successfully, but these errors were encountered: