Skip to content

Commit d959a68

Browse files
committed
Extract the rust builder
1 parent 66613b8 commit d959a68

File tree

5 files changed

+37
-49
lines changed

5 files changed

+37
-49
lines changed

Dockerfile.misc

-2
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,6 @@ RUN cpanm Modern::Perl
6969

7070
RUN cpanm App::Prove CPU::Z80::Assembler Data::Dump File::Path List::Uniq Object::Tiny::RW Regexp::Common Text::Diff YAML::Tiny
7171

72-
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
73-
7472
RUN mkdir /cmake && \
7573
cd /cmake && \
7674
wget https://github.com/Kitware/CMake/releases/download/v3.24.0-rc5/cmake-3.24.0-rc5-linux-x86_64.sh && \

Dockerfile.rust-cg-gcc

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
FROM ubuntu:20.04
2+
3+
ARG DEBIAN_FRONTEND=noninteractive
4+
RUN dpkg --add-architecture i386
5+
RUN apt update -y -q && apt upgrade -y -q && apt update -y -q && \
6+
apt install -y -q \
7+
build-essential \
8+
bison \
9+
curl \
10+
flex \
11+
git \
12+
libc6-dev-i386 \
13+
libc6-dev:i386 \
14+
make \
15+
patchelf \
16+
xz-utils
17+
18+
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
19+
20+
RUN mkdir -p /root
21+
COPY rust-cg-gcc /root/
22+
COPY common.sh /root/
23+
24+
WORKDIR /root

common.sh

+3-7
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
# Common utilities and setup for builds
44

5-
set -euo pipefail
5+
set -euxo pipefail
66

77
# get_remote_revision GITURL BRANCH
88
get_remote_revision() {
@@ -14,23 +14,19 @@ get_remote_revision() {
1414
echo "$REVISION"
1515
}
1616

17-
# initialise REVISION OUTPUT_FILENAME
17+
# initialise REVISION OUTPUT_FILENAME [optional previously built revision]
1818
initialise() {
1919
local REVISION="$1"
2020
local OUTPUT="$2"
21+
local LAST_REVISION="${3-previously-unbuilt}"
2122
echo "ce-build-revision:${REVISION}"
2223
echo "ce-build-output:${OUTPUT}"
23-
}
24-
25-
# skip_if_built REVISION PREV_REVISION
26-
skip_if_built() {
2724
if [[ "${REVISION}" == "${LAST_REVISION}" ]]; then
2825
echo "ce-build-status:SKIPPED"
2926
exit
3027
fi
3128
}
3229

33-
3430
# complete <source folder> <name to be extracted as> <dest tar.xz file>
3531
complete() {
3632
local SOURCE="$1"

compcert/build.sh

+1-3
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,7 @@ FULLNAME=${BASENAME}.tar.xz
2525
OUTPUT=$3/${FULLNAME}
2626

2727
REVISION=$(get_remote_revision "${URL}" "${BRANCH}")
28-
initialise "${REVISION}" "${OUTPUT}"
29-
30-
skip_if_built "${REVISION}" "${LAST_REVISION}"
28+
initialise "${REVISION}" "${OUTPUT}" "${LAST_REVISION}"
3129

3230
# The path to compcert will be hardcoded in a config file (share/compcert.ini).
3331
# This makes the compiler not relocatable without editing this file beforehand.

misc/build-rustc-cg-gcc.sh renamed to rust-cg-gcc/build.sh

+9-37
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
## $2 : destination: a directory or S3 path (eg. s3://...)
55
## $3 : last revision (as mangled below) successfully build (optional)
66

7-
set -e
7+
set -eu
8+
source common.sh
89

9-
ROOT=$PWD
1010
VERSION="${1}"
1111
LAST_REVISION="${3-}"
1212

@@ -21,34 +21,15 @@ GCC_BRANCH="master"
2121
CG_GCC_BRANCH="master"
2222
CG_GCC_URL="https://github.com/rust-lang/rustc_codegen_gcc.git"
2323

24-
GCC_REVISION=$(git ls-remote --heads "${GCC_URL}" "refs/heads/${GCC_BRANCH}" | cut -f 1)
25-
CG_GCC_REVISION=$(git ls-remote --heads "${CG_GCC_URL}" "refs/heads/${CG_GCC_BRANCH}" | cut -f 1)
24+
GCC_REVISION=$(get_remote_revision "${GCC_URL}" "heads/${GCC_BRANCH}")
25+
CG_GCC_REVISION=$(get_remote_revision "${CG_GCC_URL}" "heads/${CG_GCC_BRANCH}")
2626

2727
BASENAME=rustc-cg-gcc-${VERSION}-$(date +%Y%m%d)
2828
FULLNAME=${BASENAME}.tar.xz
29-
OUTPUT=${ROOT}/${FULLNAME}
30-
S3OUTPUT=
31-
if [[ $2 =~ ^s3:// ]]; then
32-
S3OUTPUT=$2
33-
else
34-
if [[ -d "${2}" ]]; then
35-
OUTPUT=$2/${FULLNAME}
36-
else
37-
OUTPUT=${2-$OUTPUT}
38-
fi
39-
fi
29+
OUTPUT=$2/${FULLNAME}
4030

4131
REVISION="cggcc-${CG_GCC_REVISION}-gcc-${GCC_REVISION}"
42-
echo "ce-build-revision:${REVISION}"
43-
echo "ce-build-output:${OUTPUT}"
44-
45-
if [[ "${REVISION}" == "${LAST_REVISION}" ]]; then
46-
echo "ce-build-status:SKIPPED"
47-
exit
48-
fi
49-
50-
## From now, no unset variable
51-
set -u
32+
initialise "${REVISION}" "${OUTPUT}" "${LAST_REVISION}"
5233

5334
OUTPUT=$(realpath "${OUTPUT}")
5435

@@ -156,15 +137,15 @@ pushd rustc_codegen_gcc
156137

157138
## Temporary fix, see
158139
## https://github.com/compiler-explorer/compiler-explorer/issues/4715. This
159-
## causes all the crates to be build with panic=abort, so any unwinding will be
140+
## causes all the crates to be built with panic=abort, so any unwinding will be
160141
## doomed :(
161142
CG_RUSTFLAGS=-Cpanic=abort \
162143
./build.sh --release
163144

164145
popd
165146

166147
##
167-
## Everything should be correctly build
148+
## Everything should be correctly built
168149
##
169150

170151
##
@@ -217,13 +198,4 @@ test test.s
217198
./test
218199

219200
# Don't try to compress the binaries as they don't like it
220-
pushd toolroot
221-
222-
export XZ_DEFAULTS="-T 0"
223-
tar Jcf "${OUTPUT}" --transform "s,^./,./${BASENAME}/," ./
224-
225-
if [[ -n "${S3OUTPUT}" ]]; then
226-
aws s3 cp --storage-class REDUCED_REDUNDANCY "${OUTPUT}" "${S3OUTPUT}"
227-
fi
228-
229-
echo "ce-build-status:OK"
201+
complete toolroot "${BASENAME}" "${OUTPUT}"

0 commit comments

Comments
 (0)