Skip to content
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

make the gc public #32203

Closed
JAicewizard opened this issue May 23, 2019 · 7 comments
Closed

make the gc public #32203

JAicewizard opened this issue May 23, 2019 · 7 comments

Comments

@JAicewizard
Copy link

What version of Go are you using (go version)?

$ go version 1.12.4

What did you do?

I try to compile go code at run-time(not performance critical) and right now have to assume that the go command is available and up-to-date.

What did you expect to see?

I was hoping that there would be some kind of way to import the gc so I can compile the code from inside the program, eliminating the go dependency.

What did you see instead?

The gc is not exported but instead inside a /internal making it impossible to import and use in other programs/code-bases.

@randall77
Copy link
Contributor

What are you going to do with the compiled code? You would still need a linker to make anything useful from the result. Do you want the linker also?

Does it need to handle cgo? Then we'd need gcc bundled somehow as well.

I'm not sure we want to do this. The interface for the compiler is complicated and it's not clear we want to freeze it, as we would need to do if we made it public in the stdlib.

@JAicewizard
Copy link
Author

I'm sorry I don't 100% understand the internals of go. maybe I should replace all "compile" with "build".
so I am looking for a public interface that build a go package into a binary just like go build. looking at the internal code this seemed to be handled by the gc package but I might have been mistaken.

@AlexRouSg
Copy link
Contributor

Have you considered just packaging go with your program? Or check if go is installed and is at least version x.y.z and if not, download and extract it?

Why must it be compiled into your program?

@JAicewizard
Copy link
Author

It doesn't have to, but it would be nice. The current setup works, but it would be nice to have an always working setup that doesn't come with a "what if".

@AlexRouSg
Copy link
Contributor

Can you give specific "what ifs" or cons for the alternative solutions I described earlier that doesn't apply to a package?

@JAicewizard
Copy link
Author

I realized that it would be little use in my case, since I would still need the standard library.
But I still think that it would be really cool(I cant immediately find a use-case) to have a simple API to compile X file with access to X libraries (like /go/src but then not necessarily with stdlib).
If you want you can close this

@agnivade
Copy link
Contributor

Duplicate of #15108. Feel free to subscribe to that.

@golang golang locked and limited conversation to collaborators May 22, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants