Skip to content

Commit 6b6b124

Browse files
dtretyakovmstorsjo
authored andcommitted
docker: build linux/arm64 images (#398)
1 parent 6775203 commit 6b6b124

File tree

3 files changed

+85
-0
lines changed

3 files changed

+85
-0
lines changed

.github/workflows/docker.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,3 +69,46 @@ jobs:
6969
- name: Inspect Docker images
7070
run: |
7171
docker images
72+
73+
docker-build-toolchain:
74+
needs: [prepare]
75+
runs-on: ubuntu-latest
76+
steps:
77+
- uses: actions/checkout@v4
78+
with:
79+
ref: ${{ (inputs.commit != '' && inputs.commit) || inputs.branch }}
80+
- name: Download toolchain
81+
uses: dawidd6/action-download-artifact@v3
82+
with:
83+
workflow: build.yml
84+
workflow_conclusion: success
85+
commit: ${{inputs.commit}}
86+
branch: ${{inputs.branch}}
87+
event: push
88+
name: linux-ucrt-.*
89+
name_is_regexp: true
90+
path: toolchain
91+
- name: Set up QEMU
92+
uses: docker/setup-qemu-action@v3
93+
- name: Set up Docker Buildx
94+
uses: docker/setup-buildx-action@v3
95+
- name: Log in to Docker Hub
96+
if: ${{inputs.login}}
97+
uses: docker/login-action@v3
98+
with:
99+
username: ${{secrets.DOCKER_USERNAME}}
100+
password: ${{secrets.DOCKER_PASSWORD}}
101+
- name: Build Docker images
102+
uses: docker/build-push-action@v5
103+
with:
104+
context: .
105+
platforms: linux/arm64
106+
push: ${{inputs.push}}
107+
file: ./Dockerfile.toolchain
108+
load: true
109+
tags: |
110+
mstorsjo/llvm-mingw:latest
111+
mstorsjo/llvm-mingw:${{needs.prepare.outputs.TAG}}
112+
- name: Inspect Docker images
113+
run: |
114+
docker images

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@
55
/libffi
66
/cpython*
77
/python-native
8+
/toolchain

Dockerfile.toolchain

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
FROM ubuntu:20.04
2+
3+
RUN apt-get update -qq && \
4+
DEBIAN_FRONTEND="noninteractive" apt-get install -qqy --no-install-recommends \
5+
git wget bzip2 file unzip libtool pkg-config cmake build-essential \
6+
automake yasm gettext autopoint vim-tiny python3 python3-distutils \
7+
ninja-build ca-certificates curl less zip && \
8+
apt-get clean -y && \
9+
rm -rf /var/lib/apt/lists/*
10+
11+
# Manually install a newer version of CMake; this is needed since building
12+
# LLVM requires CMake 3.20, while Ubuntu 20.04 ships with 3.16.3. If
13+
# updating to a newer distribution, this can be dropped.
14+
RUN cd /opt && \
15+
curl -LO https://github.com/Kitware/CMake/releases/download/v3.26.4/cmake-3.26.4-Linux-$(uname -m).tar.gz && \
16+
tar -zxf cmake-*.tar.gz && \
17+
rm cmake-*.tar.gz && \
18+
mv cmake-* cmake
19+
ENV PATH=/opt/cmake/bin:$PATH
20+
21+
22+
RUN git config --global user.name "LLVM MinGW" && \
23+
git config --global user.email root@localhost
24+
25+
WORKDIR /build
26+
27+
ENV TOOLCHAIN_PREFIX=/opt/llvm-mingw
28+
29+
ARG TOOLCHAIN_ARCHS="i686 x86_64 armv7 aarch64"
30+
31+
# Copy prebuilt toolchains for the current architecture.
32+
# Test executing a binary, to make sure that it works (i.e. it is not built
33+
# requiring a newer version of glibc or libstdc++ than what is available in
34+
# this container).
35+
RUN --mount=type=bind,source=toolchain,target=/toolchain \
36+
mkdir -p $TOOLCHAIN_PREFIX && ARCH=$(uname -m) && \
37+
tar xf /toolchain/linux-ucrt-$ARCH-toolchain/llvm-mingw-*-$ARCH.tar.xz --strip-components 1 -C $TOOLCHAIN_PREFIX && \
38+
ANY_ARCH=$(echo $TOOLCHAIN_ARCHS | awk '{print $1}') && \
39+
$TOOLCHAIN_PREFIX/bin/$ANY_ARCH-w64-mingw32-clang --version
40+
41+
ENV PATH=$TOOLCHAIN_PREFIX/bin:$PATH

0 commit comments

Comments
 (0)