Skip to content

Commit

Permalink
unix: convert openbsd/mips64 to direct libc calls
Browse files Browse the repository at this point in the history
The current code has continued to work on OpenBSD, since it has been using
syscall(2) via libc. However, the system call numbers are still hardcoded in
golang.org/x/sys/unix. Various system call changes have been made in OpenBSD,
resulting in changes to the system call numbers and arguments, which now
fail when this package is used.

Switch to calling various system calls directly via libc, rather than calling
via libc using syscall(2).

Unfortunately, this will no longer work on upstream Go since the changes
needed to convert it to libc are still blocked pending review. This means
that we're in a less than ideal situation where upstream Go openbsd/mips64
does not work on any supported OpenBSD release (in fact has not since
OpenBSD 6.8, which was EOL over a year ago), however golang.org/x/sys/unix
is now unusable with the Go package that ships with supported releases via
OpenBSD ports. It would seem that being able to actually use Go software on
a supported OpenBSD release trumps maintaining compatibility with the
unusable upstream Go source.

Updates golang/go#36435

Change-Id: Id8947cd0e4e05709e96c3d4478ac8789b924d416
Reviewed-on: https://go-review.googlesource.com/c/sys/+/459497
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
  • Loading branch information
4a6f656c committed Dec 30, 2022
1 parent 3b1fc93 commit 7c6badc
Show file tree
Hide file tree
Showing 5 changed files with 1,342 additions and 140 deletions.
4 changes: 2 additions & 2 deletions unix/mkall.sh
Original file line number Diff line number Diff line change
Expand Up @@ -174,10 +174,10 @@ openbsd_arm64)
mktypes="GOARCH=$GOARCH go tool cgo -godefs -- -fsigned-char"
;;
openbsd_mips64)
mkasm="go run mkasm.go"
mkerrors="$mkerrors -m64"
mksyscall="go run mksyscall.go -openbsd"
mksyscall="go run mksyscall.go -openbsd -libc"
mksysctl="go run mksysctl_openbsd.go"
mksysnum="go run mksysnum.go 'https://cvsweb.openbsd.org/cgi-bin/cvsweb/~checkout~/src/sys/kern/syscalls.master'"
# Let the type of C char be signed for making the bare syscall
# API consistent across platforms.
mktypes="GOARCH=$GOARCH go tool cgo -godefs -- -fsigned-char"
Expand Down
4 changes: 2 additions & 2 deletions unix/syscall_openbsd_libc.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

//go:build openbsd && !mips64
// +build openbsd,!mips64
//go:build openbsd
// +build openbsd

package unix

Expand Down
Loading

0 comments on commit 7c6badc

Please sign in to comment.