pkg / term

Package term manages POSIX terminals.
BSD 2-Clause "Simplified" License
393 stars 64 forks source link

termios does not build on mips64le #42

Closed liupeng0518 closed 4 years ago

liupeng0518 commented 5 years ago

$ go get github.com/pkg/term

# github.com/pkg/term/termios
term/termios/termios_linux.go:78:61: attr.Ispeed undefined (type *syscall.Termios has no field or method Ispeed)
term/termios/termios_linux.go:81:61: attr.Ospeed undefined (type *syscall.Termios has no field or method Ospeed)
gdamore commented 5 years ago

Wow. Those fields seem to be missing from the ztypes_linux_mips64le.go file. In fact, they don't seem to exist on modern Linux at all (in the underlying asm-generic/termios.h header). I'm astonished they are present in the old code -- man pages recommend using cfgetospeed and cfgetispeed to access these (presumably from the c_lflag bits.)

gdamore commented 5 years ago

So apparently Linux differs from one architecture to another in this regard. It will be necessary to have different versions of this code for different architectures. I'm not even sure how we can use build tags to select by architecture.

gdamore commented 5 years ago

Scanning a little, it affects all the MIPS variants of Linux, and nothing else (that is supported by the version of go that I have on the system).

Fixing will probably mean relying upon cgo and cfgetispeed etc. The other options involve a different flavor of the termios structure and a different ioctl to access them -- and those different items are not part of the sys package.

gdamore commented 5 years ago

Well, it looks like the newer golang.org/x/sys package has them... interesting.

liupeng0518 commented 5 years ago

Well, it looks like the newer golang.org/x/sys package has them... interesting.

Thanks.

gdamore commented 5 years ago

What I've done for my use case was use a different approach, using bitmasks against CBAUD. That won't cover everything, but it's good enough for my use case.

joshhansen commented 4 years ago

I ran into this this trying to build a tool to run on my router. Is there a workaround known or any expectation of providing mips support in the future?