From 1fb53739627b718c6ae6138b0616b01da09de52e Mon Sep 17 00:00:00 2001 From: Daniel Nelson Date: Mon, 7 Aug 2017 15:47:20 -0700 Subject: [PATCH] Build releases with -w -s ldflags --- Makefile | 2 +- scripts/build.py | 23 ++++------------------- 2 files changed, 5 insertions(+), 20 deletions(-) diff --git a/Makefile b/Makefile index 9e92de04e..4e73f8c36 100644 --- a/Makefile +++ b/Makefile @@ -26,7 +26,7 @@ telegraf: go build -o $(TELEGRAF) -ldflags "$(LDFLAGS)" ./cmd/telegraf/telegraf.go go-install: - go install -ldflags "$(LDFLAGS)" ./cmd/telegraf + go install -ldflags "-w -s $(LDFLAGS)" ./cmd/telegraf install: telegraf mkdir -p $(DESTDIR)$(PREFIX)/bin/ diff --git a/scripts/build.py b/scripts/build.py index d391ec2e1..3fa171c5a 100755 --- a/scripts/build.py +++ b/scripts/build.py @@ -470,26 +470,11 @@ def build(version=None, build_command += "-race " if len(tags) > 0: build_command += "-tags {} ".format(','.join(tags)) - if "1.4" in get_go_version(): - if static: - build_command += "-ldflags=\"-s -X main.version {} -X main.branch {} -X main.commit {}\" ".format(version, - get_current_branch(), - get_current_commit()) - else: - build_command += "-ldflags=\"-X main.version {} -X main.branch {} -X main.commit {}\" ".format(version, - get_current_branch(), - get_current_commit()) - else: - # Starting with Go 1.5, the linker flag arguments changed to 'name=value' from 'name value' - if static: - build_command += "-ldflags=\"-s -X main.version={} -X main.branch={} -X main.commit={}\" ".format(version, - get_current_branch(), - get_current_commit()) - else: - build_command += "-ldflags=\"-X main.version={} -X main.branch={} -X main.commit={}\" ".format(version, - get_current_branch(), - get_current_commit()) + build_command += "-ldflags=\"-w -s -X main.version={} -X main.branch={} -X main.commit={}\" ".format( + version, + get_current_branch(), + get_current_commit()) if static: build_command += "-a -installsuffix cgo " build_command += path