You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
To be clear, the //go:cgo_import_dynamic and //go:cgo_import_static directives are not documented and are not supported in user code. We do not support code that uses them.
To be clear, the //go:cgo_import_dynamic and //go:cgo_import_static directives are not documented
I thought their documentation was found at cmd/cgo/doc.go?
and are not supported in user code. We do not support code that uses them.
I understand they are not supported in user code. However, they are used in the runtime and packages like golang.org/x/sys/unix which may be affected by this issue.
Currently, on macOS we only support cgo_import_dynamic for functions that are directly called. We don't yet support variables or taking address of a function. CL https://golang.org/cl/501855 may help. (Even with that, it probably only works if the code is written in a specific way.)
As @ianlancetaylor said, generally we don't support it in user code. We do handle the use cases that the runtime and syscall packages need. If you believe that is handled incorrectly, please file a specific issue for that. Thanks.
To be clear, the //go:cgo_import_dynamic and //go:cgo_import_static directives are not documented
I thought their documentation was found at cmd/cgo/doc.go?
True. I meant that they aren't publicly documented. The documentation in cmd/cgo/doc.go is in a comment that describes the implementation but is not part of the user visible docs (https://pkg.go.dev/cmd/cgo).
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
Run the following code with command:
go run -trimpath -gcflags="-std" -ldflags="-linkmode internal" main.go
What did you expect to see?
Program run without issue with output similar to what you get from external linking.
What did you see instead?
Program crashed when dereferencing the pointer.
additional information
If
cgo_import_dynamic
uses the one argument version the linker produces an undefined symbol.Of course, the std flag is only kept in both to limit the number of differences and doesn't affect the output. This issue affects purego#114.
The text was updated successfully, but these errors were encountered: