From 87d1798c63c51209ff259635865d6a657fc666d5 Mon Sep 17 00:00:00 2001 From: Pablo Caderno Date: Mon, 10 Feb 2020 14:58:19 +1100 Subject: [PATCH 1/4] Added -trimpath option to go build Fixes #2063 Signed-off-by: Pablo Caderno Signed-off-by: kaderno --- Makefile | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/Makefile b/Makefile index 7173bc0cc22..0381d708ff1 100644 --- a/Makefile +++ b/Makefile @@ -193,14 +193,14 @@ elasticsearch-mappings: build-examples: esc -pkg frontend -o examples/hotrod/services/frontend/gen_assets.go -prefix examples/hotrod/services/frontend/web_assets examples/hotrod/services/frontend/web_assets ifeq ($(GOARCH), s390x) - CGO_ENABLED=0 installsuffix=cgo go build -o ./examples/hotrod/hotrod-$(GOOS)-$(GOARCH) ./examples/hotrod/main.go + CGO_ENABLED=0 installsuffix=cgo go build -trimpath -o ./examples/hotrod/hotrod-$(GOOS)-$(GOARCH) ./examples/hotrod/main.go else - CGO_ENABLED=0 installsuffix=cgo go build -o ./examples/hotrod/hotrod-$(GOOS) ./examples/hotrod/main.go + CGO_ENABLED=0 installsuffix=cgo go build -trimpath -o ./examples/hotrod/hotrod-$(GOOS) ./examples/hotrod/main.go endif .PHONY: build-tracegen build-tracegen: - CGO_ENABLED=0 installsuffix=cgo go build -o ./cmd/tracegen/tracegen-$(GOOS) ./cmd/tracegen/main.go + CGO_ENABLED=0 installsuffix=cgo go build -trimpath -o ./cmd/tracegen/tracegen-$(GOOS) ./cmd/tracegen/main.go .PHONE: docker-hotrod docker-hotrod: @@ -224,41 +224,41 @@ build-all-in-one-linux: build-ui .PHONY: build-all-in-one build-all-in-one: elasticsearch-mappings ifeq ($(GOARCH), s390x) - CGO_ENABLED=0 installsuffix=cgo go build -tags ui -o ./cmd/all-in-one/all-in-one-$(GOOS)-$(GOARCH) $(BUILD_INFO) ./cmd/all-in-one/main.go + CGO_ENABLED=0 installsuffix=cgo go build -tags ui -trimpath -o ./cmd/all-in-one/all-in-one-$(GOOS)-$(GOARCH) $(BUILD_INFO) ./cmd/all-in-one/main.go else - CGO_ENABLED=0 installsuffix=cgo go build -tags ui -o ./cmd/all-in-one/all-in-one-$(GOOS) $(BUILD_INFO) ./cmd/all-in-one/main.go + CGO_ENABLED=0 installsuffix=cgo go build -tags ui -trimpath -o ./cmd/all-in-one/all-in-one-$(GOOS) $(BUILD_INFO) ./cmd/all-in-one/main.go endif .PHONY: build-agent build-agent: ifeq ($(GOARCH), s390x) - CGO_ENABLED=0 installsuffix=cgo go build -o ./cmd/agent/agent-$(GOOS)-$(GOARCH) $(BUILD_INFO) ./cmd/agent/main.go + CGO_ENABLED=0 installsuffix=cgo go build -trimpath -o ./cmd/agent/agent-$(GOOS)-$(GOARCH) $(BUILD_INFO) ./cmd/agent/main.go else - CGO_ENABLED=0 installsuffix=cgo go build -o ./cmd/agent/agent-$(GOOS) $(BUILD_INFO) ./cmd/agent/main.go + CGO_ENABLED=0 installsuffix=cgo go build -trimpath -o ./cmd/agent/agent-$(GOOS) $(BUILD_INFO) ./cmd/agent/main.go endif .PHONY: build-query build-query: ifeq ($(GOARCH), s390x) - CGO_ENABLED=0 installsuffix=cgo go build -tags ui -o ./cmd/query/query-$(GOOS)-$(GOARCH) $(BUILD_INFO) ./cmd/query/main.go + CGO_ENABLED=0 installsuffix=cgo go build -tags ui -trimpath -o ./cmd/query/query-$(GOOS)-$(GOARCH) $(BUILD_INFO) ./cmd/query/main.go else - CGO_ENABLED=0 installsuffix=cgo go build -tags ui -o ./cmd/query/query-$(GOOS) $(BUILD_INFO) ./cmd/query/main.go + CGO_ENABLED=0 installsuffix=cgo go build -tags ui -trimpath -o ./cmd/query/query-$(GOOS) $(BUILD_INFO) ./cmd/query/main.go endif .PHONY: build-collector build-collector: elasticsearch-mappings ifeq ($(GOARCH), s390x) - CGO_ENABLED=0 installsuffix=cgo go build -o ./cmd/collector/collector-$(GOOS)-$(GOARCH) $(BUILD_INFO) ./cmd/collector/main.go + CGO_ENABLED=0 installsuffix=cgo go build -trimpath -o ./cmd/collector/collector-$(GOOS)-$(GOARCH) $(BUILD_INFO) ./cmd/collector/main.go else - CGO_ENABLED=0 installsuffix=cgo go build -o ./cmd/collector/collector-$(GOOS) $(BUILD_INFO) ./cmd/collector/main.go + CGO_ENABLED=0 installsuffix=cgo go build -trimpath -o ./cmd/collector/collector-$(GOOS) $(BUILD_INFO) ./cmd/collector/main.go endif .PHONY: build-ingester build-ingester: ifeq ($(GOARCH), s390x) - CGO_ENABLED=0 installsuffix=cgo go build -o ./cmd/ingester/ingester-$(GOOS)-$(GOARCH) $(BUILD_INFO) ./cmd/ingester/main.go + CGO_ENABLED=0 installsuffix=cgo go build -trimpath -o ./cmd/ingester/ingester-$(GOOS)-$(GOARCH) $(BUILD_INFO) ./cmd/ingester/main.go else - CGO_ENABLED=0 installsuffix=cgo go build -o ./cmd/ingester/ingester-$(GOOS) $(BUILD_INFO) ./cmd/ingester/main.go + CGO_ENABLED=0 installsuffix=cgo go build -trimpath -o ./cmd/ingester/ingester-$(GOOS) $(BUILD_INFO) ./cmd/ingester/main.go endif .PHONY: docker @@ -326,7 +326,7 @@ docker-push: .PHONY: build-crossdock-linux build-crossdock-linux: - CGO_ENABLED=0 GOOS=linux installsuffix=cgo go build -o ./crossdock/crossdock-linux ./crossdock/main.go + CGO_ENABLED=0 GOOS=linux installsuffix=cgo go build -trimpath -o ./crossdock/crossdock-linux ./crossdock/main.go include crossdock/rules.mk From 0fe773b5a60a21ae6c9d7242ef4d49a8c26a6bc1 Mon Sep 17 00:00:00 2001 From: Pablo Caderno Date: Mon, 10 Feb 2020 16:03:52 +1100 Subject: [PATCH 2/4] Added trimpath option to go build Defined variable per suggestion of @yurishkuro Signed-off-by: kaderno --- Makefile | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/Makefile b/Makefile index 0381d708ff1..23be43feb1d 100644 --- a/Makefile +++ b/Makefile @@ -28,6 +28,7 @@ ifeq ($(UNAME), s390x) else RACE=-race endif +GOBUILD=CGO_ENABLED=0 installsuffix=cgo go build -trimpath GOTEST=go test -v $(RACE) GOLINT=golint GOVET=go vet @@ -193,14 +194,14 @@ elasticsearch-mappings: build-examples: esc -pkg frontend -o examples/hotrod/services/frontend/gen_assets.go -prefix examples/hotrod/services/frontend/web_assets examples/hotrod/services/frontend/web_assets ifeq ($(GOARCH), s390x) - CGO_ENABLED=0 installsuffix=cgo go build -trimpath -o ./examples/hotrod/hotrod-$(GOOS)-$(GOARCH) ./examples/hotrod/main.go + $(GOBUILD) -o ./examples/hotrod/hotrod-$(GOOS)-$(GOARCH) ./examples/hotrod/main.go else - CGO_ENABLED=0 installsuffix=cgo go build -trimpath -o ./examples/hotrod/hotrod-$(GOOS) ./examples/hotrod/main.go + $(GOBUILD) -o ./examples/hotrod/hotrod-$(GOOS) ./examples/hotrod/main.go endif .PHONY: build-tracegen build-tracegen: - CGO_ENABLED=0 installsuffix=cgo go build -trimpath -o ./cmd/tracegen/tracegen-$(GOOS) ./cmd/tracegen/main.go + $(GOBUILD) -o ./cmd/tracegen/tracegen-$(GOOS) ./cmd/tracegen/main.go .PHONE: docker-hotrod docker-hotrod: @@ -224,41 +225,41 @@ build-all-in-one-linux: build-ui .PHONY: build-all-in-one build-all-in-one: elasticsearch-mappings ifeq ($(GOARCH), s390x) - CGO_ENABLED=0 installsuffix=cgo go build -tags ui -trimpath -o ./cmd/all-in-one/all-in-one-$(GOOS)-$(GOARCH) $(BUILD_INFO) ./cmd/all-in-one/main.go + $(GOBUILD) -tags ui -o ./cmd/all-in-one/all-in-one-$(GOOS)-$(GOARCH) $(BUILD_INFO) ./cmd/all-in-one/main.go else - CGO_ENABLED=0 installsuffix=cgo go build -tags ui -trimpath -o ./cmd/all-in-one/all-in-one-$(GOOS) $(BUILD_INFO) ./cmd/all-in-one/main.go + $(GOBUILD) -tags ui -o ./cmd/all-in-one/all-in-one-$(GOOS) $(BUILD_INFO) ./cmd/all-in-one/main.go endif .PHONY: build-agent build-agent: ifeq ($(GOARCH), s390x) - CGO_ENABLED=0 installsuffix=cgo go build -trimpath -o ./cmd/agent/agent-$(GOOS)-$(GOARCH) $(BUILD_INFO) ./cmd/agent/main.go + $(GOBUILD) -o ./cmd/agent/agent-$(GOOS)-$(GOARCH) $(BUILD_INFO) ./cmd/agent/main.go else - CGO_ENABLED=0 installsuffix=cgo go build -trimpath -o ./cmd/agent/agent-$(GOOS) $(BUILD_INFO) ./cmd/agent/main.go + $(GOBUILD) -o ./cmd/agent/agent-$(GOOS) $(BUILD_INFO) ./cmd/agent/main.go endif .PHONY: build-query build-query: ifeq ($(GOARCH), s390x) - CGO_ENABLED=0 installsuffix=cgo go build -tags ui -trimpath -o ./cmd/query/query-$(GOOS)-$(GOARCH) $(BUILD_INFO) ./cmd/query/main.go + $(GOBUILD) -tags ui -o ./cmd/query/query-$(GOOS)-$(GOARCH) $(BUILD_INFO) ./cmd/query/main.go else - CGO_ENABLED=0 installsuffix=cgo go build -tags ui -trimpath -o ./cmd/query/query-$(GOOS) $(BUILD_INFO) ./cmd/query/main.go + $(GOBUILD) -tags ui -o ./cmd/query/query-$(GOOS) $(BUILD_INFO) ./cmd/query/main.go endif .PHONY: build-collector build-collector: elasticsearch-mappings ifeq ($(GOARCH), s390x) - CGO_ENABLED=0 installsuffix=cgo go build -trimpath -o ./cmd/collector/collector-$(GOOS)-$(GOARCH) $(BUILD_INFO) ./cmd/collector/main.go + $(GOBUILD) -o ./cmd/collector/collector-$(GOOS)-$(GOARCH) $(BUILD_INFO) ./cmd/collector/main.go else - CGO_ENABLED=0 installsuffix=cgo go build -trimpath -o ./cmd/collector/collector-$(GOOS) $(BUILD_INFO) ./cmd/collector/main.go + $(GOBUILD) -o ./cmd/collector/collector-$(GOOS) $(BUILD_INFO) ./cmd/collector/main.go endif .PHONY: build-ingester build-ingester: ifeq ($(GOARCH), s390x) - CGO_ENABLED=0 installsuffix=cgo go build -trimpath -o ./cmd/ingester/ingester-$(GOOS)-$(GOARCH) $(BUILD_INFO) ./cmd/ingester/main.go + $(GOBUILD) -o ./cmd/ingester/ingester-$(GOOS)-$(GOARCH) $(BUILD_INFO) ./cmd/ingester/main.go else - CGO_ENABLED=0 installsuffix=cgo go build -trimpath -o ./cmd/ingester/ingester-$(GOOS) $(BUILD_INFO) ./cmd/ingester/main.go + $(GOBUILD) -o ./cmd/ingester/ingester-$(GOOS) $(BUILD_INFO) ./cmd/ingester/main.go endif .PHONY: docker @@ -507,3 +508,4 @@ proto-install: ./vendor/github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway \ ./vendor/github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger # ./vendor/github.com/mwitkow/go-proto-validators/protoc-gen-govalidators + From 13e10183268a0c884dbb685037f3a788b54b4fa3 Mon Sep 17 00:00:00 2001 From: Pablo Caderno Date: Mon, 10 Feb 2020 16:09:02 +1100 Subject: [PATCH 3/4] Updated last go build command Signed-off-by: Pablo Caderno Signed-off-by: kaderno --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 23be43feb1d..40c10c59728 100644 --- a/Makefile +++ b/Makefile @@ -327,7 +327,7 @@ docker-push: .PHONY: build-crossdock-linux build-crossdock-linux: - CGO_ENABLED=0 GOOS=linux installsuffix=cgo go build -trimpath -o ./crossdock/crossdock-linux ./crossdock/main.go + $(GOBUILD) GOOS=linux -o ./crossdock/crossdock-linux ./crossdock/main.go include crossdock/rules.mk From 2117ca245a76326060105f34e981270ef3b16164 Mon Sep 17 00:00:00 2001 From: kaderno Date: Mon, 10 Feb 2020 19:28:20 +1100 Subject: [PATCH 4/4] Changed variable order Signed-off-by: kaderno --- Makefile | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 40c10c59728..3230209a7bd 100644 --- a/Makefile +++ b/Makefile @@ -327,7 +327,7 @@ docker-push: .PHONY: build-crossdock-linux build-crossdock-linux: - $(GOBUILD) GOOS=linux -o ./crossdock/crossdock-linux ./crossdock/main.go + GOOS=linux $(GOBUILD) -o ./crossdock/crossdock-linux ./crossdock/main.go include crossdock/rules.mk @@ -476,7 +476,6 @@ proto: ### grpc-gateway generates 'query.pb.gw.go' that does not respect (gogoproto.customname) = "TraceID" ### --grpc-gateway_out=$(PROTO_GOGO_MAPPINGS):$(PWD)/proto-gen/ \ ### --swagger_out=allow_merge=true:$(PWD)/proto-gen/openapi/ \ - $(PROTOC) \ $(PROTO_INCLUDES) \ -I plugin/storage/grpc/proto \ @@ -508,4 +507,3 @@ proto-install: ./vendor/github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway \ ./vendor/github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger # ./vendor/github.com/mwitkow/go-proto-validators/protoc-gen-govalidators -