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

proposal: cmd/compile: refactor compiler and linker to be libraries #26384

Closed
dave opened this issue Jul 14, 2018 · 2 comments
Closed

proposal: cmd/compile: refactor compiler and linker to be libraries #26384

dave opened this issue Jul 14, 2018 · 2 comments

Comments

@dave
Copy link
Contributor

@dave dave commented Jul 14, 2018

The Go compiler and linker are currently built as command line tools. This issue proposes refactoring so they can be used as libraries.

Benefits:

  • External applications could compile code in a server (or even browser) environment. For example a wasm mode for https://compile.jsgo.io/ and https://play.jsgo.io/. Currently this is impossible.
  • The go command line tool currently uses os/exec to spawn sub processes when it needs to compile and link. If the compiler and linker were built as libraries, this could be accomplished in-process, without the overhead of os/exec.

Problems:

  • The current code directly accesses the filesystem with the os package for reading the input code and writing the output binaries. A solution would need an abstraction layer, similar to build.Config.
  • The current codebase makes extensive use of package level variables to store state - this would need to be refactored.
  • This will increase the public surface area of the compiler API.
@agnivade agnivade changed the title cmd/compile: refactor compiler and linker to be libraries proposal: cmd/compile: refactor compiler and linker to be libraries Jul 14, 2018
@gopherbot gopherbot added this to the Proposal milestone Jul 14, 2018
@gopherbot gopherbot added the Proposal label Jul 14, 2018
@ALTree

This comment has been minimized.

Copy link
Member

@ALTree ALTree commented Jul 14, 2018

This is #15108

@dave

This comment has been minimized.

Copy link
Contributor Author

@dave dave commented Jul 14, 2018

Yes you're absolutely right. I'll close this.

@dave dave closed this Jul 14, 2018
@golang golang locked and limited conversation to collaborators Jul 14, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.