gokrazy / tools

this repository contains the gok CLI tool of gokrazy
https://gokrazy.org
BSD 3-Clause "New" or "Revised" License
50 stars 27 forks source link

Strip symbols from executable file to reduce size #8

Closed tetsu-koba closed 4 years ago

tetsu-koba commented 6 years ago

Strip symbols from executable file to reduce size by adding ldflags to "go install" and "go build" command.

Before this commit

$ ls -lh total 15M -r--r--r-- 1 koba koba 2.9M Mar 29 05:33 dhcp -r--r--r-- 1 koba koba 8.8M Mar 29 05:33 init -r--r--r-- 1 koba koba 3.3M Mar 29 05:33 ntp

15.0 MB in total

After this commit $ ls -lh total 9.0M -r--r--r-- 1 koba koba 1.7M Mar 29 05:47 dhcp -r--r--r-- 1 koba koba 5.4M Mar 29 05:47 init -r--r--r-- 1 koba koba 2.0M Mar 29 05:47 ntp

9.1 MB in total

stapelberg commented 6 years ago

Can you confirm that the only feature we’ll lose by omitting the symbol table/debug information is support in external debuggers (e.g. gdb)? I have already verified /debug/pprof/{goroutine,heap} still works, but perhaps I missed something.

Even if yes, we still need to put this behind a flag. I haven’t made up my mind yet as to whether the flag should default to omitting the symbol table/debug info or not. Making it default to that behavior would be a departure from the official go toolchain default, which would at least be unexpected for many users.

Given that we’re talking about a few megabytes on SD cards which are measured in two-digit gigabyte numbers these days, what’s the motivation for this change?

tetsu-koba commented 6 years ago

Thank you for taking a look for my patch. Gokrazy is very impressive for me. I agree that debugger could confuse without symbols. There is trade off. So I agree a flag switch. I found my patch is too straight forward.

Motivation of my change is a trial for minimum size system. Yes, SD card is huge enough size. I will try network boot without SD card. Then smaller size makes sense. Let me investigate in my local fork.