golang / go

The Go programming language
https://go.dev
BSD 3-Clause "New" or "Revised" License
123.92k stars 17.65k forks source link

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

Open wingrez opened 2 hours ago

wingrez commented 2 hours ago

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

gabyhelp commented 2 hours ago

Related Issues and Documentation

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

wingrez commented 1 hour ago

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