...
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
10set -e
11set -o pipefail
12
13GOARCH=${GOARCH:-$(go env GOARCH)}
14echo "# Building goboringcrypto_linux_$GOARCH.syso. Set GOARCH to override." >&2
15
16if ! which docker >/dev/null; then
17 echo "# Docker not found. Inside Google, see go/installdocker." >&2
18 exit 1
19fi
20
21platform=""
22buildargs=""
23case "$GOARCH" in
24amd64)
25 ;;
26arm64)
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
40esac
41
42docker build $platform $buildargs --build-arg GOARCH=$GOARCH -t goboring:$GOARCH .
43id=$(docker create $platform goboring:$GOARCH)
44docker cp $id:/boring/godriver/goboringcrypto_linux_$GOARCH.syso ./syso
45docker rm $id
46ls -l ./syso/goboringcrypto_linux_$GOARCH.syso
View as plain text