hack: compile w/o optimizations & inlining when debugging

Without these compile flags, Delve is unable to report the value of some
variables and it's not possible to jump into inlined code.

As the contributing docs already mention that `DOCKER_DEBUG` should
disable "build optimizations", the env var is reused here instead of
introducing a new one.

Signed-off-by: Albin Kerouanton <albinker@gmail.com>
This commit is contained in:
Albin Kerouanton 2023-09-06 10:10:55 +02:00
parent 032797ea4b
commit 820f37b1a6
No known key found for this signature in database
GPG key ID: 630B8E1DCBDB1864

View file

@ -74,11 +74,15 @@ source "${MAKEDIR}/.go-autogen"
fi
fi
if [ -n "${DOCKER_DEBUG}" ]; then
GCFLAGS="all=-N -l"
fi
echo "Building $([ "$DOCKER_STATIC" = "1" ] && echo "static" || echo "dynamic") $DEST/$BINARY_FULLNAME ($PLATFORM_NAME)..."
if [ -n "$DOCKER_DEBUG" ]; then
set -x
fi
./hack/with-go-mod.sh go build -mod=vendor -modfile=vendor.mod -o "$DEST/$BINARY_FULLNAME" "${BUILDFLAGS[@]}" -ldflags "$LDFLAGS $LDFLAGS_STATIC $DOCKER_LDFLAGS" "$GO_PACKAGE"
./hack/with-go-mod.sh go build -mod=vendor -modfile=vendor.mod -o "$DEST/$BINARY_FULLNAME" "${BUILDFLAGS[@]}" -ldflags "$LDFLAGS $LDFLAGS_STATIC $DOCKER_LDFLAGS" -gcflags="${GCFLAGS}" "$GO_PACKAGE"
)
echo "Created binary: $DEST/$BINARY_FULLNAME"