unix: generate linux/sparc64 go files using Docker

With cgo supporting sparc64 as of CL 102555 and CL 132155, the Docker
based build system can be used to generate file for linux/sparc64 as
well.

Updates golang/go#15282

Change-Id: I109e55f39d3229b24b0029c42074e439c6c54dc8
Reviewed-on: https://go-review.googlesource.com/c/102655
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
Tobias Klauser
2018-12-21 14:31:28 +00:00
committed by Tobias Klauser
parent a79f1b1907
commit b4a75ba826
10 changed files with 3867 additions and 1909 deletions
+2 -2
View File
@@ -14,7 +14,7 @@ migrating the build system to use containers so the builds are reproducible.
This is being done on an OS-by-OS basis. Please update this documentation as This is being done on an OS-by-OS basis. Please update this documentation as
components of the build system change. components of the build system change.
### Old Build System (currently for `GOOS != "Linux" || GOARCH == "sparc64"`) ### Old Build System (currently for `GOOS != "linux"`)
The old build system generates the Go files based on the C header files The old build system generates the Go files based on the C header files
present on your system. This means that files present on your system. This means that files
@@ -34,7 +34,7 @@ your specific system. Running `mkall.sh -n` shows the commands that will be run.
Requirements: bash, perl, go Requirements: bash, perl, go
### New Build System (currently for `GOOS == "Linux" && GOARCH != "sparc64"`) ### New Build System (currently for `GOOS == "linux"`)
The new build system uses a Docker container to generate the go files directly The new build system uses a Docker container to generate the go files directly
from source checkouts of the kernel and various system libraries. This means from source checkouts of the kernel and various system libraries. This means
+11 -10
View File
@@ -52,8 +52,9 @@ type target struct {
Bits int Bits int
} }
// List of all Linux targets supported by the go compiler. sparc64 is not // List of all Linux targets supported by the go compiler. Currently, riscv64
// currently supported, though a port is in progress. // and sparc64 are not fully supported, but there is enough support already to
// generate Go type and error definitions.
var targets = []target{ var targets = []target{
{ {
GoArch: "386", GoArch: "386",
@@ -133,13 +134,13 @@ var targets = []target{
SignedChar: true, SignedChar: true,
Bits: 64, Bits: 64,
}, },
// { {
// GoArch: "sparc64", GoArch: "sparc64",
// LinuxArch: "sparc", LinuxArch: "sparc",
// GNUArch: "sparc64-linux-gnu", GNUArch: "sparc64-linux-gnu",
// BigEndian: true, BigEndian: true,
// Bits: 64, Bits: 64,
// }, },
} }
// ptracePairs is a list of pairs of targets that can, in some cases, // ptracePairs is a list of pairs of targets that can, in some cases,
@@ -532,7 +533,7 @@ func (t *target) mksyscallFlags() (flags []string) {
} }
} }
// This flag menas a 64-bit value should use (even, odd)-pair. // This flag means a 64-bit value should use (even, odd)-pair.
if t.GoArch == "arm" || (t.LinuxArch == "mips" && t.Bits == 32) { if t.GoArch == "arm" || (t.LinuxArch == "mips" && t.Bits == 32) {
flags = append(flags, "-arm") flags = append(flags, "-arm")
} }
+21
View File
@@ -57,7 +57,28 @@ package unix
#include <linux/perf_event.h> #include <linux/perf_event.h>
#include <linux/rtnetlink.h> #include <linux/rtnetlink.h>
#include <linux/stat.h> #include <linux/stat.h>
#if defined(__sparc__)
// On sparc{,64}, the kernel defines struct termios2 itself which clashes with the
// definition in glibc. Duplicate the kernel version here.
#if defined(__arch64__)
typedef unsigned int tcflag_t;
#else
typedef unsigned long tcflag_t;
#endif
struct termios2 {
tcflag_t c_iflag;
tcflag_t c_oflag;
tcflag_t c_cflag;
tcflag_t c_lflag;
unsigned char c_line;
unsigned char c_cc[19];
unsigned int c_ispeed;
unsigned int c_ospeed;
};
#else
#include <asm/termbits.h> #include <asm/termbits.h>
#endif
#include <asm/ptrace.h> #include <asm/ptrace.h>
#include <time.h> #include <time.h>
#include <unistd.h> #include <unistd.h>
+2 -9
View File
@@ -46,8 +46,8 @@ case "$#" in
exit 2 exit 2
esac esac
if [[ "$GOOS" = "linux" ]] && [[ "$GOARCH" != "sparc64" ]]; then if [[ "$GOOS" = "linux" ]]; then
# Use then new build system # Use the Docker-based build system
# Files generated through docker (use $cmd so you can Ctl-C the build or run) # Files generated through docker (use $cmd so you can Ctl-C the build or run)
$cmd docker build --tag generate:$GOOS $GOOS $cmd docker build --tag generate:$GOOS $GOOS
$cmd docker run --interactive --tty --volume $(dirname "$(readlink -f "$0")"):/build generate:$GOOS $cmd docker run --interactive --tty --volume $(dirname "$(readlink -f "$0")"):/build generate:$GOOS
@@ -121,13 +121,6 @@ freebsd_arm)
# API consistent across platforms. # API consistent across platforms.
mktypes="GOARCH=$GOARCH go tool cgo -godefs -- -fsigned-char" mktypes="GOARCH=$GOARCH go tool cgo -godefs -- -fsigned-char"
;; ;;
linux_sparc64)
GOOSARCH_in=syscall_linux_sparc64.go
unistd_h=/usr/include/sparc64-linux-gnu/asm/unistd.h
mkerrors="$mkerrors -m64"
mksysnum="./mksysnum_linux.pl $unistd_h"
mktypes="GOARCH=$GOARCH go tool cgo -godefs"
;;
netbsd_386) netbsd_386)
mkerrors="$mkerrors -m32" mkerrors="$mkerrors -m32"
mksyscall="go run mksyscall.go -l32 -netbsd" mksyscall="go run mksyscall.go -l32 -netbsd"
+12 -6
View File
@@ -17,12 +17,10 @@ if test -z "$GOARCH" -o -z "$GOOS"; then
fi fi
# Check that we are using the new build system if we should # Check that we are using the new build system if we should
if [[ "$GOOS" = "linux" ]] && [[ "$GOARCH" != "sparc64" ]]; then if [[ "$GOOS" = "linux" ]] && [[ "$GOLANG_SYS_BUILD" != "docker" ]]; then
if [[ "$GOLANG_SYS_BUILD" != "docker" ]]; then echo 1>&2 "In the Docker based build system, mkerrors should not be called directly."
echo 1>&2 "In the new build system, mkerrors should not be called directly." echo 1>&2 "See README.md"
echo 1>&2 "See README.md" exit 1
exit 1
fi
fi fi
if [[ "$GOOS" = "aix" ]]; then if [[ "$GOOS" = "aix" ]]; then
@@ -223,7 +221,15 @@ struct ltchars {
#include <linux/if_xdp.h> #include <linux/if_xdp.h>
#include <mtd/ubi-user.h> #include <mtd/ubi-user.h>
#include <net/route.h> #include <net/route.h>
#if defined(__sparc__)
// On sparc{,64}, the kernel defines struct termios2 itself which clashes with the
// definition in glibc. As only the error constants are needed here, include the
// generic termibits.h (which is included by termbits.h on sparc).
#include <asm-generic/termbits.h>
#else
#include <asm/termbits.h> #include <asm/termbits.h>
#endif
#ifndef MSG_FASTOPEN #ifndef MSG_FASTOPEN
#define MSG_FASTOPEN 0x20000000 #define MSG_FASTOPEN 0x20000000
+3 -3
View File
@@ -28,10 +28,10 @@ func main() {
if goarch == "" { if goarch == "" {
goarch = os.Getenv("GOARCH") goarch = os.Getenv("GOARCH")
} }
// Check that we are using the new build system if we should be. // Check that we are using the Docker-based build system if we should be.
if goos == "linux" && goarch != "sparc64" { if goos == "linux" {
if os.Getenv("GOLANG_SYS_BUILD") != "docker" { if os.Getenv("GOLANG_SYS_BUILD") != "docker" {
os.Stderr.WriteString("In the new build system, mkpost should not be called directly.\n") os.Stderr.WriteString("In the Docker-based build system, mkpost should not be called directly.\n")
os.Stderr.WriteString("See README.md\n") os.Stderr.WriteString("See README.md\n")
os.Exit(1) os.Exit(1)
} }
+3 -3
View File
@@ -93,10 +93,10 @@ func main() {
goarch = os.Getenv("GOARCH") goarch = os.Getenv("GOARCH")
} }
// Check that we are using the new build system if we should // Check that we are using the Docker-based build system if we should
if goos == "linux" && goarch != "sparc64" { if goos == "linux" {
if os.Getenv("GOLANG_SYS_BUILD") != "docker" { if os.Getenv("GOLANG_SYS_BUILD") != "docker" {
fmt.Fprintf(os.Stderr, "In the new build system, mksyscall should not be called directly.\n") fmt.Fprintf(os.Stderr, "In the Docker-based build system, mksyscall should not be called directly.\n")
fmt.Fprintf(os.Stderr, "See README.md\n") fmt.Fprintf(os.Stderr, "See README.md\n")
os.Exit(1) os.Exit(1)
} }
+2420 -1776
View File
File diff suppressed because it is too large Load Diff
+4 -2
View File
@@ -1,5 +1,5 @@
// mksysnum_linux.pl -Ilinux/usr/include -m64 -D__arch64__ linux/usr/include/asm/unistd.h // go run linux/mksysnum.go -Wall -Werror -static -I/tmp/include /tmp/include/asm/unistd.h
// Code generated by the command above; DO NOT EDIT. // Code generated by the command above; see README.md. DO NOT EDIT.
// +build sparc64,linux // +build sparc64,linux
@@ -345,4 +345,6 @@ const (
SYS_COPY_FILE_RANGE = 357 SYS_COPY_FILE_RANGE = 357
SYS_PREADV2 = 358 SYS_PREADV2 = 358
SYS_PWRITEV2 = 359 SYS_PWRITEV2 = 359
SYS_STATX = 360
SYS_IO_PGETEVENTS = 361
) )
File diff suppressed because it is too large Load Diff