Skip to content

Commit

Permalink
Bump go 1.19: fix error when building tools such as benchmark
Browse files Browse the repository at this point in the history
The pipeline error:
```
Building 'tools/benchmark'...
% 'rm' '-f' 'bin/tools/benchmark'
% 'env' 'GO_BUILD_FLAGS=-v' 'CGO_ENABLED=0' 'go' 'build' '-v' '-installsuffix=cgo' '-ldflags='\''-X=go.etcd.io/etcd/api/v3/version.GitSHA=01250c9'\''' '-o=bin/tools/benchmark' './tools/benchmark'
stderr: invalid value "'-X=go.etcd.io/etcd/api/v3/version.GitSHA=01250c9'" for flag -ldflags: parameter may not start with quote character '
stderr: usage: go build [-o output] [build flags] [packages]
stderr: Run 'go help build' for details.
FAIL: (code:2):
  % 'env' 'GO_BUILD_FLAGS=-v' 'CGO_ENABLED=0' 'go' 'build' '-v' '-installsuffix=cgo' '-ldflags='\''-X=go.etcd.io/etcd/api/v3/version.GitSHA=01250c9'\''' '-o=bin/tools/benchmark' './tools/benchmark'
FAIL: 'build' failed at Thu Sep 15 03:13:24 UTC 2022
```

It's caused by golang/go#43177. Previously
invalid -ldflags is silently ignored by go cmd. But it isn't ignored
anymore in go 1.19 due to the fix in PR
https://go-review.googlesource.com/c/go/+/339289.

Signed-off-by: Benjamin Wang <[email protected]>
  • Loading branch information
ahrtr committed Sep 16, 2022
1 parent f2c590a commit 7b0e608
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion scripts/build_lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ tools_build() {
# shellcheck disable=SC2086
run env GO_BUILD_FLAGS="${GO_BUILD_FLAGS}" CGO_ENABLED=0 go build ${GO_BUILD_FLAGS} \
-installsuffix=cgo \
"-ldflags='${GO_LDFLAGS[*]}'" \
"-ldflags=${GO_LDFLAGS[*]}" \
-o="${out}/${tool}" "./${tool}" || return 2
done
tests_build "${@}"
Expand Down

0 comments on commit 7b0e608

Please sign in to comment.