Skip to content

Commit f00abf0

Browse files
committed
github: Cross build the linux x86_64 packages on aarch64
This avoids needing to build two linux stage1 packages (reducing the total amount of github actions runtime used). This also makes the linux-stage1 job faster, as the aarch64 runners currently seem to be faster than the x86_64 ones.
1 parent 88d8cb7 commit f00abf0

File tree

1 file changed

+58
-18
lines changed

1 file changed

+58
-18
lines changed

.github/workflows/build.yml

Lines changed: 58 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,7 @@ jobs:
6666

6767
linux-stage1:
6868
needs: [prepare]
69-
strategy:
70-
fail-fast: false
71-
matrix:
72-
include:
73-
- { runner: ubuntu-22.04, arch: x86_64 }
74-
- { runner: ubuntu-22.04-arm, arch: aarch64 }
75-
runs-on: ${{matrix.runner}}
69+
runs-on: ubuntu-22.04-arm
7670
steps:
7771
- uses: actions/checkout@v4
7872
- name: Build
@@ -97,7 +91,7 @@ jobs:
9791
tar -Jcf ../$NAME.tar.xz --format=ustar --numeric-owner --owner=0 --group=0 --sort=name --mtime="$BUILD_DATE" $NAME
9892
- uses: actions/upload-artifact@v4
9993
with:
100-
name: linux-stage1-ucrt-${{matrix.arch}}-toolchain
94+
name: linux-stage1-ucrt-aarch64-toolchain
10195
path: |
10296
llvm-mingw-*.tar.xz
10397
retention-days: 7
@@ -135,18 +129,12 @@ jobs:
135129
# Build a cross compiler for Linux, targeting Windows.
136130
linux:
137131
needs: [prepare, linux-stage1, linux-profile]
138-
strategy:
139-
fail-fast: false
140-
matrix:
141-
include:
142-
- { runner: ubuntu-22.04, arch: x86_64 }
143-
- { runner: ubuntu-22.04-arm, arch: aarch64 }
144-
runs-on: ${{matrix.runner}}
132+
runs-on: ubuntu-22.04-arm
145133
steps:
146134
- uses: actions/checkout@v4
147135
- uses: actions/download-artifact@v4
148136
with:
149-
name: linux-stage1-ucrt-${{matrix.arch}}-toolchain
137+
name: linux-stage1-ucrt-aarch64-toolchain
150138
- name: Unpack stage1 Clang
151139
run: |
152140
tar -Jxf llvm-mingw-*.tar.xz
@@ -176,7 +164,59 @@ jobs:
176164
tar -Jcf ../$NAME.tar.xz --format=ustar --numeric-owner --owner=0 --group=0 --sort=name --mtime="$BUILD_DATE" $NAME
177165
- uses: actions/upload-artifact@v4
178166
with:
179-
name: linux-ucrt-${{matrix.arch}}-toolchain
167+
name: linux-ucrt-aarch64-toolchain
168+
path: |
169+
llvm-mingw-*.tar.xz
170+
retention-days: 7
171+
172+
# Crosscompile the toolchain for running on Linux on a different architecture, bundle the runtime
173+
# libraries that were built in the 'linux-stage1' step above.
174+
linux-cross-x86_64:
175+
needs: [linux-stage1, linux-profile, prepare]
176+
runs-on: ubuntu-22.04-arm
177+
steps:
178+
- uses: actions/checkout@v4
179+
- uses: actions/download-artifact@v4
180+
with:
181+
name: linux-stage1-ucrt-aarch64-toolchain
182+
- name: Unpack stage1 Clang
183+
run: |
184+
tar -Jxf llvm-mingw-*.tar.xz
185+
rm llvm-mingw-*.tar.xz
186+
sudo mv llvm-mingw* /opt/llvm-mingw
187+
- uses: actions/download-artifact@v4
188+
with:
189+
name: profile
190+
- name: Build
191+
env:
192+
LLVM_VERSION: ${{needs.prepare.outputs.LLVM_VERSION}}
193+
MINGW_W64_VERSION: ${{needs.prepare.outputs.MINGW_W64_VERSION}}
194+
SOURCE_DATE_EPOCH: ${{needs.prepare.outputs.COMMIT_DATE_UNIX}}
195+
run: |
196+
sudo apt-get update && sudo apt-get install g++-x86-64-linux-gnu
197+
./build-all.sh /opt/llvm-mingw $(pwd)/install/llvm-mingw --no-runtimes --host=x86_64-linux-gnu --thinlto --pgo
198+
.github/workflows/store-version.sh install/llvm-mingw/versions.txt
199+
- name: Assemble the cross-built toolchain
200+
run: |
201+
./prepare-cross-toolchain-unix.sh /opt/llvm-mingw $(pwd)/install/llvm-mingw
202+
- name: Test using the cross-built assembled toolchain
203+
run: |
204+
sudo apt-get update && sudo apt-get install qemu-user-static libc6-amd64-cross libstdc++6-amd64-cross
205+
QEMU_LD_PREFIX=/usr/x86_64-linux-gnu ./test-libcxx-module.sh $(pwd)/install/llvm-mingw
206+
QEMU_LD_PREFIX=/usr/x86_64-linux-gnu ./run-tests.sh $(pwd)/install/llvm-mingw
207+
- name: Package the toolchain
208+
env:
209+
TAG: ${{needs.prepare.outputs.TAG}}
210+
BUILD_DATE: ${{needs.prepare.outputs.BUILD_DATE}}
211+
run: |
212+
cd install
213+
DISTRO=ubuntu-$(grep DISTRIB_RELEASE /etc/lsb-release | cut -f 2 -d =)-x86_64
214+
NAME=llvm-mingw-$TAG-ucrt-$DISTRO
215+
mv llvm-mingw $NAME
216+
tar -Jcf ../$NAME.tar.xz --format=ustar --numeric-owner --owner=0 --group=0 --sort=name --mtime="$BUILD_DATE" $NAME
217+
- uses: actions/upload-artifact@v4
218+
with:
219+
name: linux-ucrt-x86_64-toolchain
180220
path: |
181221
llvm-mingw-*.tar.xz
182222
retention-days: 7
@@ -748,7 +788,7 @@ jobs:
748788
if: github.event_name == 'schedule'
749789
permissions:
750790
contents: write
751-
needs: [linux, macos, linux-cross-windows, test-toolchain, linux-test-cross-build-ffmpeg, test-ffmpeg]
791+
needs: [linux, linux-cross-x86_64, macos, linux-cross-windows, test-toolchain, linux-test-cross-build-ffmpeg, test-ffmpeg]
752792
runs-on: ubuntu-latest
753793
steps:
754794
- name: Download all artifacts

0 commit comments

Comments
 (0)