Skip to content

build: bootstrap.bash builds a lot of useless stuff #17219

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

Closed
bradfitz opened this issue Sep 24, 2016 · 6 comments
Closed

build: bootstrap.bash builds a lot of useless stuff #17219

bradfitz opened this issue Sep 24, 2016 · 6 comments
Labels
Builders x/build issues (builders, bots, dashboards) FrozenDueToAge
Milestone

Comments

@bradfitz
Copy link
Contributor

While cross-compiling ARM for faster builders (#17105) in a mode similar to src/bootstrap.bash, I see many useless things being built:

net/http (http2, hpack, httplex, ...)
A bunch of packages never needed by cmd/compile, cmd/link, etc.

It'd be nice to have a mode which only built the bare minimum to build the cross-compiled tools.

@bradfitz bradfitz added the Builders x/build issues (builders, bots, dashboards) label Sep 24, 2016
@bradfitz bradfitz added this to the Unreleased milestone Sep 24, 2016
@bradfitz bradfitz self-assigned this Sep 24, 2016
@bradfitz
Copy link
Contributor Author

For example, I'm thinking of something like this, behind a flag or environment variable perhaps:

diff --git a/src/make.bash b/src/make.bash
index 1a1412a..7db2123 100755
--- a/src/make.bash
+++ b/src/make.bash
@@ -165,7 +165,7 @@ if [ "$GOHOSTARCH" != "$GOARCH" -o "$GOHOSTOS" != "$GOOS" ]; then
        # CC_FOR_TARGET is recorded as the default compiler for the go tool. When building for the host, however,
        # use the host compiler, CC, from `cmd/dist/dist env` instead.
        CC=$CC GOOS=$GOHOSTOS GOARCH=$GOHOSTARCH \
-               "$GOTOOLDIR"/go_bootstrap install -gcflags "$GO_GCFLAGS" -ldflags "$GO_LDFLAGS" -v std cmd
+               "$GOTOOLDIR"/go_bootstrap install -gcflags "$GO_GCFLAGS" -ldflags "$GO_LDFLAGS" -v cmd/compile cmd/link cmd/asm
        echo
 fi

That seems to cut down user CPU from 3.5 minutes to 2.5 minutes, and sys CPU from 14.5s to 11.5s.

Note sure if cmd/compile cmd/link cmd/asm is sufficient, though.

/cc @ianlancetaylor @minux @mdempsky

@minux
Copy link
Member

minux commented Sep 25, 2016 via email

@bradfitz
Copy link
Contributor Author

@minux, doesn't seem to be. cmd/go is needed by bootstrap.bash (for avoidable reasons), but isn't needed by make.bash, which the builders use.

The cross-compiling builder does this instead of using bootstrap.bash:

        remoteErr, err := kubeBC.Exec("/bin/bash", buildlet.ExecOpts{
                SystemLevel: true,
                Args: []string{
                        "-c",
                        "cd $WORKDIR/go/src && " +
                                "./make.bash && " +
                                "cd .. && " +
                                "mv bin/*_*/* bin && " +
                                "rmdir bin/*_* && " +
                                "rm -rf pkg/linux_amd64 pkg/tool/linux_amd64 pkg/bootstrap pkg/obj",
                },
                Output: st,
                ExtraEnv: []string{
                        "GOROOT_BOOTSTRAP=/go1.4",
                        "CGO_ENABLED=1",
                        "CC_FOR_TARGET=arm-linux-gnueabihf-gcc",
                        "GOOS=" + goos,
                        "GOARCH=" + goarch,
                        "GOARM=7", // harmless if GOARCH != "arm"                                                                      
                },
                Debug: true,
        })

And I see no reason why the linux_amd64 host needs cmd/go, any networking packages (we should not use the network during the make.bash build),cmd/vet`, etc.

@minux
Copy link
Member

minux commented Sep 26, 2016 via email

@bradfitz
Copy link
Contributor Author

/cc @mdempsky for thoughts.

@bradfitz
Copy link
Contributor Author

I added a minimal output mode in f0f62fc for the Go builders. I'm happy enough with that for now.

@golang golang locked and limited conversation to collaborators May 28, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Builders x/build issues (builders, bots, dashboards) FrozenDueToAge
Projects
None yet
Development

No branches or pull requests

3 participants