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/cgo: specifying -g1 fails compilation #26144

Closed
benesch opened this issue Jun 29, 2018 · 1 comment
Closed

cmd/cgo: specifying -g1 fails compilation #26144

benesch opened this issue Jun 29, 2018 · 1 comment
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@benesch
Copy link
Contributor

benesch commented Jun 29, 2018

Please answer these questions before submitting your issue. Thanks!

What version of Go are you using (go version)?

go version devel +cbce223 Fri Jun 29 17:44:10 2018 +0000 linux/amd64

Does this issue reproduce with the latest release?

Yes.

What operating system and processor architecture are you using (go env)?

linux/amd64

What did you do?

I attempted to compile the following toy program

# t.go
package main

// void foo(void) {}
import "C"

func main() {
	C.foo();
}

with this command:

$ CGO_CFLAGS=-g1 go build

What did you expect to see?

A working program with minimal debug information.

What did you see instead?

A compilation failure:

# github.com/benesch/t
./t.go:7:2: call of non-function C.foo

Seems like cgo really needs debug information to be available. The problem changes with -g0:

$ CGO_CFLAGS=-g0 go build
# github.com/benesch/t
cannot load DWARF output from $WORK/b001//_cgo_.o: decoding dwarf section info at offset 0x0: too short

I don't particularly care if cgo silently upgrades the amount of debugging where necessary—or outright rejects -g0 and -g1. I just accidentally stumbled across this while trying to plumb some flags for msan through CockroachDB's C/C++ dependencies and it took a while to figure out what had gone wrong.

/cc @ianlancetaylor

@ianlancetaylor ianlancetaylor added the NeedsFix The path to resolution is known, but the work has not been done. label Jun 29, 2018
@ianlancetaylor ianlancetaylor added this to the Go1.12 milestone Jun 29, 2018
@gopherbot
Copy link

Change https://golang.org/cl/152165 mentions this issue: cmd/cgo: don't pass CGO_CFLAGS -g options to debug info generation

@golang golang locked and limited conversation to collaborators Dec 10, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

3 participants