From 0c7ac182ae636c7238dd46dfbe3dc65eba6b673d Mon Sep 17 00:00:00 2001 From: James Davies Date: Sun, 21 Nov 2021 21:48:57 +0000 Subject: [PATCH] Add go. Update cmake. --- extra/cmake/checksums | 2 +- extra/cmake/version | 2 +- extra/go/build | 96 ++++++++++++++++++++++++++++++ extra/go/checksums | 7 +++ extra/go/patches/posix-build.patch | 62 +++++++++++++++++++ extra/go/sources | 7 +++ extra/go/version | 1 + 7 files changed, 175 insertions(+), 2 deletions(-) create mode 100755 extra/go/build create mode 100644 extra/go/checksums create mode 100644 extra/go/patches/posix-build.patch create mode 100644 extra/go/sources create mode 100644 extra/go/version diff --git a/extra/cmake/checksums b/extra/cmake/checksums index 790860c1..505ac83d 100644 --- a/extra/cmake/checksums +++ b/extra/cmake/checksums @@ -1,3 +1,3 @@ -d14d06df4265134ee42c4d50f5a60cb8b471b7b6a47da8e5d914d49dd783794f +998c7ba34778d2dfdb3df8a695469e24b11e2bfa21fbe41b361a3f45e1c9345e 93f5582efd076673f9bcb3e639bd594e378954a5a3130e5921027ede23c3325c 3bdd84a118d787fea57f40601534d16d27c0644e5d9533dc9237e9a01352c2f0 diff --git a/extra/cmake/version b/extra/cmake/version index f1ad24dd..8d8e0b04 100644 --- a/extra/cmake/version +++ b/extra/cmake/version @@ -1 +1 @@ -3.21.3 1 +3.22.0 1 diff --git a/extra/go/build b/extra/go/build new file mode 100755 index 00000000..ee51e39b --- /dev/null +++ b/extra/go/build @@ -0,0 +1,96 @@ +#!/bin/sh -e + +get_arch(){ + case "$1" in + aarch64) echo "arm64" ;; + armv7) echo "arm" ;; + i686) echo "386" ;; + x86_64) echo "amd64" ;; + powerpc64le) echo "ppc64le" ;; + powerpc64) echo "ppc64" ;; + riscv64) echo "riscv64" ;; + *) echo "Unsupported architecture $1"; exit 1;; + esac +} + +patch -p1 < posix-build.patch + +# Disable stripping of binaries. +# This breaks Go. +:> nostrip + +# If building on arm, i386 or amd64 we can bootstrap from c using +# the go 1.4 source. Other arch require a binary bootstrap. +if [ "$KISS_XBUILD_ARCH" = "x86_64" ] || [ "$KISS_XBUILD_ARCH" = "i686" ] || [ "$KISS_XBUILD_ARCH" = "armv7" ]; then + echo "Building go bootstrap from source" + + export GOROOT=$PWD/go1.4-bootstrap + export GOROOT_FINAL=$PWD/lib/go-bootstrap + mkdir -p lib/go-bootstrap + ( + cd "$GOROOT/src" + CC=clang CFLAGS= LDFLAGS= ./make.bash + cd .. + cp -a bin pkg src ../lib/go-bootstrap + ) + export GOROOT_BOOTSTRAP=$PWD/lib/go-bootstrap +else + echo "Using binary go for bootstrap" + export GOROOT_BOOTSTRAP="$PWD/$(get_arch $KISS_XBUILD_ARCH)-bootstrap" +fi + +export CC="clang" +export CC_FOR_TARGET="$CC" +export GOHOSTOS=linux +export GOHOSTARCH="$(get_arch $KISS_XBUILD_ARCH)" +export GOOS=linux +export GOARCH="$(get_arch $KISS_XHOST_ARCH)" +export GO_LDFLAGS="-w -s" +export GOROOT_FINAL=/usr/lib/go +export GOROOT=$PWD/go-current + +# Build go for the target +( + cd "$GOROOT/src" + ./make.bash --no-clean -v +) + +cd "$GOROOT" + +mkdir -p "$1/usr/bin" "$1/usr/lib/go/bin" + +# Install main file +if [ "$KISS_XBUILD_TRIPLE" != "$KISS_XHOST_TRIPLE" ]; then + install -m755 "bin/linux_$GOARCH/go" "$1/usr/lib/go/bin/go" + install -m755 "bin/linux_$GOARCH/gofmt" "$1/usr/lib/go/bin/gofmt" +else + install -m755 "bin/go" "$1/usr/lib/go/bin/go" + install -m755 "bin/gofmt" "$1/usr/lib/go/bin/gofmt" +fi + +# Create standard symlinks +ln -s "/usr/lib/go/bin/go" "$1/usr/bin" +ln -s "/usr/lib/go/bin/gofmt" "$1/usr/bin" + +cp -a misc pkg src lib "$1/usr/lib/go" + +# Remove unneeded files. +rm -f "$1/usr/share/go/doc/articles/wiki/get.bin" +rm -f "$1/usr/lib/go/pkg/tool/"*/api +rm -rf "$1/usr/lib/go/pkg/bootstrap" +rm -rf "$1/usr/lib/go/pkg/obj" + +# Remove tests. +for path in "$1/usr/lib/go/src" "$1/usr/lib/go/misc/cgo" +do + find "$path" -type f -a -name \*_test.go -depth -exec rm {} + + find "$path" -type f -a -name \*.bash -depth -exec rm {} + + find "$path" -type f -a -name \*.bat -depth -exec rm {} + + find "$path" -type f -a -name \*.rc -depth -exec rm {} + +done + + +find . -type d -a -name testdata | + while read -r dir; do + rm -rf "$dir" + done diff --git a/extra/go/checksums b/extra/go/checksums new file mode 100644 index 00000000..ffb3cbe1 --- /dev/null +++ b/extra/go/checksums @@ -0,0 +1,7 @@ +2255eb3e4e824dd7d5fcdc2e7f84534371c186312e546fb1086a34c17752f431 +f4ff5b5eb3a3cae1c993723f3eab519c5bae18866b5e5f96fe1102f0cb5c3e52 +47e1bd9302748e22b63dab7c1413f8ac2d538a598d1cf344dd2e29f287b4bacb +f2e3e5841257281d963026ea27e329d75f6fdebd6b6aa1b105b0a862cab86db0 +a1d8250f8230e0043530479a98c81627ec75d1a1ccb59ebc62463acab7182da1 +dfffcad593c41e06b7e861803d2ac1b0f3fc6ab17a4bd1630b6463627bc9ca19 +5203efb9255b2e32ea69a8fc796192fa48e2e954a44f6b12d1df1735bc18ec99 diff --git a/extra/go/patches/posix-build.patch b/extra/go/patches/posix-build.patch new file mode 100644 index 00000000..b84bccc3 --- /dev/null +++ b/extra/go/patches/posix-build.patch @@ -0,0 +1,62 @@ +diff --git a/go-current/src/make.bash b/go-current/src/make.bash +index 880a0f4..f27c355 100755 +--- a/go-current/src/make.bash ++++ b/go-current/src/make.bash +@@ -1,4 +1,4 @@ +-#!/usr/bin/env bash ++#!/bin/sh + # Copyright 2009 The Go Authors. All rights reserved. + # Use of this source code is governed by a BSD-style + # license that can be found in the LICENSE file. +@@ -154,7 +154,7 @@ fi + + export GOROOT_BOOTSTRAP=${GOROOT_BOOTSTRAP:-$HOME/go1.4} + export GOROOT="$(cd .. && pwd)" +-IFS=$'\n'; for go_exe in $(type -ap go); do ++for go_exe in $(command -v go); do + if [ ! -x "$GOROOT_BOOTSTRAP/bin/go" ]; then + goroot=$(GOROOT='' GOOS='' GOARCH='' "$go_exe" env GOROOT) + if [ "$goroot" != "$GOROOT" ]; then +diff --git a/go1.4-bootstrap/src/make.bash b/go1.4-bootstrap/src/make.bash +index 104c3ba..043d38a 100755 +--- a/go1.4-bootstrap/src/make.bash ++++ b/go1.4-bootstrap/src/make.bash +@@ -1,4 +1,4 @@ +-#!/usr/bin/env bash ++#!/bin/sh + # Copyright 2009 The Go Authors. All rights reserved. + # Use of this source code is governed by a BSD-style + # license that can be found in the LICENSE file. +@@ -43,7 +43,7 @@ + # This is used by cgo. Default is CC. + # + # CXX_FOR_TARGET: Command line to run to compile C++ code for GOARCH. +-# This is used by cgo. Default is CXX, or, if that is not set, ++# This is used by cgo. Default is CXX, or, if that is not set, + # "g++" or "clang++". + # + # GO_DISTFLAGS: extra flags to provide to "dist bootstrap". Use "-s" +@@ -102,7 +102,7 @@ done + # Test for debian/kFreeBSD. + # cmd/dist will detect kFreeBSD as freebsd/$GOARCH, but we need to + # disable cgo manually. +-if [ "$(uname -s)" == "GNU/kFreeBSD" ]; then ++if [ "$(uname -s)" = "GNU/kFreeBSD" ]; then + export CGO_ENABLED=0 + fi + +@@ -122,12 +122,12 @@ case "$GOHOSTARCH" in + 386) mflag=-m32;; + amd64) mflag=-m64;; + esac +-if [ "$(uname)" == "Darwin" ]; then ++if [ "$(uname)" = "Darwin" ]; then + # golang.org/issue/5261 + mflag="$mflag -mmacosx-version-min=10.6" + fi + # if gcc does not exist and $CC is not set, try clang if available. +-if [ -z "$CC" -a -z "$(type -t gcc)" -a -n "$(type -t clang)" ]; then ++if [ -z "$CC" -a -z "$(command -v gcc)" -a -n "$(command -v clang)" ]; then + export CC=clang CXX=clang++ + fi + ${CC:-gcc} $mflag -O2 -Wall -Werror -o cmd/dist/dist -Icmd/dist "$DEFGOROOT" cmd/dist/*.c diff --git a/extra/go/sources b/extra/go/sources new file mode 100644 index 00000000..7eec043c --- /dev/null +++ b/extra/go/sources @@ -0,0 +1,7 @@ +https://golang.org/dl/go1.17.2.src.tar.gz go-current/ +https://dl.google.com/go/go1.4-bootstrap-20171003.tar.gz go1.4-bootstrap/ +file:///home/pokey/temp/go/go-linux-arm64-bootstrap.tbz arm64-bootstrap/ +file:///home/pokey/temp/go/go-linux-ppc64le-bootstrap.tbz ppc64le-bootstrap/ +file:///home/pokey/temp/go/go-linux-ppc64-bootstrap.tbz ppc64-bootstrap/ +file:///home/pokey/temp/go/go-linux-riscv64-bootstrap.tbz riscv64-bootstrap/ +patches/posix-build.patch diff --git a/extra/go/version b/extra/go/version new file mode 100644 index 00000000..a9652518 --- /dev/null +++ b/extra/go/version @@ -0,0 +1 @@ +1.17.2 1