Skip to content

Simple helloworld binary on windows,darwin and fedora is about 1.2M but on CentOS 5.7 it is only 223K. #3181

@tjyang

Description

@tjyang
I was assuming there will be an effort to reduce generated binary size later but I don't
understand why same weekly go src generated go compiler produce smaller binary file on
CentOS 5.7 ?

What steps will reproduce the problem?
1. helloworld is 1.2M on win 7.
C:\goweekly\gocode\src\hello>go build -x helloworld.go
WORK=C:\Users\aty010\AppData\Local\Temp\go-build072947126
mkdir -p $WORK\_\helloworld\_obj\
cd $GOROOT\gocode\src\hello/.
$GOROOT\pkg\tool\windows_386\8g.exe -o $WORK\_\helloworld\_obj\_go_.8 -p _/hello
world -I $WORK $GOROOT\gocode\src\hello\helloworld.go
$GOROOT\pkg\tool\windows_386\pack.exe grc $WORK\_\helloworld.a $WORK\_\helloworl
d\_obj\_go_.8
$GOROOT\pkg\tool\windows_386\8l.exe -o $WORK\_\helloworld\_obj\a.out.exe -L $WOR
K $WORK\_\helloworld.a
cp $WORK\_\helloworld\_obj\a.out.exe helloworld.exe

C:\goweekly\gocode\src\hello>ls -rt
helloworld.go  helloworld.exe

C:\goweekly\gocode\src\hello>ls -lrt
total 598
-rw-r--r--    1 ATY010   Administ       75 Feb  3 13:53 helloworld.go
-rwxr-xr-x    1 ATY010   Administ  1222144 Mar  3 23:01 helloworld.exe

C:\goweekly\gocode\src\hello>go version
go version weekly.2012-02-22 +eb997f446b2e

C:\goweekly\gocode\src\hello>


2. helloworld is 1.2M on fedora 16.
[weekly@640m hw]$ cat /etc/redhat-release
Fedora release 16 (Verne)
[weekly@640m hw]$

[weekly@640m hw]$ gcc -v
Using built-in specs.
COLLECT_GCC=/usr/bin/gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/i686-redhat-linux/4.6.2/lto-wrapper
Target: i686-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man
--infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla
--enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release
--with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions
--enable-gnu-unique-object --enable-linker-build-id
--enable-languages=c,c++,objc,obj-c++,java,fortran,ada,go,lto --enable-plugin
--enable-java-awt=gtk --disable-dssi
--with-java-home=/usr/lib/jvm/java-1.5.0-gcj-1.5.0.0/jre --enable-libgcj-multifile
--enable-java-maintainer-mode --with-ecj-jar=/usr/share/java/eclipse-ecj.jar
--disable-libjava-multilib --with-ppl --with-cloog --with-tune=generic --with-arch=i686
--build=i686-redhat-linux
Thread model: posix
gcc version 4.6.2 20111027 (Red Hat 4.6.2-1) (GCC)
[weekly@640m hw]$ ls -l hw*
-rwxrwxr-x  1 weekly weekly 1261540 Mar  3 22:41 hw
-rw-rw-r--. 1 weekly weekly      81 Feb  7 17:29 hw.go
[weekly@640m hw]$ pwd
/home/weekly/gocode/src/hw
[weekly@640m hw]$

What is the expected output?



[root@learn hw]# go build -x helloworld.go
WORK=/tmp/go-build828264604
mkdir -p $WORK/_/helloworld/_obj/
cd $GOROOTcode/src/hw/.
$GOROOT/pkg/tool/linux_386/8g -o $WORK/_/helloworld/_obj/_go_.8 -p _/helloworld -I $WORK
$GOROOTcode/src/hw/helloworld.go
$GOROOT/pkg/tool/linux_386/pack grc $WORK/_/helloworld.a $WORK/_/helloworld/_obj/_go_.8
$GOROOT/pkg/tool/linux_386/8l -o $WORK/_/helloworld/_obj/a.out -L $WORK
$WORK/_/helloworld.a
cp $WORK/_/helloworld/_obj/a.out helloworld
[root@learn hw]# ls -lrt
total 232
-rw-r--r-- 1 root root    272 Mar  3 20:39 helloworld.go
-rwxr-xr-x 1 root root 227865 Mar  3 20:51 helloworld
[root@learn hw]# ./helloworld
hello, world
[root@learn hw]# pwd
/root/gocode/src/hw
[root@learn hw]# pwd
/root/gocode/src/hw
[root@learn hw]# go version
go version weekly.2012-02-22 +96bd78e7d35e
[root@learn hw]# cat /etc/redhat-release
CentOS release 5.7 (Final)
[root@learn hw]# gcc -v
Using built-in specs.
Target: i386-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man
--infodir=/usr/share/info --enable-shared --enable-threads=posix
--enable-checking=release --with-system-zlib --enable-__cxa_atexit
--disable-libunwind-exceptions --enable-libgcj-multifile
--enable-languages=c,c++,objc,obj-c++,java,fortran,ada --enable-java-awt=gtk
--disable-dssi --disable-plugin --with-java-home=/usr/lib/jvm/java-1.4.2-gcj-1.4.2.0/jre
--with-cpu=generic --host=i386-redhat-linux
Thread model: posix
gcc version 4.1.2 20080704 (Red Hat 4.1.2-51)
[root@learn hw]#

3. helloworld binary on Darwin is 1.3M.

imac:hello weekly$ go build -x helloworld.go
WORK=/tmp/go-build930742753
mkdir -p $WORK/_/helloworld/_obj/
cd $GOROOTcode/src/hello/.
$GOROOT/pkg/tool/darwin_amd64/6g -o $WORK/_/helloworld/_obj/_go_.6 -p _/helloworld -I
$WORK $GOROOTcode/src/hello/helloworld.go
$GOROOT/pkg/tool/darwin_amd64/pack grc $WORK/_/helloworld.a
$WORK/_/helloworld/_obj/_go_.6
$GOROOT/pkg/tool/darwin_amd64/6l -o $WORK/_/helloworld/_obj/a.out -L $WORK
$WORK/_/helloworld.a
cp $WORK/_/helloworld/_obj/a.out helloworld
imac:hello weekly$ ls -lrt
total 2520
-rw-r--r--  1 weekly  staff       82 Mar  3 23:11 helloworld.go
-rwxr-xr-x  1 weekly  staff  1282064 Mar  3 23:11 helloworld
imac:hello weekly$ go version
go version weekly.2012-02-22 +96bd78e7d35e
imac:hello weekly$

What do you see instead?


Which compiler are you using (5g, 6g, 8g, gccgo)?


Which operating system are you using?


Which revision are you using?  (hg identify)


Please provide any additional information below.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions