Skip to content

Commit 57dea75

Browse files
authored
build: Add debug make target with symbols and no optimizations. (#28117)
The dev target and the downstream builders are not suitable for debugging as they are optimized and do not have symblos enabled. This change adds a "dev-debug" target that can be used to build Nomad in a way that Delve can be used fully for debugging and development.
1 parent 5435ae9 commit 57dea75

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

GNUmakefile

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,23 @@ dev: hclfmt ## Build for the current development platform
288288
@cp $(PROJECT_ROOT)/$(DEV_TARGET) $(PROJECT_ROOT)/bin/
289289
@cp $(PROJECT_ROOT)/$(DEV_TARGET) $(BIN)
290290

291+
.PHONY: dev-debug
292+
dev-debug: GOOS=$(shell go env GOOS)
293+
dev-debug: GOARCH=$(shell go env GOARCH)
294+
dev-debug: ## Build for the current platform with debug symbols and no optimizations
295+
@echo "==> Removing old development build..."
296+
@rm -f $(PROJECT_ROOT)/bin/nomad
297+
@rm -f $(BIN)/nomad
298+
@echo "==> Done"
299+
@echo "==> Building debug binary..."
300+
@go build \
301+
-gcflags "all=-N -l" \
302+
-ldflags "$(GO_LDFLAGS)" \
303+
-tags "$(GO_TAGS) $(NOMAD_UI_TAG)" \
304+
-o $(PROJECT_ROOT)/bin/nomad
305+
@cp $(PROJECT_ROOT)/bin/nomad $(BIN)
306+
@echo "==> Done"
307+
291308
.PHONY: dev-static
292309
dev-static:
293310
@$(MAKE) CGO_ENABLED=0 dev ## Build a dev binary with no CGO

0 commit comments

Comments
 (0)