зеркало из https://github.com/golang/build.git
build/env: add Dockerfile for cross-compiling from x86 to arm
Moved cross-compile builders to env/crosscompile Tested it works: $ readelf --headers go/bin/go ELF Header: Magic: 7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00 Class: ELF32 Data: 2's complement, little endian Version: 1 (current) OS/ABI: UNIX - System V ABI Version: 0 Type: EXEC (Executable file) Machine: ARM Version: 0x1 Entry point address: 0xc3a80 Start of program headers: 52 (bytes into file) Start of section headers: 276 (bytes into file) Flags: 0x5000002, has entry point, Version5 EABI Size of this header: 52 (bytes) Size of program headers: 32 (bytes) Number of program headers: 7 Size of section headers: 40 (bytes) Number of section headers: 23 Section header string table index: 7 Change-Id: I3db71fa954575c29bb0a12a07c9bf84c4c96d88e Reviewed-on: https://go-review.googlesource.com/29679 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This commit is contained in:
Родитель
f787cecbe4
Коммит
56d60b94d1
|
@ -0,0 +1,51 @@
|
|||
# Copyright 2016 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.
|
||||
|
||||
# Linux builder VM running Debian stretch (i.e. Debian testing)
|
||||
# Docker tag gobuilders/linux-armel-stretch
|
||||
|
||||
FROM debian:stretch
|
||||
MAINTAINER golang-dev <golang-dev@googlegroups.com>
|
||||
|
||||
ENV DEBIAN_FRONTEND noninteractive
|
||||
|
||||
# curl: for getting and unpacking Go 1.4 source
|
||||
# git-core: for interacting with the Go source & subrepos
|
||||
# gcc, libc-dev: for building Go's bootstrap 'dist' prog
|
||||
# gcc-armel-linux-gnu, libc6-dev-armel-cross: for armel builds
|
||||
# procps, lsof, psmisc: misc tools
|
||||
RUN apt-get update && apt-get install -y \
|
||||
bzip2 \
|
||||
ca-certificates \
|
||||
curl \
|
||||
git-core \
|
||||
gcc \
|
||||
libc6-dev \
|
||||
gcc-arm-linux-gnueabi \
|
||||
libc6-dev-armel-cross \
|
||||
procps \
|
||||
lsof \
|
||||
psmisc \
|
||||
--no-install-recommends \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
RUN mkdir -p /go1.4-amd64 \
|
||||
&& ( \
|
||||
curl --silent https://storage.googleapis.com/golang/go1.4.3.linux-amd64.tar.gz | tar -C /go1.4-amd64 -zxv \
|
||||
) \
|
||||
&& mv /go1.4-amd64/go /go1.4 \
|
||||
&& rm -rf /go1.4-amd64 \
|
||||
&& rm -rf /go1.4/pkg/linux_amd64_race \
|
||||
/go1.4/api \
|
||||
/go1.4/blog \
|
||||
/go1.4/doc \
|
||||
/go1.4/misc \
|
||||
/go1.4/test \
|
||||
&& find /go1.4 -type d -name testdata | xargs rm -rf
|
||||
|
||||
RUN curl -o /usr/local/bin/stage0 https://storage.googleapis.com/go-builder-data/buildlet-stage0.linux-amd64-kube \
|
||||
&& chmod +x /usr/local/bin/stage0
|
||||
|
||||
ENV GOROOT_BOOTSTRAP=/go1.4 GOOS=linux GOARCH=arm CC_FOR_TARGET=arm-linux-gnueabi-gcc
|
||||
COPY build-release.sh /usr/bin/
|
|
@ -0,0 +1,2 @@
|
|||
The docker image created from this directory can be used to cross compile go
|
||||
from linux/amd64 to linux/arm.
|
|
@ -0,0 +1,25 @@
|
|||
# Copyright 2016 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.
|
||||
|
||||
IMAGE_NAME=$(shell basename $(CURDIR))
|
||||
STAGING_REPO=gcr.io/go-dashboard-dev
|
||||
PROD_REPO=gcr.io/symbolic-datum-552
|
||||
|
||||
usage:
|
||||
echo "Use staging, prod, or dev targets. For dev, specify your Docker repository with the REPO=foo argument." ; exit 1
|
||||
|
||||
staging: Dockerfile
|
||||
docker build -t $(STAGING_REPO)/$(IMAGE_NAME):latest .
|
||||
gcloud docker push $(STAGING_REPO)/$(IMAGE_NAME):latest
|
||||
|
||||
prod: Dockerfile
|
||||
docker build -t $(PROD_REPO)/$(IMAGE_NAME):latest .
|
||||
gcloud docker push $(PROD_REPO)/$(IMAGE_NAME):latest
|
||||
|
||||
# You must provide a REPO=your-repo-name arg when you make
|
||||
# this targarget. REPO is the name of the Docker repository
|
||||
# that will be prefixed to the name of the image being built.
|
||||
dev: Dockerfile
|
||||
docker build -t $(REPO)/$(IMAGE_NAME):latest .
|
||||
gcloud docker push $(REPO)/$(IMAGE_NAME):latest
|
|
@ -0,0 +1,2 @@
|
|||
The docker image created from this directory can be used to cross compile go
|
||||
from linux/amd64 to linux/s390x.
|
|
@ -1,10 +0,0 @@
|
|||
The docker image created from this directory can be used to cross compile go
|
||||
from linux/amd64 to linux/s390x.
|
||||
|
||||
How to use:
|
||||
|
||||
$ docker run --rm -it -v $(pwd)/artifacts:/artifacts \
|
||||
gobuilders/linux-s390x-stretch build-release.sh $GIT_REV
|
||||
|
||||
This will make the built go artifact, go-${GIT_REV}-linux-s390x.tar.gz,
|
||||
available in the directory you mounted as `/artifacts` in the container.
|
|
@ -1,28 +0,0 @@
|
|||
#!/bin/bash
|
||||
# Copyright 2016 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.
|
||||
set -e
|
||||
|
||||
GIT_REV=$1
|
||||
if [[ -z "$GIT_REV" ]]; then
|
||||
GIT_REV=master
|
||||
fi
|
||||
|
||||
# fetch the source
|
||||
git clone https://go.googlesource.com/go /usr/src/go
|
||||
(
|
||||
cd /usr/src/go
|
||||
# checkout the specific revision
|
||||
git checkout "$GIT_REV"
|
||||
|
||||
cd /usr/src/go/src
|
||||
# build
|
||||
./bootstrap.bash
|
||||
|
||||
cd /
|
||||
mv /usr/src/go-${GOOS}-${GOARCH}-bootstrap /go
|
||||
mkdir -p /artifacts
|
||||
# tarball the artifact
|
||||
tar -czvf /artifacts/go-${GIT_REV}-${GOOS}-${GOARCH}.tar.gz /go
|
||||
)
|
Загрузка…
Ссылка в новой задаче