You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
My application executes a lot of small Go scripts programmatically. These scripts reference the standard library.
My goal is to precompile the standard library (std) so that it is never compiled again until I update the Go version. That would help me speed up the small scripts execution.
However when I do go install std or go build std, the compilation results are placed into GOCACHE folder. So essentially, the std gets cached rather then precompiled. And with time this cache expires and I have to run go install std again.
I believe it should be possible to precompile the std library in Go as in all other compiled languages that I'm familiar with. However I failed to find a way to do it in the documentation, github issues or SO threads. Please, help me to see what I'm missing here.
What did you see happen?
Std library is cached in GOCACHE folder, and this cache expires with time even if Go version remains the same.
What did you expect to see?
Std library is precompiled and saved in GOPATH/pkg or elsewhere, where it won't be compiled ever again until I update the Go version.
The text was updated successfully, but these errors were encountered:
The standard library was intentionally moved to the cache in order to reduce distribution size (see #47257), but note that even before then the object files in the cache were sometimes not used (for example, due to the use of different build flags that affect the compiled code).
Also note that any standard-library packages you actually use should have their access times updated (and should therefore not be remove from the cache when it is trimmed).
At any rate: you can get the old behavior by setting GODEBUG=installgoroot=all in your environment.
bcmills
changed the title
Standard library gets cached in GOCACHE folder via 'go build/install std' and the cache expires with time
cmd/go: Standard library gets cached in GOCACHE folder via 'go build/install std' and the cache expires with time
Jan 22, 2024
Go version
go version go1.21.6 linux/amd64
Output of
go env
in your module/workspace:What did you do?
My application executes a lot of small Go scripts programmatically. These scripts reference the standard library.
My goal is to precompile the standard library (std) so that it is never compiled again until I update the Go version. That would help me speed up the small scripts execution.
However when I do
go install std
orgo build std
, the compilation results are placed into GOCACHE folder. So essentially, the std gets cached rather then precompiled. And with time this cache expires and I have to rungo install std
again.I believe it should be possible to precompile the std library in Go as in all other compiled languages that I'm familiar with. However I failed to find a way to do it in the documentation, github issues or SO threads. Please, help me to see what I'm missing here.
What did you see happen?
What did you expect to see?
Std library is precompiled and saved in GOPATH/pkg or elsewhere, where it won't be compiled ever again until I update the Go version.
The text was updated successfully, but these errors were encountered: