Skip to content
Snippets Groups Projects
Commit 1bf376ad authored by Marc-Olivier Andrez's avatar Marc-Olivier Andrez
Browse files

build: disable optimizations when building `go` code in Debug mode

Debugging Go code built without optimizations is easier, as mentioned on
https://go.dev/doc/gdb#Introduction:

> When you compile and link your Go programs with the gc toolchain on
> Linux, macOS, FreeBSD or NetBSD, the resulting binaries contain DWARFv4
> debugging information that recent versions (≥7.5) of the GDB debugger
> can use to inspect a live process or a core dump.
>
> Pass the '-w' flag to the linker to omit the debug information (for
> example, go build -ldflags=-w prog.go).
>
> The code generated by the gc compiler includes inlining of function
> invocations and registerization of variables. These optimizations can
> sometimes make debugging with gdb harder. If you find that you need to
> disable these optimizations, build your program using go build
> -gcflags=all="-N -l".
>
> If you want to use gdb to inspect a core dump, you can trigger a dump
> on a program crash, on systems that permit it, by setting
> GOTRACEBACK=crash in the environment (see the runtime package
> documentation for more info).
parent 28818b78
Loading
Pipeline #118942 failed
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment