This seems like an XY Problem <https://xyproblem.info/>. Why are you
depending on a private implementation detail of the Go runtime? What
happens to your code if that function is removed or its behavior
changes? There is probably a better solution than creating that dependency.
If nothing else by keeping it private rather than exporting the symbol.

On Wed, Dec 25, 2024 at 10:35 PM zhengyao xie <jayant...@gmail.com> wrote:

> I would like to ask everyone for your help. In external code, I used
> `//go:linkname` directive as follows:
>
> ```go
> //go:linkname runtime_setEventErr runtime.(*pollDesc).setEventErr
> func runtime_setEventErr(pd runtimePollDesc, b bool, seq uintptr)
> ```
> The `runtime.(*pollDesc).setEventErr` function has been linked using
> linkname. It works well before go1.23, but since [go1.23 lock down future
> uses of linkname](https://github.com/golang/go/issues/67401), it can't
> work. I want to export this function within a private go runtime to remove
> the linkname check. How should I modify it? I have tried several ways but
> none of them seem to work:
>
> ```go
> //go:linkname setEventErr
> func (pd *pollDesc) setEventErr(b bool, seq uintptr)
>
> //go:linkname (*pollDesc).setEventErr
> func (pd *pollDesc) setEventErr(b bool, seq uintptr)
>
> //go:linkname runtime.(*pollDesc).setEventErr
> func (pd *pollDesc) setEventErr(b bool, seq uintptr)
> ```
>
> ```bash
> cd go/src && ./make.bash
> ```
>
> The error log is:
>
> ```
> /usr/local/go/src/runtime/netpoll.go:178:3: //go:linkname must refer to
> declared function or variable
> ```
>
> --
> You received this message because you are subscribed to the Google Groups
> "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to golang-nuts+unsubscr...@googlegroups.com.
> To view this discussion visit
> https://groups.google.com/d/msgid/golang-nuts/a7ba5ba3-31b0-465b-9706-12c528d0a098n%40googlegroups.com
> <https://groups.google.com/d/msgid/golang-nuts/a7ba5ba3-31b0-465b-9706-12c528d0a098n%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>


-- 
Kurtis Rader
Caretaker of the exceptional canines Junior and Hank

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion visit 
https://groups.google.com/d/msgid/golang-nuts/CABx2%3DD9SczDBkeyixZ_5gDPm7Q8fjxRQLZYJZdpY8LjbJx9oGQ%40mail.gmail.com.

Reply via email to