Skip to content

cmd/compile: go build takes too long and creates huge executable with big static array #24724

@mariecurried

Description

@mariecurried

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

go version go1.10.1 windows/amd64

Does this issue reproduce with the latest release?

Yes.

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

set GOARCH=amd64
set GOBIN=
set GOEXE=.exe
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOOS=windows
set GORACE=
set GOROOT=C:\Go
set GOTMPDIR=
set GOTOOLDIR=C:\Go\pkg\tool\windows_amd64
set GCCGO=gccgo
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -fmessage-length=0 -fdebug-prefix-map=...

What did you do and what happened?

I'm learning Go and I decided to make a few little programs to get comfortable with the language. Usually the executables are ~1MB. But when I tried to compile the following program, the compilation took a long time and the executable was ~800MB.
https://play.golang.org/p/EK8zDu5vVQN

What did you expect to see?

I expected the executable to be ~1MB, because I tried a similar program, but without the explicit initialization of the first element of the array to 1, and it worked fine. Like the other times, the executable was ~1MB.
https://play.golang.org/p/LM9TBaQcRIo

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