why does the Go compiler produce big binary files?
For example after compiling following code, I get a 1.8 MB exec file
package main
import "fmt"
func main(){
fmt.Println("Hello World")
}
I tested the above code on both Ubuntu and Win7 and result is the same!
I also wrote a bigger program with +70 lines of code and the resulting binary file was surprisingly again 1.8 MB (actually there were a few bytes difference). I'm wondering what is dumped into the binary file by the Go compiler.
Why is my trivial program such a large binary? (from the Go Programming Language FAQ):
The linkers in the gc tool chain (5l, 6l, and 8l) do static linking. All Go binaries therefore include the Go run-time, along with the run-time type information necessary to support dynamic type checks, reflection, and even panic-time stack traces.
A simple C "hello, world" program compiled and linked statically using gcc on Linux is around 750 kB, including an implementation of printf. An equivalent Go program using fmt.Printf is around 1.2 MB, but that includes more powerful run-time support.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With