go-delve / delve

Delve is a debugger for the Go programming language.
MIT License
22.37k stars 2.13k forks source link

Hitting compile error when launching delve in devbox #3748

Closed mwoodpatrick closed 2 weeks ago

mwoodpatrick commented 2 weeks ago
  1. What version of Delve are you using (dlv version)? Version: 1.22.1 Build: $Id: 0c3470054da6feac5f6dcf3e3e5144a64f7a9a48 $

  2. What version of Go are you using? (go version)? go version go1.22.3 linux/amd64

  3. What operating system and processor architecture are you using? Debian GNU/Linux 12 (bookworm)

  4. What did you do? In jetify/devbox env I ran: dlv debug ./main.go

  5. What did you expect to see? Delve should launch

  6. What did you see instead?

    runtime/cgo

    In file included from /nix/store/x8lqlydsxbrwvf6p7v18gws8kn1xl37f-glibc-2.38-23-dev/include/bits/libc-header-start.h:33, from /nix/store/x8lqlydsxbrwvf6p7v18gws8kn1xl37f-glibc-2.38-23-dev/include/stdlib.h:26, from _cgo_export.c:3: /nix/store/x8lqlydsxbrwvf6p7v18gws8kn1xl37f-glibc-2.38-23-dev/include/features.h:414:4: error: #warning _FORTIFY_SOURCE requires compiling with optimization (-O) [-Werror=cpp] 414 | # warning _FORTIFY_SOURCE requires compiling with optimization (-O) | ^~~ cc1: all warnings being treated as errors exit status 1

aarzilli commented 2 weeks ago

You have to set CGO_CFLAGS to something, otherwise delve will set it to "-O0 -g", which your library doesn't like.

mwoodpatrick commented 2 weeks ago

Recommendations as to what a suitable value should be would be greatly appreciated

aarzilli commented 2 weeks ago

Anything that isn't the empty string, -g for example.

mwoodpatrick commented 2 weeks ago

That worked, many thanks, much appreciated