golang/go

cmd/ld: no dwarf when using -linkmode=external on OS X

rsc opened this issue · 6 comments

rsc commented
CL https://golang.org/cl/9025047 disabled dwarf generation when using
-linkmode=external on OS X:

changeset:   16733:3ac710a2ebf3
user:        Rob Pike <r@golang.org>
date:        Tue Apr 30 14:22:28 2013 -0700
files:       src/cmd/ld/dwarf.c
description:
cmd/ld: when linking externally, only generate dwarf info for ELF

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/9025047

This makes lldb/gdb useless on Mac when using cgo outside the Go standard library.

Anyone remember why we did this?

Should look into undoing it for Go 1.4.
rsc commented

Comment 1:

from private mail:
Well apparently it's a mess. OS X has a separate dwarf linker. ld is supposed to add
references to all .o files into the executable. Then you can run dsymutil to read all
the .o files mentioned in the binary and combine the debug info into a .dwarf file. I've
got a patch that seems to get the debug info into the correct format for a mach o object
file, but for some reason ld doesn't include it in the list of the .o files, so the info
just disappears.

Labels changed: added release-go1.5, removed release-go1.4.

Comment 2:

CL https://golang.org/cl/168780043 mentions this issue.

Possibly related: #5221.

CL https://golang.org/cl/8661 mentions this issue.

CL 8661 was rolled back due to build breakage.

CL https://golang.org/cl/10284 mentions this issue.