go-delve / delve

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

macOS Linking error running with `dlv debug` #3710

Closed adammw closed 1 month ago

adammw commented 2 months ago

Please answer the following before submitting your issue:

  1. What version of Delve are you using (dlv version)? 1.22.1
  2. What version of Go are you using? (go version)? go version go1.22.2 darwin/amd64
  3. What operating system and processor architecture are you using? Mac OS 14.4.1 (23E224) amd64

Reproduction Steps

exit status 1

aarzilli commented 1 month ago

This is not an issue with delve. You can reproduce it with just go by doing:

$ CGO_CFLAGS='-O0 -g' go build
# example.com
$GOROOT/pkg/tool/darwin_amd64/link: running clang failed: exit status 1
ld: warning: -no_pie is deprecated when targeting new OS versions
Undefined symbols for architecture x86_64:
  "_decode_int32", referenced from:
      _sample_func in 000002.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

It should be reported to https://github.com/golang/go. You can work around this problem by doing export CGO_CFLAGS=-g before executing delve.