Skip to content

Commit

Permalink
Merge #60149
Browse files Browse the repository at this point in the history
60149: build: cross-compile when building roachtest tools r=stevendanna a=stevendanna

The roachtest, workload, and roachprod tools might need to run on machines 
with older glibcs than the builder when running the roachtests.  By
using mkrelease, we ensure that theses are built using the
cross-compilation environment that supports older glibc versions. This
avoids us having to keep the builder image in line with other images
we might use for testing.

Release note: None

Co-authored-by: Steven Danna <[email protected]>
  • Loading branch information
craig[bot] and stevendanna committed Feb 10, 2021
2 parents dfaefec + 110fa0d commit 355fe0b
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 38 deletions.
75 changes: 38 additions & 37 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -250,10 +250,6 @@ endif

$(info GOPATH set to $(GOPATH))

# We install our vendored tools to a directory within this repository to avoid
# overwriting any user-installed binaries of the same name in the default GOBIN.
GO_INSTALL := GOBIN='$(abspath bin)' GOFLAGS= $(GO) install

# Prefer tools we've installed with go install and Yarn to those elsewhere on
# the PATH.
export PATH := $(abspath bin):$(PATH)
Expand Down Expand Up @@ -319,12 +315,6 @@ ifeq (, $(shell which bazel))
$(info $(yellow)Warning: 'bazel' not found (`brew install bazel` for macs)$(term-reset))
endif

# Force vendor directory to rebuild.
.PHONY: vendor_rebuild
vendor_rebuild: bin/.submodules-initialized
$(GO_INSTALL) -v -mod=mod github.com/goware/modvendor
./build/vendor_rebuild.sh

# Tell Make to delete the target if its recipe fails. Otherwise, if a recipe
# modifies its target before failing, the target's timestamp will make it appear
# up-to-date on the next invocation of Make, even though it is likely corrupt.
Expand Down Expand Up @@ -367,32 +357,6 @@ pkg/ui/yarn.installed: pkg/ui/package.json pkg/ui/yarn.lock pkg/ui/yarn.protobuf
rm -rf pkg/ui/node_modules/@types/node
touch $@

# Update the git hooks and install commands from dependencies whenever they
# change.
# These should be synced with `./pkg/cmd/import-tools/main.go`.
bin/.bootstrap: $(GITHOOKS) vendor/modules.txt | bin/.submodules-initialized
@$(GO_INSTALL) -v \
github.com/client9/misspell/cmd/misspell \
github.com/cockroachdb/crlfmt \
github.com/cockroachdb/gostdlib/cmd/gofmt \
github.com/cockroachdb/gostdlib/x/tools/cmd/goimports \
github.com/cockroachdb/stress \
github.com/goware/modvendor \
github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway \
github.com/kevinburke/go-bindata/go-bindata \
github.com/kisielk/errcheck \
github.com/mattn/goveralls \
github.com/mibk/dupl \
github.com/mmatczuk/go_generics/cmd/go_generics \
github.com/pseudomuto/protoc-gen-doc/cmd/protoc-gen-doc \
github.com/wadey/gocovmerge \
golang.org/x/lint/golint \
golang.org/x/perf/cmd/benchstat \
golang.org/x/tools/cmd/goyacc \
golang.org/x/tools/cmd/stringer \
golang.org/x/tools/go/analysis/passes/shadow/cmd/shadow \
honnef.co/go/tools/cmd/staticcheck
touch $@

IGNORE_GOVERS :=

Expand Down Expand Up @@ -453,6 +417,10 @@ xcmake-flags += -DCMAKE_SYSTEM_NAME=$(XCMAKE_SYSTEM_NAME) -DCMAKE_C_COMPILER=$(X
override xgo := GOFLAGS= GOOS=$(XGOOS) GOARCH=$(XGOARCH) CC=$(XCC) CXX=$(XCXX) $(xgo)
endif

# We install our vendored tools to a directory within this repository to avoid
# overwriting any user-installed binaries of the same name in the default GOBIN.
GO_INSTALL := GOBIN='$(abspath bin)' GOFLAGS= $(xgo) install

C_DEPS_DIR := $(abspath c-deps)
JEMALLOC_SRC_DIR := $(C_DEPS_DIR)/jemalloc
PROTOBUF_SRC_DIR := $(C_DEPS_DIR)/protobuf
Expand Down Expand Up @@ -584,6 +552,12 @@ vendor/github.com/knz/go-libedit/unix/zcgo_flags_extra.go: Makefile | bin/.submo
@echo '// #cgo !windows LDFLAGS: -ledit -lncurses' >> $@
@echo 'import "C"' >> $@

# Force vendor directory to rebuild.
.PHONY: vendor_rebuild
vendor_rebuild: bin/.submodules-initialized
$(GO_INSTALL) -v -mod=mod github.com/goware/modvendor
./build/vendor_rebuild.sh

# BUILD ARTIFACT CACHING
#
# We need to ensure that changes to a dependency's configure or CMake flags
Expand Down Expand Up @@ -1747,11 +1721,38 @@ bin/workload bin/docgen bin/execgen bin/roachtest $(logictest-bins): $(SQLPARSER
bin/workload bin/docgen bin/roachtest $(logictest-bins): $(LIBPROJ) $(CGO_FLAGS_FILES)
bin/roachtest $(logictest-bins): $(C_LIBS_CCL) $(CGO_FLAGS_FILES) $(OPTGEN_TARGETS)

# Update the git hooks and install commands from dependencies whenever they
# change.
# These should be synced with `./pkg/cmd/import-tools/main.go`.
bin/.bootstrap: $(GITHOOKS) vendor/modules.txt | bin/.submodules-initialized
@$(GO_INSTALL) -v \
github.com/client9/misspell/cmd/misspell \
github.com/cockroachdb/crlfmt \
github.com/cockroachdb/gostdlib/cmd/gofmt \
github.com/cockroachdb/gostdlib/x/tools/cmd/goimports \
github.com/cockroachdb/stress \
github.com/goware/modvendor \
github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway \
github.com/kevinburke/go-bindata/go-bindata \
github.com/kisielk/errcheck \
github.com/mattn/goveralls \
github.com/mibk/dupl \
github.com/mmatczuk/go_generics/cmd/go_generics \
github.com/pseudomuto/protoc-gen-doc/cmd/protoc-gen-doc \
github.com/wadey/gocovmerge \
golang.org/x/lint/golint \
golang.org/x/perf/cmd/benchstat \
golang.org/x/tools/cmd/goyacc \
golang.org/x/tools/cmd/stringer \
golang.org/x/tools/go/analysis/passes/shadow/cmd/shadow \
honnef.co/go/tools/cmd/staticcheck
touch $@

$(bins): bin/%: bin/%.d | bin/prereqs bin/.submodules-initialized
@echo go install -v $*
bin/prereqs $(if $($*-package),$($*-package),./pkg/cmd/$*) > $@.d.tmp
mv -f $@.d.tmp $@.d
@$(GO_INSTALL) -v $(if $($*-package),$($*-package),./pkg/cmd/$*)
$(GO_INSTALL) -v $(GOFLAGS) $(GOMODVENDORFLAGS) -tags '$(TAGS)' -ldflags '$(LINKFLAGS)' $(if $($*-package),$($*-package),./pkg/cmd/$*)

$(testbins): bin/%: bin/%.d | bin/prereqs $(SUBMODULES_TARGET)
@echo go test -c $($*-package)
Expand Down
2 changes: 1 addition & 1 deletion build/teamcity-nightly-roachtest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ chmod o+rwx "${artifacts}"
# Disable global -json flag.
export PATH=$PATH:$(GOFLAGS=; go env GOPATH)/bin

make bin/workload bin/roachtest bin/roachprod > "${artifacts}/build.txt" 2>&1 || cat "${artifacts}/build.txt"
build/builder/mkrelease.sh amd64-linux-gnu bin/workload bin/roachtest bin/roachprod > "${artifacts}/build.txt" 2>&1 || cat "${artifacts}/build.txt"

# Set up Google credentials. Note that we need this for all clouds since we upload
# perf artifacts to Google Storage at the end.
Expand Down
1 change: 1 addition & 0 deletions pkg/cmd/roachtest/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ func findBinaryOrLibrary(binOrLib string, name string) (string, error) {
dirs := []string{
filepath.Join(gopath, "/src/github.com/cockroachdb/cockroach/"),
filepath.Join(gopath, "/src/github.com/cockroachdb/cockroach", binOrLib+suffix),
filepath.Join(gopath, "/src/github.com/cockroachdb/cockroach", binOrLib),
filepath.Join(os.ExpandEnv("$PWD"), binOrLib+suffix),
}
for _, dir := range dirs {
Expand Down

0 comments on commit 355fe0b

Please sign in to comment.