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

runtime: multiple definition of 'go:itab.runtime.errorString,error' #70220

Closed
wingrez opened this issue Nov 6, 2024 · 4 comments
Closed

runtime: multiple definition of 'go:itab.runtime.errorString,error' #70220

wingrez opened this issue Nov 6, 2024 · 4 comments
Labels
compiler/runtime Issues related to the Go compiler and/or runtime.

Comments

@wingrez
Copy link
Contributor

wingrez commented Nov 6, 2024

Go version

go1.23.2

Output of go env in your module/workspace:

Doesn't matter.

What did you do?

I'm trying to customize some of the features in the runtime. However I ran into a problem.

To simplify, here is an example.

Add this function to runtime.

func Demo() error {
	return errorString("hello")
}

main.go

package main

import "C"
import (
	_ "plugin"
	"runtime"
)

func main() {
	err := runtime.Demo()
	println(err)
}

Build using go build main.go.

What did you see happen?

go/pkg/tool/linux_arm64/link: running gcc failed: exit status 1
/usr/bin/ld.gold: error: /tmp/go-link-2461440430/go.o: multiple definition of 'go:itab.runtime.errorString,error'
/usr/bin/ld.gold: /tmp/go-link-2461440430/go.o: previous definition here
collect2: error: ld returned 1 exit status

What did you expect to see?

Build success

@gopherbot gopherbot added the compiler/runtime Issues related to the Go compiler and/or runtime. label Nov 6, 2024
@gabyhelp
Copy link

gabyhelp commented Nov 6, 2024

Related Issues and Documentation

(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.)

@wingrez
Copy link
Contributor Author

wingrez commented Nov 6, 2024

There are two duplicate symbols in go.o: go:itab.runtime.errorString,error, and their attributes are Global.

@seankhliao
Copy link
Member

If you look at errorString, it's only used for panics.

Unlike many projects, the Go project does not use GitHub Issues for general discussion or asking questions. GitHub Issues are used for tracking bugs and proposals only.

For questions please refer to https://github.com/golang/go/wiki/Questions

@seankhliao seankhliao closed this as not planned Won't fix, can't repro, duplicate, stale Nov 6, 2024
@randall77
Copy link
Contributor

This is kind of odd, although I wouldn't call it a bug either. Certainly we don't support modifying the runtime like this.

I think the trigger is because Demo is being inlined. That means we get a runtime symbol defined in both the runtime .o and the main package .o.
I don't understand why that is a problem, though. Itab symbols like this should me marked DUPOK and deduplicated. Maybe something about the buildmode loses that DUPOK mark somewhere?

In any case, marking Demo with //go:noinline fixes it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler/runtime Issues related to the Go compiler and/or runtime.
Projects
None yet
Development

No branches or pull requests

5 participants