From 2a010263f62c8ad82952a7c2c661baa9706c6155 Mon Sep 17 00:00:00 2001 From: Sebastian Lackner Date: Wed, 26 Dec 2018 21:45:10 +0100 Subject: build.bash: Escape LDFLAGS before passing them to 'go build'. This ensures that ./build.bash still works when the LDFLAGS environment variable contains multiple options, e.g., LDFLAGS="-lpthread -lm". The correct way of passing multiple options is discussed here: https://github.com/golang/go/issues/6234 For some unknown reason, the method only works when -extldflags is the last argument - is this a bug in Go? --- build.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.bash b/build.bash index 2f2d1dd..d6f6b7f 100755 --- a/build.bash +++ b/build.bash @@ -84,7 +84,7 @@ GO_LDFLAGS="-X main.GitVersion=$GITVERSION -X main.GitVersionFuse=$GITVERSIONFUS # If LDFLAGS is set, add it as "-extldflags". if [[ -n ${LDFLAGS:-} ]] ; then - GO_LDFLAGS="-extldflags=$LDFLAGS $GO_LDFLAGS" + GO_LDFLAGS="$GO_LDFLAGS \"-extldflags=$LDFLAGS\"" fi # Actual "go build" call -- cgit v1.2.3