Go 1.13 needs different static linking flags
We don't need to pre-build the Go standard library or use -i flag either - Go sorts that all out for us now.
This commit is contained in:
1 parent
dd70668b89
commit
56491b35f1
2 files changed
+8
-35
No files matched your search
@@ -176,18 +176,11 @@ PUSH_ML=push_ml_weave push_ml_weaveexec push_ml_weave-kube push_ml_weave-npc
|
|||||||
|
|
||||||
WEAVE_EXPORT=weave$(ARCH_EXT).tar.gz
|
WEAVE_EXPORT=weave$(ARCH_EXT).tar.gz
|
||||||
|
|
||||||
NETGO_CHECK=@strings $@ | grep cgo_stub\\\.go >/dev/null || { \
|
|
||||||
rm $@; \
|
|
||||||
echo "\nYour go standard library was built without the 'netgo' build tag."; \
|
|
||||||
echo "To fix that, run"; \
|
|
||||||
echo " sudo go clean -i net"; \
|
|
||||||
echo " sudo go install -tags netgo std"; \
|
|
||||||
false; \
|
|
||||||
}
|
|
||||||
# The flags we are passing to go build. -extldflags -static for making a static binary,
|
# The flags we are passing to go build. -extldflags -static for making a static binary,
|
||||||
# -linkmode external for linking external C libraries into the binary, -X main.version for telling the
|
# -X main.version for telling the Go binary which version it is,
|
||||||
# Go binary which version it is, -tags netgo for enforcing the native Go DNS resolver
|
# -s -w drop symbol tables used by debuggers (not Go's internal symbol info)
|
||||||
BUILD_FLAGS=-i -ldflags "-linkmode external -extldflags -static -X main.version=$(WEAVE_VERSION)" -tags netgo
|
# -tags "osusergo netgo" to use native Go UID and DNS implementations
|
||||||
|
BUILD_FLAGS=-ldflags "-extldflags -static -X main.version=$(WEAVE_VERSION) -s -w" -tags "osusergo netgo"
|
||||||
|
|
||||||
PACKAGE_BASE=$(shell go list -e ./)
|
PACKAGE_BASE=$(shell go list -e ./)
|
||||||
|
|
||||||
@@ -216,10 +209,8 @@ ifeq ($(BUILD_IN_CONTAINER),true)
|
|||||||
# This make target compiles all binaries inside of the weaveworks/build container
|
# This make target compiles all binaries inside of the weaveworks/build container
|
||||||
# It bind-mounts the source into the container and passes all important variables
|
# It bind-mounts the source into the container and passes all important variables
|
||||||
exes $(EXES) tests lint: $(BUILD_UPTODATE)
|
exes $(EXES) tests lint: $(BUILD_UPTODATE)
|
||||||
@mkdir -p $(shell pwd)/.pkg
|
|
||||||
$(SUDO) docker run $(RM) $(RUN_FLAGS) \
|
$(SUDO) docker run $(RM) $(RUN_FLAGS) \
|
||||||
-v $(shell pwd):/go/src/github.com/weaveworks/weave \
|
-v $(shell pwd):/go/src/github.com/weaveworks/weave \
|
||||||
-v $(shell pwd)/.pkg:/go/pkg \
|
|
||||||
-e GOARCH=$(ARCH) -e CGO_ENABLED=1 -e GOOS=linux -e CIRCLECI -e CIRCLE_BUILD_NUM -e CIRCLE_NODE_TOTAL -e CIRCLE_NODE_INDEX -e COVERDIR -e SLOW -e DEBUG \
|
-e GOARCH=$(ARCH) -e CGO_ENABLED=1 -e GOOS=linux -e CIRCLECI -e CIRCLE_BUILD_NUM -e CIRCLE_NODE_TOTAL -e CIRCLE_NODE_INDEX -e COVERDIR -e SLOW -e DEBUG \
|
||||||
$(BUILD_IMAGE) COVERAGE=$(COVERAGE) WEAVE_VERSION=$(WEAVE_VERSION) CC=$(CC) QEMUARCH=$(QEMUARCH) CGO_LDFLAGS=$(CGO_LDFLAGS) $@
|
$(BUILD_IMAGE) COVERAGE=$(COVERAGE) WEAVE_VERSION=$(WEAVE_VERSION) CC=$(CC) QEMUARCH=$(QEMUARCH) CGO_LDFLAGS=$(CGO_LDFLAGS) $@
|
||||||
touch $@
|
touch $@
|
||||||
@@ -235,19 +226,15 @@ ifeq ($(COVERAGE),true)
|
|||||||
else
|
else
|
||||||
go build $(BUILD_FLAGS) -o $@ ./$(@D)
|
go build $(BUILD_FLAGS) -o $@ ./$(@D)
|
||||||
endif
|
endif
|
||||||
$(NETGO_CHECK)
|
|
||||||
|
|
||||||
$(WEAVEUTIL_EXE) $(KUBEUTILS_EXE) $(WEAVENPC_EXE) $(NETWORKTESTER_EXE):
|
$(WEAVEUTIL_EXE) $(KUBEUTILS_EXE) $(WEAVENPC_EXE) $(NETWORKTESTER_EXE):
|
||||||
go build $(BUILD_FLAGS) -o $@ ./$(@D)
|
go build $(BUILD_FLAGS) -o $@ ./$(@D)
|
||||||
$(NETGO_CHECK)
|
|
||||||
|
|
||||||
$(WEAVEWAIT_EXE):
|
$(WEAVEWAIT_EXE):
|
||||||
go build $(BUILD_FLAGS) -tags "netgo iface mcast" -o $@ ./$(@D)
|
go build $(BUILD_FLAGS) -tags "osusergo netgo iface mcast" -o $@ ./$(@D)
|
||||||
$(NETGO_CHECK)
|
|
||||||
|
|
||||||
$(WEAVEWAIT_NOMCAST_EXE):
|
$(WEAVEWAIT_NOMCAST_EXE):
|
||||||
go build $(BUILD_FLAGS) -tags "netgo iface" -o $@ ./$(@D)
|
go build $(BUILD_FLAGS) -tags "osusergo netgo iface" -o $@ ./$(@D)
|
||||||
$(NETGO_CHECK)
|
|
||||||
|
|
||||||
# These programs need a separate rule as they fail the netgo check in
|
# These programs need a separate rule as they fail the netgo check in
|
||||||
# the main build stanza due to not importing net package
|
# the main build stanza due to not importing net package
|
||||||
@@ -412,15 +399,14 @@ clean-bin:
|
|||||||
-$(SUDO) DOCKER_HOST=$(DOCKER_HOST) docker rmi $(IMAGES)
|
-$(SUDO) DOCKER_HOST=$(DOCKER_HOST) docker rmi $(IMAGES)
|
||||||
find prog -type f -name "Dockerfile.*" -not -name "Dockerfile.template" -print | xargs rm -f
|
find prog -type f -name "Dockerfile.*" -not -name "Dockerfile.template" -print | xargs rm -f
|
||||||
find prog -type f -name "*qemu-*" -print | xargs rm -f
|
find prog -type f -name "*qemu-*" -print | xargs rm -f
|
||||||
rm -rf $(EXES) $(IMAGES_UPTODATE) $(WEAVEDB_UPTODATE) weave*.tar.gz .pkg
|
go clean ./...
|
||||||
|
rm -rf $(EXES) $(IMAGES_UPTODATE) $(WEAVEDB_UPTODATE) weave*.tar.gz .cache
|
||||||
|
|
||||||
clean: clean-bin clean-work-dir
|
clean: clean-bin clean-work-dir
|
||||||
-$(SUDO) DOCKER_HOST=$(DOCKER_HOST) docker rmi $(BUILD_IMAGE)
|
-$(SUDO) DOCKER_HOST=$(DOCKER_HOST) docker rmi $(BUILD_IMAGE)
|
||||||
rm -rf test/tls/*.pem test/coverage.* test/coverage $(BUILD_UPTODATE)
|
rm -rf test/tls/*.pem test/coverage.* test/coverage $(BUILD_UPTODATE)
|
||||||
|
|
||||||
build:
|
build:
|
||||||
$(SUDO) go clean -i net
|
|
||||||
$(SUDO) go install -tags netgo std
|
|
||||||
$(MAKE)
|
$(MAKE)
|
||||||
|
|
||||||
run-smoketests: all testrunner
|
run-smoketests: all testrunner
|
||||||
|
|||||||
@@ -57,19 +57,6 @@ RUN go get \
|
|||||||
github.com/fatih/hclfmt \
|
github.com/fatih/hclfmt \
|
||||||
github.com/client9/misspell/cmd/misspell
|
github.com/client9/misspell/cmd/misspell
|
||||||
|
|
||||||
# First clean, because we're gonna rebuild the std both with -race enabled and disabled
|
|
||||||
# Running go install std twice is intentional and required, as content is written in two different directories
|
|
||||||
# (/usr/local/go/pkg/linux_amd64 vs /usr/local/go/pkg/linux_amd64_race)
|
|
||||||
# The other architectures do not have support for -race
|
|
||||||
RUN go clean -i net \
|
|
||||||
&& go install -tags netgo std \
|
|
||||||
&& go install -race -tags netgo std
|
|
||||||
|
|
||||||
# Prebuild std for the other architectures
|
|
||||||
RUN for platform in ${GO_CROSSPLATFORMS}; do \
|
|
||||||
GOOS=${platform%/*} GOARCH=${platform##*/} \
|
|
||||||
go install -tags netgo std; done
|
|
||||||
|
|
||||||
# Allow full write access to the Go folders for anyone
|
# Allow full write access to the Go folders for anyone
|
||||||
RUN chmod -R a+w /usr/local/go
|
RUN chmod -R a+w /usr/local/go
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user