-
Notifications
You must be signed in to change notification settings - Fork 0
/
build-all-archs
executable file
·129 lines (113 loc) · 3.89 KB
/
build-all-archs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
#!/bin/bash -e
#
# Simple script to build risu for all architectures
#
# Copyright (c) 2017 Linaro Limited
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Eclipse Public License v1.0
# which accompanies this distribution, and is available at
# http://www.eclipse.org/legal/epl-v10.html
#
# Contributors:
# Peter Maydell (Linaro) - initial implementation
# Simple usage
usage() {
cat <<-EOF
Usage: $0 [options]
Options include:
--static build a static binary
--use-docker[=tags] use docker cross compile
If specifying docker the default will be to use the any
qemu:debian-FOO-cross targets available on your system.
EOF
exit 1
}
while [[ "$1" = -* ]]; do
opt="$1"; shift
arg=
if [[ "$opt" = *=* ]]; then
arg="${opt#*=}"
opt="${opt%%=*}"
fi
case "$opt" in
--static)
CONF="--static"
;;
--use-docker)
if [ -z "$arg" ]; then
default_tags=$(docker images qemu --format "{{.Repository}}:{{.Tag}}" | grep "\(arm\|ppc64el\|m68k\|i386\).*cross$")
docker_tags=$(echo $default_tags | sed 's/\n/\s/g' )
else
docker_tags="$arg"
fi
;;
--help)
usage
;;
*)
usage
;;
esac
done
#
# If you are developing your primary architecture directly out of the
# source tree you can confuse any out-of-tree builds thanks to random
# crap in your VPATH. Let's detect that and save some hair pulling.
#
if [ -e Makefile.in ]; then
echo "Cleaning in-src-tree build"
make distclean
fi
# Debian stretch and Ubuntu Xenial have cross compiler packages for
# all of these:
# gcc-arm-linux-gnueabihf gcc-aarch64-linux-gnu gcc-m68k-linux-gnu
# gcc-powerpc64le-linux-gnu gcc-powerpc64-linux-gnu
# If docker is enabled we just brute force the various images until we
# can set the one that has a workable cross compiler.
DOCKER_RUN="docker run --rm -u $(id -u) -v $(pwd):$(pwd) -w $(pwd)"
program_exists() {
if [[ ! -z "$docker_tags" && ! "$1" == "x86_64-linux-gnu-gcc" ]]; then
use_docker_tag=""
for tag in $docker_tags; do
if ${DOCKER_RUN} ${tag} /bin/bash -c "command -v $1 >/dev/null"; then
use_docker_tag=$tag
return
fi
done
fi
command -v "$1" >/dev/null 2>&1
}
# powerpc64-linux-gnu doesn't work at the moment, so not yet listed.
for triplet in i386-linux-gnu i686-linux-gnu x86_64-linux-gnu \
aarch64-linux-gnu arm-linux-gnueabihf \
m68k-linux-gnu \
powerpc64le-linux-gnu powerpc64-linux-gnu ; do
if ! program_exists "${triplet}-gcc"; then
echo "Skipping ${triplet}: no compiler found"
continue
else
echo "Building ${triplet} on ${use_docker_tag:-host}..."
fi
# Do a complete rebuild from scratch, because it's cheap enough.
rm -rf build/${triplet}
mkdir -p build/${triplet}
CONFIGURE="cd build/${triplet} && CROSS_PREFIX="${triplet}-" ../../configure ${CONF}"
MAKE="make -C build/${triplet} EXTRA_CFLAGS=-Werror"
if [ -z "$use_docker_tag" ]; then
/bin/bash -c "${CONFIGURE}"
${MAKE}
else
${DOCKER_RUN} $use_docker_tag /bin/bash -c "${CONFIGURE}"
${DOCKER_RUN} $use_docker_tag /bin/bash -c "${MAKE}"
fi
done
# Now run risugen for all architectures
mkdir -p build/risuout
set -o pipefail # detect failures in pipeline
for f in *.risu; do
echo "Running risugen on $f..."
# The grep is a quick hack to avoid flooding the terminal with an
# enormous list of patterns. Ideally we should make risugen
# have a --quiet option or similar.
./risugen --numinsns 10000 $f build/risuout/$f.out | grep -v '^Generating code using patterns'
done