From d645297358ce3f9fced99b772b36da6c1bf6d464 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Gronowski?= Date: Thu, 5 Jan 2023 20:32:46 +0100 Subject: [PATCH] hack/make: Don't add -buildmode=pie with -race MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Make it possible to add `-race` to the BUILDFLAGS without making the build fail with error: "-buildmode=pie not supported when -race is enabled" Signed-off-by: Paweł Gronowski --- hack/make/.binary | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/hack/make/.binary b/hack/make/.binary index d56e3f3126..15b21eb04f 100644 --- a/hack/make/.binary +++ b/hack/make/.binary @@ -70,14 +70,17 @@ hash_files() { esac fi - # -buildmode=pie is not supported on Windows and Linux on mips and riscv64. - case "$(go env GOOS)/$(go env GOARCH)" in - windows/* | linux/mips* | linux/riscv*) ;; + # -buildmode=pie not supported when -race is enabled + if [[ " $BUILDFLAGS " != *" -race "* ]]; then + # -buildmode=pie is not supported on Windows and Linux on mips and riscv64. + case "$(go env GOOS)/$(go env GOARCH)" in + windows/* | linux/mips* | linux/riscv*) ;; - *) - BUILDFLAGS+=("-buildmode=pie") - ;; - esac + *) + BUILDFLAGS+=("-buildmode=pie") + ;; + esac + fi echo "Building: $DEST/$BINARY_FULLNAME" echo "GOOS=\"${GOOS}\" GOARCH=\"${GOARCH}\" GOARM=\"${GOARM}\""