Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for native AArch64 hosts #567

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 20 additions & 8 deletions build-docker-image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,23 @@ set -x
set -euo pipefail

version="$(cargo metadata --format-version 1 | jq --raw-output '.packages[] | select(.name == "cross") | .version')"
aarch64_unsupported = (
aarch64-linux-android
arm-linux-androideabi
armv7-linux-androideabi
asmjs-unknown-emscripten # todo
i686-linux-android
i686-pc-windows-gnu
powerpc-unknown-linux-gnu
powerpc64-unknown-linux-gnu
powerpc64le-unknown-linux-gnu
sparc64-unknown-linux-gnu
sparcv9-sun-solaris # todo
wasm32-unknown-emscripten # todo
x86_64-linux-android
x86_64-pc-windows-gnu
x86_64-sun-solaris
)

cd docker

Expand All @@ -12,13 +29,7 @@ run() {
local image_name="rustembedded/cross:${1}"
local cache_from_args=()

if ! docker image inspect "${image_name}" &>/dev/null; then
if docker pull "${image_name}"; then
cache_from_args=(--cache-from "${image_name}")
fi
fi

docker build ${cache_from_args[@]+"${cache_from_args[@]}"} --pull -t "${image_name}" -f "${dockerfile}" .
docker build ${cache_from_args[@]+"${cache_from_args[@]}"} -t "${image_name}" -f "${dockerfile}" .

if ! [[ "${version}" =~ alpha ]] && ! [[ "${version}" =~ dev ]]; then
local versioned_image_name="${image_name}-${version}"
Expand All @@ -28,7 +39,8 @@ run() {

if [[ -z "${*}" ]]; then
for t in Dockerfile.*; do
run "${t##Dockerfile.}"
target = "${t##Dockerfile.}"
run "${target}"
done
else
for image in "${@}"; do
Expand Down
11 changes: 8 additions & 3 deletions docker/Dockerfile.aarch64-unknown-linux-gnu
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,14 @@ RUN /cmake.sh
COPY xargo.sh /
RUN /xargo.sh

RUN apt-get install --assume-yes --no-install-recommends \
g++-aarch64-linux-gnu \
libc6-dev-arm64-cross
RUN arch="$(uname -m)" && \
case "${arch}" in \
arm64|aarch64) apt-get install --assume-yes --no-install-recommends \
g++ ;; \
*) apt-get install --assume-yes --no-install-recommends \
g++-aarch64-linux-gnu \
libc6-dev-arm64-cross ;; \
esac

COPY qemu.sh /
RUN /qemu.sh aarch64 softmmu
Expand Down
14 changes: 6 additions & 8 deletions docker/Dockerfile.arm-unknown-linux-gnueabihf
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,10 @@ RUN /cmake.sh
COPY xargo.sh /
RUN /xargo.sh

RUN mkdir /usr/arm-linux-gnueabihf \
&& cd /usr/arm-linux-gnueabihf \
&& export TOOLCHAIN_VERSION=8.3-2019.03 \
&& curl --retry 3 -sSfL https://developer.arm.com/-/media/Files/downloads/gnu-a/${TOOLCHAIN_VERSION}/binrel/gcc-arm-${TOOLCHAIN_VERSION}-x86_64-arm-linux-gnueabihf.tar.xz -O \
&& tar --strip-components 1 -xJf gcc-arm-${TOOLCHAIN_VERSION}-x86_64-arm-linux-gnueabihf.tar.xz \
&& rm gcc-arm-${TOOLCHAIN_VERSION}-x86_64-arm-linux-gnueabihf.tar.xz
ARG ARCH=arm \
KERNEL=kernel7
COPY gcc-toolchain.sh /
RUN /gcc-toolchain.sh arm-linux-gnueabihf "--with-arch=armv6 --with-fpu=vfp --with-float=hard"

ENV PATH /usr/arm-linux-gnueabihf/bin:$PATH

Expand All @@ -25,6 +23,6 @@ ENV CARGO_TARGET_ARM_UNKNOWN_LINUX_GNUEABIHF_LINKER=arm-linux-gnueabihf-gcc \
CARGO_TARGET_ARM_UNKNOWN_LINUX_GNUEABIHF_RUNNER=qemu-arm \
CC_arm_unknown_linux_gnueabihf=arm-linux-gnueabihf-gcc \
CXX_arm_unknown_linux_gnueabihf=arm-linux-gnueabihf-g++ \
QEMU_LD_PREFIX=/usr/arm-linux-gnueabihf/arm-linux-gnueabihf/libc \
LD_LIBRARY_PATH=/usr/arm-linux-gnueabihf/arm-linux-gnueabihf/libc/lib:/usr/arm-linux-gnueabihf/arm-linux-gnueabihf/lib:/usr/arm-linux-gnueabihf/lib \
QEMU_LD_PREFIX=/usr/arm-linux-gnueabihf/arm-linux-gnueabihf \
LD_LIBRARY_PATH=/usr/arm-linux-gnueabihf/arm-linux-gnueabihf/lib:/usr/arm-linux-gnueabihf/lib \
RUST_TEST_THREADS=1
22 changes: 20 additions & 2 deletions docker/Dockerfile.i586-unknown-linux-gnu
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ubuntu:16.04
FROM ubuntu:18.04

COPY common.sh lib.sh /
RUN /common.sh
Expand All @@ -10,4 +10,22 @@ COPY xargo.sh /
RUN /xargo.sh

RUN apt-get install --assume-yes --no-install-recommends \
g++-multilib
g++-multilib-i686-linux-gnu

COPY qemu.sh /
RUN /qemu.sh i386 softmmu

COPY dropbear.sh /
RUN /dropbear.sh

COPY linux-image.sh /
RUN /linux-image.sh i586

COPY linux-runner /

ENV CARGO_TARGET_I586_UNKNOWN_LINUX_GNU_LINKER=i686-linux-gnu-gcc \
CARGO_TARGET_I586_UNKNOWN_LINUX_GNU_RUNNER="/linux-runner i586" \
CC_i586_unknown_linux_gnu=i686-linux-gnu-gcc \
CXX_i586_unknown_linux_gnu=i686-linux-gnu-g++ \
QEMU_LD_PREFIX=/usr/i686-linux-gnu \
RUST_TEST_THREADS=1
16 changes: 15 additions & 1 deletion docker/Dockerfile.i586-unknown-linux-musl
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,20 @@ RUN /xargo.sh
COPY musl.sh /
RUN /musl.sh TARGET=i586-linux-musl

COPY qemu.sh /
RUN /qemu.sh i386 softmmu

COPY dropbear.sh /
RUN /dropbear.sh

COPY linux-image.sh /
RUN /linux-image.sh i586

COPY linux-runner /

ENV CARGO_TARGET_I586_UNKNOWN_LINUX_MUSL_LINKER=i586-linux-musl-gcc \
CARGO_TARGET_I586_UNKNOWN_LINUX_MUSL_RUNNER="/linux-runner i586" \
CC_i586_unknown_linux_musl=i586-linux-musl-gcc \
CXX_i586_unknown_linux_musl=i586-linux-musl-g++
CXX_i586_unknown_linux_musl=i586-linux-musl-g++ \
QEMU_LD_PREFIX=/usr/local/i586-linux-muslsf \
RUST_TEST_THREADS=1
11 changes: 8 additions & 3 deletions docker/Dockerfile.i686-unknown-linux-gnu
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ubuntu:16.04
FROM ubuntu:18.04

COPY common.sh lib.sh /
RUN /common.sh
Expand All @@ -10,7 +10,7 @@ COPY xargo.sh /
RUN /xargo.sh

RUN apt-get install --assume-yes --no-install-recommends \
g++-multilib
g++-multilib-i686-linux-gnu

COPY qemu.sh /
RUN /qemu.sh i386 softmmu
Expand All @@ -23,4 +23,9 @@ RUN /linux-image.sh i686

COPY linux-runner /

ENV CARGO_TARGET_I686_UNKNOWN_LINUX_GNU_RUNNER="/linux-runner i686"
ENV CARGO_TARGET_I686_UNKNOWN_LINUX_GNU_LINKER=i686-linux-gnu-gcc \
CARGO_TARGET_I686_UNKNOWN_LINUX_GNU_RUNNER="/linux-runner i686" \
CC_i686_unknown_linux_gnu=i686-linux-gnu-gcc \
CXX_i686_unknown_linux_gnu=i686-linux-gnu-g++ \
QEMU_LD_PREFIX=/usr/i686-linux-gnu \
RUST_TEST_THREADS=1
16 changes: 15 additions & 1 deletion docker/Dockerfile.i686-unknown-linux-musl
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,20 @@ RUN /xargo.sh
COPY musl.sh /
RUN /musl.sh TARGET=i686-linux-musl

COPY qemu.sh /
RUN /qemu.sh i386 softmmu

COPY dropbear.sh /
RUN /dropbear.sh

COPY linux-image.sh /
RUN /linux-image.sh i686

COPY linux-runner /

ENV CARGO_TARGET_I686_UNKNOWN_LINUX_MUSL_LINKER=i686-linux-musl-gcc \
CARGO_TARGET_I686_UNKNOWN_LINUX_MUSL_RUNNER="/linux-runner i686" \
CC_i686_unknown_linux_musl=i686-linux-musl-gcc \
CXX_i686_unknown_linux_musl=i686-linux-musl-g++
CXX_i686_unknown_linux_musl=i686-linux-musl-g++ \
QEMU_LD_PREFIX=/usr/local/i686-linux-muslsf \
RUST_TEST_THREADS=1
3 changes: 2 additions & 1 deletion docker/Dockerfile.mips-unknown-linux-gnu
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
FROM ubuntu:16.04
FROM ubuntu:21.04
ARG DEBIAN_FRONTEND=noninteractive

COPY common.sh lib.sh /
RUN /common.sh
Expand Down
10 changes: 6 additions & 4 deletions docker/Dockerfile.mips64-unknown-linux-gnuabi64
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
FROM ubuntu:16.04
FROM ubuntu:21.04
ARG DEBIAN_FRONTEND=noninteractive

COPY common.sh lib.sh /
RUN /common.sh
Expand All @@ -9,11 +10,12 @@ RUN /cmake.sh
COPY xargo.sh /
RUN /xargo.sh

COPY qemu.sh /
RUN apt-get install --assume-yes --no-install-recommends \
g++-mips64-linux-gnuabi64 \
libc6-dev-mips64-cross && \
/qemu.sh mips64
libc6-dev-mips64-cross

COPY qemu.sh /
RUN /qemu.sh mips64

ENV CARGO_TARGET_MIPS64_UNKNOWN_LINUX_GNUABI64_LINKER=mips64-linux-gnuabi64-gcc \
CARGO_TARGET_MIPS64_UNKNOWN_LINUX_GNUABI64_RUNNER=qemu-mips64 \
Expand Down
3 changes: 2 additions & 1 deletion docker/Dockerfile.mips64el-unknown-linux-gnuabi64
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
FROM ubuntu:16.04
FROM ubuntu:21.04
ARG DEBIAN_FRONTEND=noninteractive

COPY common.sh lib.sh /
RUN /common.sh
Expand Down
3 changes: 2 additions & 1 deletion docker/Dockerfile.mipsel-unknown-linux-gnu
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
FROM ubuntu:16.04
FROM ubuntu:21.04
ARG DEBIAN_FRONTEND=noninteractive

COPY common.sh lib.sh /
RUN /common.sh
Expand Down
2 changes: 1 addition & 1 deletion docker/Dockerfile.s390x-unknown-linux-gnu
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ubuntu:16.04
FROM ubuntu:18.04

COPY common.sh lib.sh /
RUN /common.sh
Expand Down
24 changes: 6 additions & 18 deletions docker/Dockerfile.wasm32-unknown-emscripten
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
FROM ubuntu:16.04
FROM ubuntu:21.04
ENV DEBIAN_FRONTEND=noninteractive

COPY common.sh lib.sh /
RUN /common.sh
Expand All @@ -9,23 +10,10 @@ RUN /cmake.sh
COPY xargo.sh /
RUN /xargo.sh

COPY --from=trzeci/emscripten:1.38.46-upstream /emsdk_portable /emsdk_portable

ENV EMSDK /emsdk_portable
ENV EMSCRIPTEN=${EMSDK}/emscripten/sdk

ENV EM_DATA ${EMSDK}/.data
ENV EM_CONFIG ${EMSDK}/.emscripten
ENV EM_CACHE ${EM_DATA}/cache
ENV EM_PORTS ${EM_DATA}/ports

ENV PATH="${EMSDK}:${EMSDK}/emscripten/sdk:${EMSDK}/llvm/clang/bin:${EMSDK}/node/current/bin:${EMSDK}/binaryen/bin:${PATH}"

ENTRYPOINT ["/emsdk_portable/entrypoint"]

RUN apt-get update && apt-get install --assume-yes --no-install-recommends \
libxml2 \
python
COPY emscripten.sh /
RUN /emscripten.sh

COPY node-wasm /usr/local/bin/
ENV CARGO_TARGET_WASM32_UNKNOWN_EMSCRIPTEN_RUNNER=node-wasm

ENTRYPOINT [ "/entrypoint" ]
26 changes: 18 additions & 8 deletions docker/Dockerfile.x86_64-unknown-linux-gnu
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
FROM ubuntu:16.04

COPY linux-image.sh /
RUN /linux-image.sh x86_64

FROM centos:7
FROM ubuntu:18.04

COPY common.sh lib.sh /
RUN /common.sh
Expand All @@ -14,14 +9,29 @@ RUN /cmake.sh
COPY xargo.sh /
RUN /xargo.sh

RUN arch="$(uname -m)" && \
case "${arch}" in \
arm64|aarch64) apt-get install --assume-yes --no-install-recommends \
g++-x86-64-linux-gnu \
libc6-dev-amd64-cross ;; \
*) apt-get install --assume-yes --no-install-recommends \
g++ ;; \
esac

COPY qemu.sh /
RUN /qemu.sh x86_64 softmmu

COPY dropbear.sh /
RUN /dropbear.sh

COPY --from=0 /qemu /qemu
COPY linux-image.sh /
RUN /linux-image.sh x86_64

COPY linux-runner /

ENV CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_RUNNER="/linux-runner x86_64"
ENV CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_LINKER=x86_64-linux-gnu-gcc \
CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_RUNNER="/linux-runner x86_64" \
CC_x86_64_unknown_linux_gnu=x86_64-linux-gnu-gcc \
CXX_x86_64_unknown_linux_gnu=x86_64-linux-gnu-g++ \
QEMU_LD_PREFIX=/usr/x86_64-linux-gnu \
RUST_TEST_THREADS=1
15 changes: 13 additions & 2 deletions docker/Dockerfile.x86_64-unknown-linux-musl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ubuntu:20.04
FROM ubuntu:18.04

COPY common.sh lib.sh /
RUN /common.sh
Expand All @@ -9,9 +9,20 @@ RUN /cmake.sh
COPY xargo.sh /
RUN /xargo.sh

COPY qemu.sh /
RUN /qemu.sh x86_64

COPY musl.sh /
RUN /musl.sh TARGET=x86_64-linux-musl

# Allows qemu to run dynamic linked binaries
RUN ln -sf \
/usr/local/x86_64-linux-musl/lib/libc.so \
/usr/local/x86_64-linux-musl/lib/ld-musl-x86_64.so.1

ENV CARGO_TARGET_X86_64_UNKNOWN_LINUX_MUSL_LINKER=x86_64-linux-musl-gcc \
CARGO_TARGET_X86_64_UNKNOWN_LINUX_MUSL_RUNNER=qemu-x86_64 \
CC_x86_64_unknown_linux_musl=x86_64-linux-musl-gcc \
CXX_x86_64_unknown_linux_musl=x86_64-linux-musl-g++
CXX_x86_64_unknown_linux_musl=x86_64-linux-musl-g++ \
QEMU_LD_PREFIX=/usr/local/x86_64-linux-musl \
RUST_TEST_THREADS=1
19 changes: 17 additions & 2 deletions docker/cmake.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,22 @@ set -euo pipefail
. lib.sh

main() {
local version=3.17.2
local uname_arch=$(uname -m)
local version=3.20.5

local arch=
case "${uname_arch}" in
x86_64)
arch="x86_64"
;;
arm64|aarch64)
arch="aarch64"
;;
*)
echo "unsupported architecture"
exit 1
;;
esac

install_packages curl

Expand All @@ -16,7 +31,7 @@ main() {

pushd "${td}"

curl --retry 3 -sSfL "https://github.com/Kitware/CMake/releases/download/v${version}/cmake-${version}-Linux-x86_64.sh" -o cmake.sh
curl --retry 3 -sSfL "https://github.com/Kitware/CMake/releases/download/v${version}/cmake-${version}-Linux-${arch}.sh" -o cmake.sh
sh cmake.sh --skip-license --prefix=/usr/local

popd
Expand Down
Loading