-
Notifications
You must be signed in to change notification settings - Fork 18k
cmd/link: linking github.com/hashicorp/packer takes >2gb of ram #32094
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
Comments
Hello @lyda thank you for reporting this issue and welcome to the Go project! I'll page some experts about this @ianlancetaylor @randall77 @josharian @aclements, but am not sure if we should triage this for Go1.13 or Go1.14? |
Thanks. And no worries about versions, whichever version makes sense. I was using the one users of FreeBSD are likely to use. Note, I provided a simple terraform config to make it easier to reproduce. Finding the right FreeBSD AMI and navigating AWS if you don't know it is a pain. So the terraform config is just there to make it easier for you to get a test machine to try it on. You can get the same outcome on a similarly sized non-AWS VM, I just happened to be setting up an AWS instance at the time. The base issue is memory usage in linking. The packer project seems to present an example body of code that takes what seems like an excessive amount of ram to link. I think the changed title is a bit misleading because the issue really isn't with terraform. It's merely a convenience I provided to make people's lives easier in reproducing the issue. And I only included packer in the title because that's what I was compiling - I suspect packer is hardly the only code base where this issue occurs but I have not tried compiling a bunch of Go projects to prove that. |
Thank you @lyda! I've updated it to "cmd/compile: out of memory on t2.small when linking/building with less than 1.5GB of RAM", please feel free to modify it. You have access too to update the title :) |
I tried doing cc @thanm and @cherrymui who have been working on linker memory reductions I'm going to tentatively mark this as 1.13, in case either of them sees something easy and safe to do here, inspired particularly by linking packer. It is highly likely this will get punted to 1.14, though. |
2.13 looks promising - just need to shave off .6g or so! :) |
Quick question: Does it use cgo (i.e. internal linking or external linking)? Do you build a static executable, or PIE/shared library/etc. which requires dynamic relocations? Also, how big are the inputs (object files) and the output? Thanks! |
Not really sure.
It's made with this Makefile. It includes a lot, but I think go.mk is the relevant one. |
It looks like the recent linker improvements fixed this issue. I tried building
I'm closing this issue, but feel free to comment if you believe it should be kept open. |
Thanks for closing the loop on this! |
What version of Go are you using (
go version
)?Using the version from ports:
Does this issue reproduce with the latest release?
I think that's the latest release, so yes.
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
As mentioned in #27739, building packer on a t2.small with around 1.5g of ram will fail. A full terraform example is here and will reproduce the problem.
What did you expect to see?
I expected packer to be linked.
What did you see instead?
The Go compiler crashed at the link stage. If you follow the terraform example and upgrade to
t2.medium
, you'll see it finally succeed - it will have 3.8g of ram available (check withvmstat
).The text was updated successfully, but these errors were encountered: