diff --git a/hack/make/.binary b/hack/make/.binary index d56e3f312688c2bece2e8f91d024b7ba8ddff2c1..15b21eb04fb435db6b80e2b8de0205d8aa80e444 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}\""