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
cgo: invalid reloc in gozk #1334
Labels
Comments
One problem in the log (the nm errors) is a known problem that keeps gotest from working on cgo packages. http://golang.org/cl/3553041 should take care of that. I'm not sure about the other errors. It's possible that the nm fix will fix them too. Please try again after the nm fix goes in. (It should update this issue when I submit it.) Labels changed: added cgo. Owner changed to r...@golang.org. Status changed to Accepted. |
Noticed the patch went it (the issue didn't yet update for some reason). You indeed got rid of those errors you mention, but there are still issues. I'm attaching the new output. Attachments:
|
Synced to tip, retried, and confirmed that the output is still the same as err2.txt. Attaching _test/gozk.a. Thanks for checking. Attachments:
|
Synced to tip, applied the CL, and it's certainly looking better. I'm now getting a bunch of "not defined" errors, as per the attached output. Some data about the erroring variables: - In gozk.go they're used as e.g. C.ZOO_ASSOCIATING_STATE - In zookeeper.h, they're defined as e.g. extern ZOOAPI const int ZOO_ASSOCIATING_STATE; - In zookeeper.c, they're defined as e.g. const int ZOO_ASSOCIATING_STATE = 2; Please let me know if I can help further. Attachments:
|
It's linked into the package as a shared library. In the Makefile: CGO_LDFLAGS+=-lzookeeper_mt _cgo_import.c does not mention ZOO_ASSOCIATING_STATE. Attaching both the Makefile and _cgo_import.c. Attachments:
|
Can reproduce this latest bug by changing stdio/file.go to say package stdio /* #include <stdio.h> #include <stdlib.h> #include <sys/stat.h> #include <errno.h> #include <resolv.h> char* greeting = "hello, world"; */ import "C" import "unsafe" type File C.FILE var Stdout = (*File)(C.stdout) var Stderr = (*File)(C.stderr) var res = &C._res The solution will be to make the generation of _cgo_main.c part of cgo instead of pushing it into the shell script where it currently is. For hello, something like int main() { return 0; } int crosscall2; extern char __stderrp[]; void *mystderrp = __stderrp; extern char _res[]; void *mystderrx = _res; extern char greeting[]; void *mygreeting = greeting; creates a working binary (refers to _res but not greeting, which is internal). I am waiting for some other cgo changes to get reviewed and submitted first but I think we're getting there. |
This issue was closed by revision 6c6d530. Status changed to Fixed. |
I've hacked together a _cgo_main.c to overcome the above issue, and all tests pass with gozk: gopack grc _test/gozk.a _gotest_.6 _cgo_defun.6 _cgo_import.6 gozk.cgo2.o _cgo_export.o ZooKeeper test server directory: /tmp/gocheck-816681689/0 ZooKeeper test server port: 21812 OK: 34 passed PASS Thanks a lot for the awesome work on the new cgo Russ. |
This issue was closed.
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Attachments:
The text was updated successfully, but these errors were encountered: