# --- T2-COPYRIGHT-NOTE-BEGIN --- # T2 SDE: package/*/go/go.conf # Copyright (C) 2021 - 2023 The T2 SDE Project # # This Copyright note is generated by scripts/Create-CopyPatch, # more information can be found in the files COPYING and README. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License version 2. # --- T2-COPYRIGHT-NOTE-END --- makeopt= makeinstopt= var_remove GCC_WRAPPER_REMOVE ' ' "-gdwarf*" # Translate our arch naming to theirs go_arch() { local is_host=$1 local goarch=$2 local gover=$3 local endi case $is_host in host) endi=$(echo -n I | od -to2 | head -n1 | cut -f2 -d" " | cut -c6) ;; target|*) endi=$arch_bigendian ;; esac local LE BE P32 case $arch_bigendian in yes|0) BE=be LE='' ;; no|1) BE='' LE=le ;; esac [ "$1" == "target" ] && [ "$arch_sizeof_char_p" = 4 ] && P32=p32 if [ $gover == "1.4" -o $gover == "1.19.10" ]; then case $goarch in arm) echo $goarch$BE ;; arm64) echo aarch64 ;; loongarch*) echo ${arch/arch} ;; mips) echo $goarch$LE ;; mips*) echo $goarch$P32$LE ;; powerpc64) echo ppc64$LE ;; x86) echo 386 ;; x86-64) echo amd64$P32 ;; *) echo $goarch ;; esac else case $goarch in arm*) echo $goarch$BE ;; loongarch*) echo ${arch/arch} ;; mips) echo $goarch$LE ;; mips*) echo $goarch$P32$LE ;; powerpc64) echo ppc64$LE ;; x86) echo 386 ;; x86-64) echo amd64$P32 ;; *) echo $goarch ;; esac fi } export CGO_ENABLED=0 export GOOS=$SDECFG_KERNEL export GOROOT_FINAL=$root$libdir/go # Build every go versions until latest go_inmake() { # Only bootstrap from C if host hasn't a Go compiler local go_tarballs="." which go 2>/dev/null || var_insert go_tarballs ' ' "$(match_source_file -p | tac | head -n -1)" for x in $go_tarballs; do local gover=${x##*/} gover=${gover%.tar.*} # Extract additional, older bootstrap tarball if [ "$x" != . ]; then mkdir -pv ../$gover tar $taropt $x -C ../$gover cd ../$gover/go fi cd src gover="${gover#go-}" # In T2, "/bin/uname" provides information about the host system # while "uname" is wrapped to provide target system information. # We need to set these values on each loop round cpu namings # changed troughout the history of the Go language. export GOARCH="$(go_arch target $arch $gover)" export GOHOSTARCH="$(go_arch host $(/bin/uname -m | uname2arch) $gover)" ./make.bash cd .. # Use what we just built as the toolchain for the next loop round if [ "$x" != "." ]; then export GOROOT_BOOTSTRAP="$PWD" cd $builddir/go fi done } hook_add inmake 5 "go_inmake" go_postmake() { # Always delete previous Go installs to avoid conflicts rm -rf $GOROOT_FINAL/ mkdir -pv $GOROOT_FINAL cp -rfv api bin lib misc pkg src go.env $GOROOT_FINAL/ # Move the cross-compiled binary in the right place as go puts it in a subdirectory if atstage cross; then find "$GOROOT_FINAL/bin/${GOOS}_$GOARCH" -type f -perm /u+x | xargs -I {} mv -v {} $GOROOT_FINAL/bin/ rm -rfv "$GOROOT_FINAL/bin/${GOOS}_$GOARCH" fi # Symlink the binaries to the bindir for bin in $GOROOT_FINAL/bin/* ; do ln -srfv $bin $root/$bindir/${bin##*/} done } hook_add postmake 5 "go_postmake"