Re:Go: Planning the 1.5 release
by rurounijones on Tuesday December 02, 2014 @05:16AM
(#8686442)
>> Imagine each binary being 5 mb on average and multiply that by 100.
> I don't think it's a factor of 100 times, that seems a bit outrageous.
I think he means 100 utilities all weighing in at 5mb
> Are you sure it's because they are statically compiled? Not because each binary has DWARF debug symbols in it so that there are useful stack traces?
Removing DWARF information with -ldflags -w reduces the size of the binary by 20%. The binary is 1.8MB originally...
$ go build hello.go
$ wc -c hello
1806192 hello
$ go build -ldflags -w hello.go
$ wc -c hello
1408880 hello
the rest is pretty much all runtime, the hello world itself should take about 10k, that's more or less the size of the C or dynamically linked Rust versions (Rust also uses static linking by default, and the hello world is 300k in that case)to see how much the runtime contributes to the size of the binary use an empty main. for hello world you bring in the fmt package which is a relative heavyweight:
$ cat > t.go
package main
func main() {}
$ go build t.go
$ wc -c t
623280 t
$ nm t | wc -l
1029
$ cat > t.go
package main
import "fmt"
func main() { fmt.Println("hello world") }
$ go build t.go
$ nm t | wc -l
2541
Are you sure it's because they are statically compiled?
Not because each binary has DWARF debug symbols in it so that there are useful stack traces?
> Imagine each binary being 5 mb on average and multiply that by 100.
I don't think it's a factor of 100 times, that seems a bit outrageous.