Re: [go-nuts] go build *.exe file size seems much too large

2019-04-21 Thread Ian Lance Taylor
On Sun, Apr 21, 2019 at 7:16 PM  wrote:
>
> For this simple go code, the *.exe file size is 1800 KB ...why so large 
> compared to equivalent C-compiled code ??
> package main
> import( "math"; "fmt" )
> func main() {
> fmt.Printf("\n %8.3f", math.Sin(1.2) )
> }
> Does the go generated *.exe file contain code only for math.Sin() or all the 
> functions that comprise "math"  ?
>
> Obviously there much more in the go *.exe file because of "fmt", but the 
> basic question still is why is the go *.exe file so large ??
> In addition to Sin() and Printf() what else is contained in the go *.exe file 
> ??

In addition to what other people said, Go programs are statically
linked by default, while C++ programs are dynamically linked by
default.  Try comparing the size of "cc -static".  Go is still bigger,
but not quite as much.

Ian

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [go-nuts] go build *.exe file size seems much too large

2019-04-21 Thread andrey mirtchovski
the go runtime (bare, nothing else) is about 1.1MB now. the "fmt"
package brings almost a MB of dependencies including 800 or so
unicode-related functions (names/symbols), reflection, etc. the math
package brings almost nothing: 11 symbols.

-8<
$ cat t.go
package main

func main() {
}
$ go build t.go && ls -lh t
-rwxr-xr-x  1 a  s   1.1M 21 Apr 20:35 t
$ cat > t.go
package main
import "fmt"
func main() {
fmt.Println("test")
}
$ go build t.go && ls -lh t
-rwxr-xr-x  1 a  s   2.0M 21 Apr 20:36 t
$ cat > t.go
package main
import ("fmt"; "math")
func main() { fmt.Printf("\n %8.3f", math.Sin(1.2) ) }
$ go build t.go && ls -lh t
-rwxr-xr-x  1 a  s   2.0M 21 Apr 20:38 t
>8--

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [go-nuts] go build *.exe file size seems much too large

2019-04-21 Thread Marcin Romaszewicz
It contains the Go runtime - memory manager, goroutine scheduler, all that.

-- Marcin


On Sun, Apr 21, 2019 at 7:16 PM  wrote:

> For this simple go code, the *.exe file size is 1800 KB ...why so large
> compared to equivalent C-compiled code ??
> package main
> import( "math"; "fmt" )
> func main() {
> fmt.Printf("\n %8.3f", math.Sin(1.2) )
> }
> Does the go generated *.exe file contain code only for math.Sin() or all
> the functions that comprise "math"  ?
>
> Obviously there much more in the go *.exe file because of "fmt", but the
> basic question still is why is the go *.exe file so large ??
> In addition to Sin() and Printf() what else is contained in the go *.exe
> file ??
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to golang-nuts+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[go-nuts] go build *.exe file size seems much too large

2019-04-21 Thread lgodio2
For this simple go code, the *.exe file size is 1800 KB ...why so large 
compared to equivalent C-compiled code ??
package main
import( "math"; "fmt" )
func main() {
fmt.Printf("\n %8.3f", math.Sin(1.2) )
}
Does the go generated *.exe file contain code only for math.Sin() or all 
the functions that comprise "math"  ?

Obviously there much more in the go *.exe file because of "fmt", but the 
basic question still is why is the go *.exe file so large ??
In addition to Sin() and Printf() what else is contained in the go *.exe 
file ??
   

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.