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

gccgo: build failed with undefined func value symbol due to inlining #33739

Closed
cherrymui opened this issue Aug 20, 2019 · 2 comments
Closed

gccgo: build failed with undefined func value symbol due to inlining #33739

cherrymui opened this issue Aug 20, 2019 · 2 comments
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@cherrymui
Copy link
Member

cherrymui commented Aug 20, 2019

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

gccgo (GCC) 10.0.0 20190816 (experimental)

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

linux/amd64

What did you do?

Build a program with the main package importing package p:

package p

package p

func F() func() {
	return f
}

func f() {}

package main

package main

import "p"

func main() {
	p.F()()
}

What did you expect to see?

build succeeds.

What did you see instead?

# main
/tmp/src/main/main.go:6: error: undefined reference to 'p.f..f'
/tmp/src/main/main.go:6: error: undefined reference to 'p.f..f'
collect2: error: ld returned 1 exit status

Package p defines a function F, which references an unexported function by func value (f). When compiling main, p.F is inlined. As a result main has a direct reference to the func value symbol p.f..f. But p.f..f is private in the object file of package p. This causes the linking to fail.

If a func value is referenced by an inlineable function, I think we need to export the func value symbol.

@gopherbot gopherbot added this to the Gccgo milestone Aug 20, 2019
@bcmills bcmills added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Aug 20, 2019
@gopherbot
Copy link

Change https://golang.org/cl/191001 mentions this issue: test: add test that failed with gccgo

@gopherbot
Copy link

Change https://golang.org/cl/191037 mentions this issue: compiler: if hidden function referenced by inline, don't hide descriptor

kraj pushed a commit to kraj/gcc that referenced this issue Aug 21, 2019
…ptor

    
    Fixes golang/go#33739
    
    Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/191037


git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@274800 138bc75d-0d04-0410-961f-82ee72b054a4
gopherbot pushed a commit that referenced this issue Aug 28, 2019
Updates #33739

Change-Id: Ib7ce4bc51972fe49998f37f6e27baa6a2a036d5e
Reviewed-on: https://go-review.googlesource.com/c/go/+/191001
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
tomocy pushed a commit to tomocy/go that referenced this issue Sep 1, 2019
Updates golang#33739

Change-Id: Ib7ce4bc51972fe49998f37f6e27baa6a2a036d5e
Reviewed-on: https://go-review.googlesource.com/c/go/+/191001
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
t4n6a1ka pushed a commit to t4n6a1ka/go that referenced this issue Sep 5, 2019
Updates golang#33739

Change-Id: Ib7ce4bc51972fe49998f37f6e27baa6a2a036d5e
Reviewed-on: https://go-review.googlesource.com/c/go/+/191001
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
@golang golang locked and limited conversation to collaborators Aug 20, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

3 participants