-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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
ponies: embed Go in C program #2790
Comments
Comment 2 by lewis@squareup.com: I am interested in this as well. I'd like to use Go to make PostgreSQL extensions among other things. It provides a unique balance between simplicity of scripting languages and performance of a compiled language. To me, go seems like it's ideal for implementing database features. |
Elias Naur is working on this: https://golang.org/cl/6822078 |
Updated implementation (and linux/amd64 implementation) at https://groups.google.com/forum/?fromgroups#!topic/golang-nuts/zmjXkGrEx6Q |
Comment 8 by jwatte@imvu.com: Go might be able to do something here. LUA is too simplistic, and the syntax is wonky. V8 is too heavy-weight, and single-threaded. Python is single-threaded. A good embedding interface could have significant value! |
CL https://golang.org/cl/9738047 references this issue. |
I just wrote a blog post about this: Using Go in mobile apps, Part 1: Calling Go functions from C++ |
@ianlancetaylor Thanks for posting the document. It appears that adding |
Thanks for your interest. You should coordinate with Michael Hudson-Doyle michael.hudson@canonical.com. He is the only person I know to be working in this area at the moment. |
Does anyone know if there has been any progress on any of these ideas? I'm specifically interested in what's described in the doc @ianlancetaylor mentioned as Go code linked into, and called from, a non-Go program. I have a large(ish) C++ app and I'd like to reimplement part of it in Go as a static lib and just link it in using my current build process. |
Michael Hudson-Doyle has been working on shared libraries. I plan to work on linking Go into a C program soon but I haven't started yet. |
Yes, I'm making progress on shared libraries, and also understanding how awkward doing dlopen-style embedding is going to be :-) It doesn't feel like embedding Go as a static library should be all that hard? cgo_static_export the right things, avoid generating a entrypoint, generate a .o as for host linking and then don't invoke the host linker? |
Oh, I guess you have to worry about TLS a bit. |
Thank you @ianlancetaylor - I look forward to it! If you need some help testing when you get to that point please let me know. |
@asmaloney I had an idea about how to do this, though I haven't tried it out yet.
This method has limitations – for example, I'm pretty sure C code could never call into Go code from a non-Go thread. |
Isn't this already implemented using the |
Yes, this should now work on tip, using -buildmode=c-archive or -buildmode=c-shared. They don't work on all systems, but let's use separate issues to track specific systems where they need work. |
Are there plans to support freebsd (if someone doesn't feel like using the linux compatability layer and 32-bit binaries)? |
@eatonphil We try not to hold discussions on closed issues. See https://golang.org/wiki/Questions . I would be happy to review patches adding support for FreeBSD. It shouldn't be hard. As I said above, you can also open a separate issue for that. |
Sorry about that! I misread the "Open" sign above my comment as referring to this thread. I'll open a new issue. |
by daniel@heroku.com:
The text was updated successfully, but these errors were encountered: