Commit b4a75ba8 authored by Tobias Klauser's avatar Tobias Klauser Committed by Tobias Klauser

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: 's avatarIan Lance Taylor <iant@golang.org>
parent a79f1b19
......@@ -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
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
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
### 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
from source checkouts of the kernel and various system libraries. This means
......
......@@ -52,8 +52,9 @@ type target struct {
Bits int
}
// List of all Linux targets supported by the go compiler. sparc64 is not
// currently supported, though a port is in progress.
// List of all Linux targets supported by the go compiler. Currently, riscv64
// and sparc64 are not fully supported, but there is enough support already to
// generate Go type and error definitions.
var targets = []target{
{
GoArch: "386",
......@@ -133,13 +134,13 @@ var targets = []target{
SignedChar: true,
Bits: 64,
},
// {
// GoArch: "sparc64",
// LinuxArch: "sparc",
// GNUArch: "sparc64-linux-gnu",
// BigEndian: true,
// Bits: 64,
// },
{
GoArch: "sparc64",
LinuxArch: "sparc",
GNUArch: "sparc64-linux-gnu",
BigEndian: true,
Bits: 64,
},
}
// 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) {
flags = append(flags, "-arm")
}
......
......@@ -57,7 +57,28 @@ package unix
#include <linux/perf_event.h>
#include <linux/rtnetlink.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>
#endif
#include <asm/ptrace.h>
#include <time.h>
#include <unistd.h>
......
......@@ -46,8 +46,8 @@ case "$#" in
exit 2
esac
if [[ "$GOOS" = "linux" ]] && [[ "$GOARCH" != "sparc64" ]]; then
# Use then new build system
if [[ "$GOOS" = "linux" ]]; then
# Use the Docker-based build system
# Files generated through docker (use $cmd so you can Ctl-C the build or run)
$cmd docker build --tag generate:$GOOS $GOOS
$cmd docker run --interactive --tty --volume $(dirname "$(readlink -f "$0")"):/build generate:$GOOS
......@@ -121,13 +121,6 @@ freebsd_arm)
# API consistent across platforms.
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)
mkerrors="$mkerrors -m32"
mksyscall="go run mksyscall.go -l32 -netbsd"
......
......@@ -17,12 +17,10 @@ if test -z "$GOARCH" -o -z "$GOOS"; then
fi
# Check that we are using the new build system if we should
if [[ "$GOOS" = "linux" ]] && [[ "$GOARCH" != "sparc64" ]]; then
if [[ "$GOLANG_SYS_BUILD" != "docker" ]]; then
echo 1>&2 "In the new build system, mkerrors should not be called directly."
echo 1>&2 "See README.md"
exit 1
fi
if [[ "$GOOS" = "linux" ]] && [[ "$GOLANG_SYS_BUILD" != "docker" ]]; then
echo 1>&2 "In the Docker based build system, mkerrors should not be called directly."
echo 1>&2 "See README.md"
exit 1
fi
if [[ "$GOOS" = "aix" ]]; then
......@@ -223,7 +221,15 @@ struct ltchars {
#include <linux/if_xdp.h>
#include <mtd/ubi-user.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>
#endif
#ifndef MSG_FASTOPEN
#define MSG_FASTOPEN 0x20000000
......
......@@ -28,10 +28,10 @@ func main() {
if goarch == "" {
goarch = os.Getenv("GOARCH")
}
// Check that we are using the new build system if we should be.
if goos == "linux" && goarch != "sparc64" {
// Check that we are using the Docker-based build system if we should be.
if goos == "linux" {
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.Exit(1)
}
......
......@@ -93,10 +93,10 @@ func main() {
goarch = os.Getenv("GOARCH")
}
// Check that we are using the new build system if we should
if goos == "linux" && goarch != "sparc64" {
// Check that we are using the Docker-based build system if we should
if goos == "linux" {
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")
os.Exit(1)
}
......
This source diff could not be displayed because it is too large. You can view the blob instead.
// mksysnum_linux.pl -Ilinux/usr/include -m64 -D__arch64__ linux/usr/include/asm/unistd.h
// Code generated by the command above; DO NOT EDIT.
// go run linux/mksysnum.go -Wall -Werror -static -I/tmp/include /tmp/include/asm/unistd.h
// Code generated by the command above; see README.md. DO NOT EDIT.
// +build sparc64,linux
......@@ -345,4 +345,6 @@ const (
SYS_COPY_FILE_RANGE = 357
SYS_PREADV2 = 358
SYS_PWRITEV2 = 359
SYS_STATX = 360
SYS_IO_PGETEVENTS = 361
)
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment