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

x/sys/unix: add missing values from syscall pkg to enable complete migration #19697

Open
laboger opened this issue Mar 24, 2017 · 9 comments
Open
Labels
compiler/runtime Issues related to the Go compiler and/or runtime.
Milestone

Comments

@laboger
Copy link
Contributor

laboger commented Mar 24, 2017

Please answer these questions before submitting your issue. Thanks!

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

go tip

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

Ubuntu 16.04 and Fedora22, Red Hat 7.x on ppc64le & ppc64

What did you do?

Trying to migrate Go code from syscall to sys/unix as described in the golang syscall package documentation https://golang.org/pkg/syscall/. This was the suggested solution for issue #19560. While it is possible to fix just the case that is described in this issue, that is not a complete solution. We want to avoid hitting another issue because of using syscall, so we'd like to migrate use of syscall to sys/unix. Also having a mixture of references to syscall and sys/unix is confusing since then it is not clear when to use which one.

Issues with migrating from syscall to sys/unix:

  1. syscall.Signal and syscall.Errno need to have a type defined within sys/unix so user code doesn't need to use these to convert signals and errnos to the appropriate integer type for the platform.

I was going to try a change for this based on a suggestion by Ian, but I'm not able to get the generator scripts in sys/unix to work. I get these errors:

GOOS=linux GOARCH=ppc64le ./mkall.sh
could not determine kind of name for C.TIOCGETC
could not determine kind of name for C.TIOCGETP
could not determine kind of name for C.TIOCGLTC
could not determine kind of name for C.TIOCSETC
could not determine kind of name for C.TIOCSETN
could not determine kind of name for C.TIOCSETP
could not determine kind of name for C.TIOCSLTC

This happened on Fedora22 and Ubuntu 16.04. If I could get some direction on what this might be that would help.

  1. The structure SysProcAttr is defined in syscall but not in sys/unix. It is used in the os package, so I don't think it should be moved to sys/unix. Seems like it needs an equivalent declaration in os.
@gopherbot gopherbot added this to the Unreleased milestone Mar 24, 2017
@ianlancetaylor
Copy link
Contributor

I think that syscall.SysProcAttr is a different issue to be dealt with differently. In fact I don't see any reason to migrate that to x/sys/unix. It's fine where it is.

@clnperez
Copy link

Hm. Wouldn't that mean still using syscall then? Or is there an alternative for users that's outside of syscall for syscall.SysProcAttr?

@bradfitz
Copy link
Contributor

@clnperez, yes, still using syscall. There's no alternative. It's part of the API: https://golang.org/pkg/os/exec/#Cmd.SysProcAttr

@laboger
Copy link
Contributor Author

laboger commented Mar 28, 2017

Then those things that can't be migrated from syscall to sys/unix should be documented so it is clear. Right now the syscall package documentation just says to migrate from syscall to sys/unix. Maybe that paragraph just needs a statement to identify the exceptions.

@bradfitz
Copy link
Contributor

That is the only case:

$ cd $GOROOT/api
$ git grep syscall | grep -v ":pkg syscall" | grep txt:pkg
go1.txt:pkg os, type ProcAttr struct, Sys *syscall.SysProcAttr
go1.txt:pkg os/exec, type Cmd struct, SysProcAttr *syscall.SysProcAttr

If you want to add something minimal to the pkg syscall docs, feel free to send a CL.

@laboger
Copy link
Contributor Author

laboger commented Mar 29, 2017

Apparently at this point in time the generator scripts in the syscall pkg and x/sys/unix are not in sync with the z files they generate. I could make the necessary changes to add definitions of Signal and Errno in sys/unix but don't know how to correctly generate all the right files without a lot of extra unrelated changes or lots of manual changes.

Will changing the comments in syscall/syscall.go update the pkg syscall docs?

@bradfitz
Copy link
Contributor

@laboger, please wait for https://go-review.googlesource.com/c/37943/

@bradfitz
Copy link
Contributor

Will changing the comments in syscall/syscall.go update the pkg syscall docs?

Yes. You can send a CL for that part at least.

@gopherbot
Copy link

Change https://golang.org/cl/80955 mentions this issue: unix: add netlink functions on Linux

@gopherbot gopherbot added the compiler/runtime Issues related to the Go compiler and/or runtime. label Jul 7, 2022
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
Status: Triage Backlog
Development

No branches or pull requests

5 participants