浏览代码

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>
Albin Kerouanton 1 年之前
父节点
当前提交
820f37b1a6
共有 1 个文件被更改,包括 5 次插入1 次删除
  1. 5 1
      hack/make/.binary

+ 5 - 1
hack/make/.binary

@@ -74,11 +74,15 @@ source "${MAKEDIR}/.go-autogen"
 		fi
 		fi
 	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)..."
 	echo "Building $([ "$DOCKER_STATIC" = "1" ] && echo "static" || echo "dynamic") $DEST/$BINARY_FULLNAME ($PLATFORM_NAME)..."
 	if [ -n "$DOCKER_DEBUG" ]; then
 	if [ -n "$DOCKER_DEBUG" ]; then
 		set -x
 		set -x
 	fi
 	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"
 echo "Created binary: $DEST/$BINARY_FULLNAME"