Skip to content

Conversation

@justonedev1
Copy link
Collaborator

In case you need to debug something extensively in debugger and you can replicate the issue locally, you can now run

DEBUG=1 make

or

DEBUG=1 make WHAT=coconut

to create binaries with all the debug symbols and without optimizations (equivalent -O0 in gcc/clang) so you don't get those annoying problems while debugging like:

(dlv) args
timestamp = (unreadable could not find loclist entry at 0x7af03 for address 0xcd7634)
~r0 = (unreadable empty OP stack)

@justonedev1 justonedev1 requested a review from knopers8 as a code owner January 13, 2026 13:38
Comment on lines +84 to +90
# To invoke debug build you need to pass DEBUG variable with any value, eg: DEBUG=1 make WHAT=...
ifdef DEBUG
GCFLAGS= -gcflags="all=-N -l"
else
GCFLAGS=
endif

Copy link
Collaborator

Choose a reason for hiding this comment

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

To be more future-proof, could you declare GCFLAGS in the main instruction flow and add the debug options optionally? I.e. GCFLAGS= $(GCFLAGS) -gcflags ....

@echo -e "\033[1;33mgo build -mod=vendor\033[0m ./cmd/$@ \033[1;33m==>\033[0m \033[1;34m./bin/$@\033[0m"
# @echo ${PWD}
@$(WHAT_$@_BUILD_FLAGS) go build -mod=vendor $(VERBOSE_$(V)) -o bin/$@ $(LDFLAGS) ./cmd/$@
@$(WHAT_$@_BUILD_FLAGS) go build -mod=vendor $(VERBOSE_$(V)) $(GCFLAGS) -o bin/$@ $(LDFLAGS) ./cmd/$@
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
@$(WHAT_$@_BUILD_FLAGS) go build -mod=vendor $(VERBOSE_$(V)) $(GCFLAGS) -o bin/$@ $(LDFLAGS) ./cmd/$@
@$(WHAT_$@_BUILD_FLAGS) go build -mod=vendor $(VERBOSE_$(V)) $(GCFLAGS) -o bin/$@ $(LDFLAGS) ./cmd/$@

I assume the added space does nothing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants