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: no dwarf when using -linkmode=external on Windows #13154

Closed
lukehoban opened this issue Nov 5, 2015 · 1 comment
Closed

cmd/link: no dwarf when using -linkmode=external on Windows #13154

lukehoban opened this issue Nov 5, 2015 · 1 comment

Comments

@lukehoban
Copy link

Similar to #8973, it appears that dwarf data is missing when using default -linkmode=external on Windows.

c:\dd\go\src\github.com\lukehoban\cgotest>go version
go version go1.5.1 windows/amd64

c:\dd\go\src\github.com\lukehoban\cgotest>where gcc
C:\Program Files\mingw-w64\x86_64-5.2.0-posix-seh-rt_v4-rev0\mingw64\bin\gcc.exe

c:\dd\go\src\github.com\lukehoban\cgotest>cat cgotest.go
package main

/*
#include <stdio.h>
char* foo(void) { return "hello, world!"; }
*/
import "C"

import "fmt"
import "runtime"

func main() {
        runtime.GOMAXPROCS(runtime.NumCPU())
        fmt.Println(C.GoString(C.foo()))
}



c:\dd\go\src\github.com\lukehoban\cgotest>go build -ldflags="-v -linkmode external"
# github.com/lukehoban/cgotest
HEADER = -H11 -T0x401000 -D0x0 -R0x1000
searching for runtime.a in $WORK/runtime.a
searching for runtime.a in C:\Go/pkg/windows_amd64/runtime.a
 0.00 deadcode
 0.02 pclntab=346795 bytes, funcdata total 70844 bytes
 0.02 dodata
 0.02 reloc
 0.04 reloc
 0.05 asmb
 0.05 codeblk
 0.07 datblk
 0.07 sym
 0.07 dwarf
 0.07 headr
 0.07 symsize = 0
 0.08 symsize = 0
host link: "gcc" "-m64" "-gdwarf-2" "-mconsole" "-o" "C:\\Users\\lukeh\\AppData\\Local\\Temp\\go-build960901386\\github.com\\lukehoban\\cgotest\\_obj\\exe\\a.out.exe" "C:\\Users\\lukeh\\AppData\\Local\\Temp\\go-link-442716235/000000.o" "C:\\Users\\lukeh\\AppData\\Local\\Temp\\go-link-442716235/000001.o" "C:\\Users\\lukeh\\AppData\\Local\\Temp\\go-link-442716235/go.o" "-g" "-O2" "-g" "-O2" "-lm" "-mthreads" "-ladvapi32" "-lntdll" "-lws2_32" "-lkernel32" "-lwinmm"
 0.27 cpu time
45702 symbols
30924 liveness data

c:\dd\go\src\github.com\lukehoban\cgotest>objdump  --dwarf cgotest.exe | wc -l
3223

c:\dd\go\src\github.com\lukehoban\cgotest>objdump  --dwarf cgotest.exe | grep "runtime.buildVersion"



c:\dd\go\src\github.com\lukehoban\cgotest>go build -ldflags="-v -linkmode internal"
# github.com/lukehoban/cgotest
HEADER = -H11 -T0x401000 -D0x0 -R0x1000
searching for runtime.a in $WORK/runtime.a
searching for runtime.a in C:\Go/pkg/windows_amd64/runtime.a
 0.00 ldpe $WORK\github.com\lukehoban\cgotest.a(_all.o)
 0.00 ldpe C:\Go/pkg/windows_amd64/runtime/cgo.a(_all.o)
 0.00 deadcode
 0.02 pclntab=347739 bytes, funcdata total 70844 bytes
 0.02 dodata
 0.02 reloc
 0.04 reloc
 0.05 asmb
 0.05 codeblk
 0.08 datblk
 0.08 sym
 0.08 dwarf
 0.09 symsize = 0
 0.14 dwarf pass 2.
 0.16 headr
 0.16 symsize = 0
 0.16 symsize = 0
 0.17 cpu time
45695 symbols
30924 liveness data

c:\dd\go\src\github.com\lukehoban\cgotest>objdump  --dwarf cgotest.exe | wc -l
145046

c:\dd\go\src\github.com\lukehoban\cgotest>objdump  --dwarf cgotest.exe | grep "runtime.buildVersion"
    <4e0e0>   DW_AT_name        : runtime.buildVersion
    4e0df       runtime.buildVersion
@ianlancetaylor ianlancetaylor changed the title cmd/ld: no dwarf when using -linkmode=external on Windows cmd/link: no dwarf when using -linkmode=external on Windows Nov 5, 2015
@ianlancetaylor ianlancetaylor added this to the Unplanned milestone Nov 5, 2015
@alexbrainman
Copy link
Member

Sure. It is dup of #10776.

Alex

lukehoban added a commit to lukehoban/delve that referenced this issue Nov 5, 2015
Makes sure that CGO compilation still works under the debugger.

Work-around for golang/go#13154
@golang golang locked and limited conversation to collaborators Nov 4, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants