Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/link: select DWARF 4 when using external linker #22455

thanm opened this issue Oct 26, 2017 · 2 comments

cmd/link: select DWARF 4 when using external linker #22455

thanm opened this issue Oct 26, 2017 · 2 comments


Copy link

@thanm thanm commented Oct 26, 2017

When a user requests external linkage, the Go linker seems to be invoking the external linker with the "-gdwarf-2" flag (asking for DWARF version 2). Example:

$ go build -x -ldflags "-v -linkmode external -extld gcc" himom.go 1> transcript.txt 2>&1
$ fgrep 'host link' transcript.txt  
0.07 host link: "gcc" "-m64" "-gdwarf-2" "-o" "/tmp/go-build530006148/b001/exe/a.out" ...

Given that the DWARF produced by the Go compiler is now DWARF 4, I don't think it makes sense to continue to use this flag. When I look at the dwarf from the himom.go build above, it appears that all compilation units in the .debug_info are showing version 4 except for this one:

  Compilation Unit @ offset 0x5b7c5:
   Length:        0x4f (32-bit)
   Version:       2
   Abbrev Offset: 0x1141
   Pointer Size:  8
 <0><5b7d0>: Abbrev Number: 1 (DW_TAG_compile_unit)
    <5b7d1>   DW_AT_stmt_list   : 0x110fa	
    <5b7d5>   DW_AT_low_pc      : 0x488867	
    <5b7dd>   DW_AT_high_pc     : 0x48887e	
    <5b7e5>   DW_AT_name        : gcc_amd64.S	
    <5b7f1>   DW_AT_comp_dir    : /x/go/src/runtime/cgo	
    <5b80a>   DW_AT_producer    : GNU AS 2.24	
    <5b816>   DW_AT_language    : 32769	(MIPS assembler)

Not sure what the original thinking was for doing this, but it doesn't seem useful now.

@thanm thanm self-assigned this Oct 26, 2017
Copy link

@gopherbot gopherbot commented Oct 26, 2017

Change mentions this issue: cmd/link: don't pass -gdwarf-2 to external linker

Copy link

@ianlancetaylor ianlancetaylor commented Oct 26, 2017

For the record, we started passing -gdwarf-2 in But I don't really understand why we are passing a -g option here at all, as we are only passing object files, and the linker just ignores the -g option anyhow. So I think your CL is right.

@gopherbot gopherbot closed this in 3e1e66f Oct 27, 2017
@golang golang locked and limited conversation to collaborators Oct 27, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.