Skip to content

Add makefile flag to create debug build #5009

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 27, 2025
Merged

Conversation

jmatth
Copy link
Member

@jmatth jmatth commented May 23, 2025

During a recent incident I had to create a build of the server I could usefully debug with delve. This PR just adds a flag to the makefile to make creating such a build easier in the future.

GCFLAGS:

  • -N: disable optimizations
  • -l: disable inlining

LDFLAGS:

  • -s: disable symbol table
  • -w: disable DWARF generation

@jmatth jmatth requested a review from abe-winter May 23, 2025 21:36
@viambot viambot added the safe to test This pull request is marked safe to test from a trusted zone label May 23, 2025
Copy link
Member

@abe-winter abe-winter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, pls fix hyphen

long-shot concern -- is GCFLAGS defined on the github runner to something that will cause problems? guessing not

@@ -9,7 +9,12 @@ PATH_WITH_TOOLS="`pwd`/$(TOOL_BIN):`pwd`/node_modules/.bin:${PATH}"
GIT_REVISION = $(shell git rev-parse HEAD | tr -d '\n')
TAG_VERSION?=$(shell ./etc/dev-version.sh | sed 's/^v//')
DATE_COMPILED?=$(shell date +'%Y-%m-%d')
COMMON_LDFLAGS = -s -w -X 'go.viam.com/rdk/config.Version=${TAG_VERSION}' -X 'go.viam.com/rdk/config.GitRevision=${GIT_REVISION}' -X 'go.viam.com/rdk/config.DateCompiled=${DATE_COMPILED}'
COMMON_LDFLAGS = -X 'go.viam.com/rdk/config.Version=${TAG_VERSION}' -X 'go.viam.com/rdk/config.GitRevision=${GIT_REVISION}' -X 'go.viam.com/rdk/config.DateCompiled=${DATE_COMPILED}'
ifdef BUILD_DEBUG
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BUILD_DEBUG=0 puts this in the first case, not the second, but shrug, I think fine as-is and not worth changing / retesting

Makefile Outdated

windows:
mkdir -p bin/windows
GOOS=windows go build -tags no_cgo -ldflags="-extldflags=-static $(COMMON_LDFLAGS)" -o bin/windows/viam-server-$(shell go env GOARCH).exe ./web/cmd/server
GOOS=windows go build -tags no_cgo -$(GCFLAGS) ldflags="-extldflags=-static $(COMMON_LDFLAGS)" -o bin/windows/viam-server-$(shell go env GOARCH).exe ./web/cmd/server
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

misplaced hyphen here

@viambot viambot added safe to test This pull request is marked safe to test from a trusted zone and removed safe to test This pull request is marked safe to test from a trusted zone labels May 23, 2025
@jmatth
Copy link
Member Author

jmatth commented May 27, 2025

long-shot concern -- is GCFLAGS defined on the github runner to something that will cause problems? guessing not

As far as I can tell it's not. Nothing in the workflow definitions sets it and the workflows run on Github's provided ubuntu-latest runners so there shouldn't be any hidden magic on the runner setting it either.

@jmatth jmatth merged commit 2999378 into viamrobotics:main May 27, 2025
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
safe to test This pull request is marked safe to test from a trusted zone
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants