github.com/JimmyHuang454/JLS-go@v0.0.0-20230831150107-90d536585ba0/boring/build.sh (about) 1 #!/bin/bash 2 # Copyright 2022 The Go Authors. All rights reserved. 3 # Use of this source code is governed by a BSD-style 4 # license that can be found in the LICENSE file. 5 6 # This shell script uses Docker to run build-boring.sh and build-goboring.sh, 7 # which build goboringcrypto_linux_$GOARCH.syso according to the Security Policy. 8 # Currently, amd64 and arm64 are permitted. 9 10 set -e 11 set -o pipefail 12 13 GOARCH=${GOARCH:-$(go env GOARCH)} 14 echo "# Building goboringcrypto_linux_$GOARCH.syso. Set GOARCH to override." >&2 15 16 if ! which docker >/dev/null; then 17 echo "# Docker not found. Inside Google, see go/installdocker." >&2 18 exit 1 19 fi 20 21 platform="" 22 buildargs="" 23 case "$GOARCH" in 24 amd64) 25 ;; 26 arm64) 27 if ! docker run --rm -t arm64v8/ubuntu:focal uname -m >/dev/null 2>&1; then 28 echo "# Docker cannot run arm64 binaries. Try:" 29 echo " sudo apt-get install qemu binfmt-support qemu-user-static" 30 echo " docker run --rm --privileged multiarch/qemu-user-static --reset -p yes" 31 echo " docker run --rm -t arm64v8/ubuntu:focal uname -m" 32 exit 1 33 fi 34 platform="--platform linux/arm64/v8" 35 buildargs="--build-arg ubuntu=arm64v8/ubuntu" 36 ;; 37 *) 38 echo unknown GOARCH $GOARCH >&2 39 exit 2 40 esac 41 42 docker build $platform $buildargs --build-arg GOARCH=$GOARCH -t goboring:$GOARCH . 43 id=$(docker create $platform goboring:$GOARCH) 44 docker cp $id:/boring/godriver/goboringcrypto_linux_$GOARCH.syso ./syso 45 docker rm $id 46 ls -l ./syso/goboringcrypto_linux_$GOARCH.syso