cmd/link: optimize init code, make it generate less asm code and make binary smaller and faster #22387
Labels
compiler/runtime
Issues related to the Go compiler and/or runtime.
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Suggested
Issues that may be good for new contributors looking for work to do.
Milestone
Please answer these questions before submitting your issue. Thanks!
What version of Go are you using (
go version
)?go version go1.9 darwin/amd64
Does this issue reproduce with the latest release?
yes
What operating system and processor architecture are you using (
go env
)?GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/a/go"
GORACE=""
GOROOT="/usr/local/go"
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/m9/qtbxkp6s3p96fk54rln7qhj80000gp/T/go-build753370285=/tmp/go-build -gno-record-gcc-switches -fno-common"
CXX="clang++"
CGO_ENABLED="1"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
What did you do?
https://play.golang.org/p/Ia27Pa9Gxs
What did you expect to see?
The init call tree should be ordered and flat.
The empty init functions should be remove.
main.Init direct call all init functions in the correct order(this one can be compute from import tree):
What did you see instead?
main.Init() just call strconv.init() os.init() which are defined in main package.
os.init call io.init, runtime.init, sync.init, time.init, internal/poll.init .
The panic message stack in some deep package like
runtime.init
also complex with os.init and main.Init(I just found why it is from this asm code)ps: This program import tree map from go1.9:
The text was updated successfully, but these errors were encountered: