Skip to content

Commit

Permalink
More cross-compile toolchains
Browse files Browse the repository at this point in the history
  • Loading branch information
justsmth committed Sep 1, 2023
1 parent e95fa3d commit 35a91b3
Show file tree
Hide file tree
Showing 21 changed files with 411 additions and 21 deletions.
1 change: 1 addition & 0 deletions tests/docker_images/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
**/*.tar.xz
43 changes: 43 additions & 0 deletions tests/docker_images/linux-loongarch64/build_images.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/usr/bin/env bash
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0 OR ISC

set -ex

# Requires:
# * Install qemu-user-static

# Note:
# On Linux, you can see which architectures that qemu is registered for by looking
# under `/proc/sys/fs/binfmt_misc`.

# If needed, you can clear these entries using the following command:
# `sudo find /proc/sys/fs/binfmt_misc -type f -name 'qemu-*' -exec sh -c 'echo -1 > {}' \;`

# Log Docker hub limit https://docs.docker.com/docker-hub/download-rate-limit/#how-can-i-check-my-current-rate
TOKEN=$(curl "https://auth.docker.io/token?service=registry.docker.io&scope=repository:ratelimitpreview/test:pull" | jq -r .token)
curl --head -H "Authorization: Bearer $TOKEN" https://registry-1.docker.io/v2/ratelimitpreview/test/manifests/latest

SCRIPT_DIR=$(dirname "$(readlink -f "${0}")")

docker run --rm --privileged multiarch/qemu-user-static --reset -p yes

ARCH_NAME=loongarch64

X_TOOLS_FILE=${ARCH_NAME}-x-tools
if [ ! -f "./ubuntu-x-tools/${X_TOOLS_FILE}.tar.xz" ]; then
if ! aws sts get-caller-identity &> /dev/null; then
echo "AWS credentials are invalid. Please verify AWS credentials and try again."
exit 1
fi
aws s3 cp "s3://aws-libcrypto/cross-compile-toolchains/host-x86_64-pc-linux-gnu/${X_TOOLS_FILE}.tar.xz" ./ubuntu-x-tools/
fi

BUILDER_NAME=${ARCH_NAME}-builder
if ! docker buildx inspect ${BUILDER_NAME}; then
docker buildx create --name ${BUILDER_NAME} --use
fi

docker buildx build -t ubuntu-${ARCH_NAME}:x-tools "${SCRIPT_DIR}"/ubuntu-x-tools --load

docker buildx rm ${BUILDER_NAME}
38 changes: 38 additions & 0 deletions tests/docker_images/linux-loongarch64/ubuntu-x-tools/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0 OR ISC

FROM ubuntu:latest

RUN apt-get update && apt-get install -y \
cmake golang gdb gdbserver valgrind \
libclang1 \
build-essential \
ssh \
rsync \
tar \
python3 \
xz-utils \
ninja-build

# Not yet available
#RUN apt-get install -y \
# qemu-system-loongarch64

RUN apt-get clean

COPY loongarch64-x-tools.tar.xz /
RUN tar Jxvf loongarch64-x-tools.tar.xz -C / && rm /loongarch64-x-tools.tar.xz
COPY loongarch64.cmake /

EXPOSE 1234

ENV GOCACHE=/tmp \
CMAKE_TOOLCHAIN_FILE=/loongarch64.cmake \
CMAKE_SYSTEM_NAME=Linux \
CMAKE_SYSTEM_PROCESSOR=loongarch64 \
CMAKE_C_COMPILER=/loongarch64-unknown-linux-gnu/bin/loongarch64-unknown-linux-gnu-gcc \
CMAKE_CXX_COMPILER=/loongarch64-unknown-linux-gnu/bin/loongarch64-unknown-linux-gnu-g++ \
CMAKE_SYSROOT=/loongarch64-unknown-linux-gnu/loongarch64-unknown-linux-gnu/sysroot \
CMAKE_GENERATOR=Ninja

CMD ["/bin/bash"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Specify the target system
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR loongarch64)

# Specify the cross-compiler
set(CMAKE_C_COMPILER /loongarch64-unknown-linux-gnu/bin/loongarch64-unknown-linux-gnu-gcc)
set(CMAKE_CXX_COMPILER /loongarch64-unknown-linux-gnu/bin/loongarch64-unknown-linux-gnu-g++)

# Specify the sysroot for the target system
set(CMAKE_SYSROOT /loongarch64-unknown-linux-gnu/loongarch64-unknown-linux-gnu/sysroot)
set(CMAKE_GENERATOR Ninja)
43 changes: 43 additions & 0 deletions tests/docker_images/linux-ppc/build_images.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/usr/bin/env bash
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0 OR ISC

set -ex

# Requires:
# * Install qemu-user-static

# Note:
# On Linux, you can see which architectures that qemu is registered for by looking
# under `/proc/sys/fs/binfmt_misc`.

# If needed, you can clear these entries using the following command:
# `sudo find /proc/sys/fs/binfmt_misc -type f -name 'qemu-*' -exec sh -c 'echo -1 > {}' \;`

# Log Docker hub limit https://docs.docker.com/docker-hub/download-rate-limit/#how-can-i-check-my-current-rate
TOKEN=$(curl "https://auth.docker.io/token?service=registry.docker.io&scope=repository:ratelimitpreview/test:pull" | jq -r .token)
curl --head -H "Authorization: Bearer $TOKEN" https://registry-1.docker.io/v2/ratelimitpreview/test/manifests/latest

SCRIPT_DIR=$(dirname "$(readlink -f "${0}")")

docker run --rm --privileged multiarch/qemu-user-static --reset -p yes

ARCH_NAME=ppc

X_TOOLS_FILE=${ARCH_NAME}-x-tools
if [ ! -f "./ubuntu-x-tools/${X_TOOLS_FILE}.tar.xz" ]; then
if ! aws sts get-caller-identity &> /dev/null; then
echo "AWS credentials are invalid. Please verify AWS credentials and try again."
exit 1
fi
aws s3 cp "s3://aws-libcrypto/cross-compile-toolchains/host-x86_64-pc-linux-gnu/${X_TOOLS_FILE}.tar.xz" ./ubuntu-x-tools/
fi

BUILDER_NAME=${ARCH_NAME}-builder
if ! docker buildx inspect ${BUILDER_NAME}; then
docker buildx create --name ${BUILDER_NAME} --use
fi

docker buildx build -t ubuntu-${ARCH_NAME}:x-tools "${SCRIPT_DIR}"/ubuntu-x-tools --load

docker buildx rm ${BUILDER_NAME}
37 changes: 37 additions & 0 deletions tests/docker_images/linux-ppc/ubuntu-x-tools/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0 OR ISC

FROM ubuntu:latest

RUN apt-get update && apt-get install -y \
cmake golang gdb gdbserver valgrind \
libclang1 \
build-essential \
ssh \
rsync \
tar \
python3 \
xz-utils \
ninja-build

RUN apt-get install -y \
qemu-system-ppc

RUN apt-get clean

COPY ppc-x-tools.tar.xz /
RUN tar Jxvf ppc-x-tools.tar.xz -C / && rm /ppc-x-tools.tar.xz
COPY ppc.cmake /

EXPOSE 1234

ENV GOCACHE=/tmp \
CMAKE_TOOLCHAIN_FILE=/ppc.cmake \
CMAKE_SYSTEM_NAME=Linux \
CMAKE_SYSTEM_PROCESSOR=ppc \
CMAKE_C_COMPILER=/powerpc-unknown-linux-gnu/bin/powerpc-unknown-linux-gnu-gcc \
CMAKE_CXX_COMPILER=/powerpc-unknown-linux-gnu/bin/powerpc-unknown-linux-gnu-g++ \
CMAKE_SYSROOT=/powerpc-unknown-linux-gnu/powerpc-unknown-linux-gnu/sysroot \
CMAKE_GENERATOR=Ninja

CMD ["/bin/bash"]
11 changes: 11 additions & 0 deletions tests/docker_images/linux-ppc/ubuntu-x-tools/ppc.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Specify the target system
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR ppc)

# Specify the cross-compiler
set(CMAKE_C_COMPILER /powerpc-unknown-linux-gnu/bin/powerpc-unknown-linux-gnu-gcc)
set(CMAKE_CXX_COMPILER /powerpc-unknown-linux-gnu/bin/powerpc-unknown-linux-gnu-g++)

# Specify the sysroot for the target system
set(CMAKE_SYSROOT /powerpc-unknown-linux-gnu/powerpc-unknown-linux-gnu/sysroot)
set(CMAKE_GENERATOR Ninja)
30 changes: 25 additions & 5 deletions tests/docker_images/linux-ppc64/build_images.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#!/bin/bash -ex
#!/usr/bin/env bash
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0 OR ISC

set -ex

# Requires:
# * Install qemu-user-static

Expand All @@ -20,8 +22,26 @@ SCRIPT_DIR=$(dirname "$(readlink -f "${0}")")

docker run --rm --privileged multiarch/qemu-user-static --reset -p yes

docker buildx create --use
docker buildx build -t debian-ppc64:build-tools "${SCRIPT_DIR}"/debian-build-tools --load
ARCH_NAME=ppc64

X_TOOLS_FILE=${ARCH_NAME}-x-tools
if [ ! -f "./ubuntu-x-tools/${X_TOOLS_FILE}.tar.xz" ]; then
if ! aws sts get-caller-identity &> /dev/null; then
echo "AWS credentials are invalid. Please verify AWS credentials and try again."
exit 1
fi
aws s3 cp "s3://aws-libcrypto/cross-compile-toolchains/host-x86_64-pc-linux-gnu/${X_TOOLS_FILE}.tar.xz" ./ubuntu-x-tools/
fi

BUILDER_NAME=${ARCH_NAME}-builder
if ! docker buildx inspect ${BUILDER_NAME}; then
docker buildx create --name ${BUILDER_NAME} --use
fi

docker buildx build -t debian-${ARCH_NAME}:test "${SCRIPT_DIR}"/debian-test --load
docker buildx build -t ubuntu-${ARCH_NAME}:x-tools "${SCRIPT_DIR}"/ubuntu-x-tools --load
#docker context use default
#docker buildx build -t debian-ppc64:e6500 "${SCRIPT_DIR}"/debian-e6500 --load
#docker buildx build -t debian-ppc64:POWER8 "${SCRIPT_DIR}"/debian-POWER8 --load
#docker buildx build -t debian-${ARCH_NAME}:e6500 "${SCRIPT_DIR}"/debian-e6500 --load
#docker buildx build -t debian-${ARCH_NAME}:POWER8 "${SCRIPT_DIR}"/debian-POWER8 --load

docker buildx rm ${BUILDER_NAME}
2 changes: 1 addition & 1 deletion tests/docker_images/linux-ppc64/debian-POWER8/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0 OR ISC

FROM debian-ppc64:build-tools
FROM debian-ppc64:test

SHELL ["/bin/bash", "-c"]

Expand Down
2 changes: 1 addition & 1 deletion tests/docker_images/linux-ppc64/debian-e6500/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0 OR ISC

FROM debian-ppc64:build-tools
FROM debian-ppc64:test

SHELL ["/bin/bash", "-c"]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ RUN /debootstrap/debootstrap --second-stage
SHELL ["/bin/bash", "-c"]

RUN apt-get update && apt-get install -y \
gcc g++ cmake golang-1.21 gdb valgrind \
gcc g++ cmake golang-1.21 gdb gdbserver lldb valgrind \
clang libclang1 \
build-essential \
ssh \
Expand All @@ -28,6 +28,8 @@ RUN apt-get update && apt-get install -y \
python3 \
&& apt-get clean

EXPOSE 7777

ENV GOCACHE=/tmp
ENV PATH="/usr/lib/go-1.21/bin:$PATH"

Expand Down
37 changes: 37 additions & 0 deletions tests/docker_images/linux-ppc64/ubuntu-x-tools/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0 OR ISC

FROM ubuntu:latest

RUN apt-get update && apt-get install -y \
cmake golang gdb gdbserver valgrind \
libclang1 \
build-essential \
ssh \
rsync \
tar \
python3 \
xz-utils \
ninja-build

RUN apt-get install -y \
qemu-system-ppc

RUN apt-get clean

COPY ppc64-x-tools.tar.xz /
RUN tar Jxvf ppc64-x-tools.tar.xz -C / && rm /ppc64-x-tools.tar.xz
COPY ppc64.cmake /

EXPOSE 1234

ENV GOCACHE=/tmp \
CMAKE_TOOLCHAIN_FILE=/ppc64.cmake \
CMAKE_SYSTEM_NAME=Linux \
CMAKE_SYSTEM_PROCESSOR=ppc64 \
CMAKE_C_COMPILER=/powerpc64-linux-gnu/bin/powerpc64-unknown-linux-gnu-gcc \
CMAKE_CXX_COMPILER=/powerpc64-linux-gnu/bin/powerpc64-unknown-linux-gnu-g++ \
CMAKE_SYSROOT=/powerpc64-linux-gnu/powerpc64-unknown-linux-gnu/sysroot \
CMAKE_GENERATOR=Ninja

CMD ["/bin/bash"]
11 changes: 11 additions & 0 deletions tests/docker_images/linux-ppc64/ubuntu-x-tools/ppc64.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Specify the target system
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR ppc64)

# Specify the cross-compiler
set(CMAKE_C_COMPILER /powerpc64-linux-gnu/bin/powerpc64-unknown-linux-gnu-gcc)
set(CMAKE_CXX_COMPILER /powerpc64-linux-gnu/bin/powerpc64-unknown-linux-gnu-g++)

# Specify the sysroot for the target system
set(CMAKE_SYSROOT /powerpc64-linux-gnu/powerpc64-unknown-linux-gnu/sysroot)
set(CMAKE_GENERATOR Ninja)
26 changes: 23 additions & 3 deletions tests/docker_images/linux-ppc64le/build_images.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#!/bin/bash -ex
#!/usr/bin/env bash
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0 OR ISC

set -ex

# Requires:
# * Install qemu-user-static

Expand All @@ -20,5 +22,23 @@ SCRIPT_DIR=$(dirname "$(readlink -f "${0}")")

docker run --rm --privileged multiarch/qemu-user-static --reset -p yes

docker buildx create --use
docker buildx build -t ubuntu-ppc64le:build-tools "${SCRIPT_DIR}"/ubuntu-build-tools --load
ARCH_NAME=ppc64le

X_TOOLS_FILE=${ARCH_NAME}-x-tools
if [ ! -f "./ubuntu-x-tools/${X_TOOLS_FILE}.tar.xz" ]; then
if ! aws sts get-caller-identity &> /dev/null; then
echo "AWS credentials are invalid. Please verify AWS credentials and try again."
exit 1
fi
aws s3 cp "s3://aws-libcrypto/cross-compile-toolchains/host-x86_64-pc-linux-gnu/${X_TOOLS_FILE}.tar.xz" ./ubuntu-x-tools/
fi

BUILDER_NAME=${ARCH_NAME}-builder
if ! docker buildx inspect ${BUILDER_NAME}; then
docker buildx create --name ${BUILDER_NAME} --use
fi

docker buildx build -t ubuntu-${ARCH_NAME}:test "${SCRIPT_DIR}"/ubuntu-test --load
docker buildx build -t ubuntu-${ARCH_NAME}:x-tools "${SCRIPT_DIR}"/ubuntu-x-tools --load

docker buildx rm ${BUILDER_NAME}
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,17 @@ FROM --platform=$BUILDPLATFORM ppc64le/ubuntu:latest
SHELL ["/bin/bash", "-c"]

RUN apt-get update && apt-get install -y \
gcc g++ cmake golang gdb valgrind \
gcc g++ cmake golang gdb gdbserver lldb valgrind \
libclang-dev clang \
build-essential \
ssh \
rsync \
tar \
python3 \
&& apt-get clean \
&& mkdir -p /.cache \
&& chmod 777 /.cache
&& apt-get clean

EXPOSE 7777

ENV GOCACHE=/tmp
ENV PATH="/usr/lib/go/bin:$PATH"

CMD ["/bin/bash"]
Loading

0 comments on commit 35a91b3

Please sign in to comment.