Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/compile: build in linux amd64 comes out 42M while in windows 27.4M #21036

Closed
yingqin678 opened this issue Jul 16, 2017 · 9 comments

Comments

Projects
None yet
4 participants
@yingqin678
Copy link

commented Jul 16, 2017

Please answer these questions before submitting your issue. Thanks!

What version of Go are you using (go version)?

1.8.3

What operating system and processor architecture are you using (go env)?

linux:
GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH=""
GORACE=""
GOROOT="/usr/local/go"
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build369711885=/tmp/go-build"
CXX="g++"
CGO_ENABLED="1"
windows:
$ go env
set GOARCH=amd64
set GOBIN=
set GOEXE=.exe
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOOS=windows
set GOPATH=D:\isource\go-workspace
set GORACE=
set GOROOT=C:\Go
set GOTOOLDIR=C:\Go\pkg\tool\windows_amd64
set GCCGO=gccgo
set CC=gcc
set GOGCCFLAGS=-m64 -mthreads -fmessage-length
set CXX=g++
set CGO_ENABLED=1
set PKG_CONFIG=pkg-config
set CGO_CFLAGS=-ID:\isource\go-workspace/inclu
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-LD:\isource\go-workspace/lib

What did you do?

i build filebeat seperately in linux and windows

What did you expect to see?

the size of binary file built in linux is smaller than 30M as in windows

What did you see instead?

in linux it came to be 42M while in windows 27.7M,
even i build across in windows to get binary file using "GOOS=linux GOARCH=amd64 go build",it still came to be 27.4M.
However i need to build in linux and the size of file smaller than 30M and i use CGO.

@ALTree ALTree changed the title go1.8.3 build in linux amd64 comes out 42M while in windows 27.4M cmd/compile: build in linux amd64 comes out 42M while in windows 27.4M Jul 16, 2017

@ALTree

This comment has been minimized.

Copy link
Member

commented Jul 16, 2017

i build filebeat

What's a "filebeat"? This: https://github.com/elastic/beats/tree/master/filebeat ?

@yingqin678

This comment has been minimized.

Copy link
Author

commented Jul 16, 2017

@ALTree yeah,tag 6.0.0-alpha-2

@ALTree

This comment has been minimized.

Copy link
Member

commented Jul 16, 2017

Can you also try with go1.9beta? It'll be released soon so it's a good idea to test with it.

@yingqin678

This comment has been minimized.

Copy link
Author

commented Jul 16, 2017

maybe i can try 1.9 later;however, its decided to upgrade 1.7 to 1.8 right now ,so maybe its better to find a way to solve it on 1.8??

@ALTree

This comment has been minimized.

Copy link
Member

commented Jul 16, 2017

I just checked myself, filesize is the same (43M on go1.9 too).

@ALTree ALTree added this to the Go1.10 milestone Jul 16, 2017

@ALTree

This comment has been minimized.

Copy link
Member

commented Jul 16, 2017

@yingqin678 go1.8 is done. Minor releases (like go1.8.3) are used to roll out fixes for critical problems (typically security issues); it's highly unlikely that a (supposed) problem with binary sizes will be included in a new minor release for go1.8.

@ALTree

This comment has been minimized.

Copy link
Member

commented Jul 16, 2017

go build -ldflags -s produces a 25M binary on my linux system. Could this work for you as a workaround?

@yingqin678

This comment has been minimized.

Copy link
Author

commented Jul 16, 2017

yes and thank you,we will try on it

@bradfitz

This comment has been minimized.

Copy link
Member

commented Jul 16, 2017

Sounds like this is resolved.

Existing bugs track binary sizes, so closing this specific instance.

@bradfitz bradfitz closed this Jul 16, 2017

@golang golang locked and limited conversation to collaborators Jul 16, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.