Skip to content

Commit b52310f

Browse files
arbourddeadprogram
authored andcommitted
ci: Add arm64 build
1 parent 0460700 commit b52310f

File tree

2 files changed

+109
-0
lines changed

2 files changed

+109
-0
lines changed

.github/workflows/linux.yml

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,3 +346,103 @@ jobs:
346346
path: |
347347
/tmp/tinygo.linux-arm.tar.gz
348348
/tmp/tinygo_armhf.deb
349+
build-linux-arm64:
350+
# Build ARM64 Linux binaries, ready for release.
351+
# It is set to "needs: build-linux" because it modifies the release created
352+
# in that process to avoid doing lots of duplicate work and to avoid
353+
# complications around precompiled libraries such as compiler-rt shipped as
354+
# part of the release tarball.
355+
runs-on: ubuntu-18.04
356+
needs: build-linux
357+
steps:
358+
- name: Checkout
359+
uses: actions/checkout@v2
360+
- name: Install apt dependencies
361+
run: |
362+
sudo apt-get install --no-install-recommends \
363+
qemu-user \
364+
g++-aarch64-linux-gnu \
365+
libc6-dev-arm64-cross \
366+
ninja-build
367+
- name: Install Go
368+
uses: actions/setup-go@v2
369+
with:
370+
go-version: '1.18.1'
371+
- name: Cache Go
372+
uses: actions/cache@v2
373+
with:
374+
key: go-cache-linux-arm64-v2-${{ hashFiles('go.mod') }}
375+
path: |
376+
~/.cache/go-build
377+
~/go/pkg/mod
378+
- name: Cache LLVM source
379+
uses: actions/cache@v2
380+
id: cache-llvm-source
381+
with:
382+
key: llvm-source-14-linux-v1
383+
path: |
384+
llvm-project/clang/lib/Headers
385+
llvm-project/clang/include
386+
llvm-project/compiler-rt
387+
llvm-project/lld/include
388+
llvm-project/llvm/include
389+
- name: Download LLVM source
390+
if: steps.cache-llvm-source.outputs.cache-hit != 'true'
391+
run: make llvm-source
392+
- name: Cache LLVM build
393+
uses: actions/cache@v2
394+
id: cache-llvm-build
395+
with:
396+
key: llvm-build-14-linux-arm64-v1
397+
path: llvm-build
398+
- name: Build LLVM
399+
if: steps.cache-llvm-build.outputs.cache-hit != 'true'
400+
run: |
401+
# fetch LLVM source
402+
rm -rf llvm-project
403+
make llvm-source
404+
# build!
405+
make llvm-build CROSS=aarch64-linux-gnu
406+
# Remove unnecessary object files (to reduce cache size).
407+
find llvm-build -name CMakeFiles -prune -exec rm -r '{}' \;
408+
- name: Cache Binaryen
409+
uses: actions/cache@v2
410+
id: cache-binaryen
411+
with:
412+
key: binaryen-linux-arm64-v1
413+
path: build/wasm-opt
414+
- name: Build Binaryen
415+
if: steps.cache-binaryen.outputs.cache-hit != 'true'
416+
run: |
417+
git submodule update --init lib/binaryen
418+
make CROSS=aarch64-linux-gnu binaryen
419+
- name: Install fpm
420+
run: |
421+
sudo gem install --no-document fpm
422+
- name: Build TinyGo binary
423+
run: |
424+
make CROSS=aarch64-linux-gnu
425+
- name: Download amd64 release
426+
uses: actions/download-artifact@v2
427+
with:
428+
name: linux-amd64-double-zipped
429+
- name: Extract amd64 release
430+
run: |
431+
mkdir -p build/release
432+
tar -xf tinygo.linux-amd64.tar.gz -C build/release tinygo
433+
- name: Modify release
434+
run: |
435+
cp -p build/tinygo build/release/tinygo/bin
436+
cp -p build/wasm-opt build/release/tinygo/bin
437+
- name: Create arm64 release
438+
run: |
439+
make release deb RELEASEONLY=1 DEB_ARCH=arm64
440+
cp -p build/release.tar.gz /tmp/tinygo.linux-arm64.tar.gz
441+
cp -p build/release.deb /tmp/tinygo_arm64.deb
442+
- name: Publish release artifact
443+
uses: actions/upload-artifact@v2
444+
with:
445+
name: linux-arm64-double-zipped
446+
path: |
447+
/tmp/tinygo.linux-arm64.tar.gz
448+
/tmp/tinygo_arm64.deb

Makefile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,15 @@ ifneq ($(CROSS),)
6868
-DLLVM_TARGET_ARCH=ARM
6969
GOENVFLAGS = GOARCH=arm CC=$(CC) CXX=$(CXX) CGO_ENABLED=1
7070
BINARYEN_OPTION += -DCMAKE_C_COMPILER=$(CC) -DCMAKE_CXX_COMPILER=$(CXX)
71+
else ifeq ($(CROSS), aarch64-linux-gnu)
72+
# Assume we're building on a Debian-like distro, with QEMU installed.
73+
LLVM_CONFIG_PREFIX = qemu-aarch64 -L /usr/aarch64-linux-gnu/
74+
# The CMAKE_SYSTEM_NAME flag triggers cross compilation mode.
75+
LLVM_OPTION += \
76+
-DCMAKE_SYSTEM_NAME=Linux \
77+
-DLLVM_TARGET_ARCH=AArch64
78+
GOENVFLAGS = GOARCH=arm64 CC=$(CC) CXX=$(CXX) CGO_ENABLED=1
79+
BINARYEN_OPTION += -DCMAKE_C_COMPILER=$(CC) -DCMAKE_CXX_COMPILER=$(CXX)
7180
else
7281
$(error Unknown cross compilation target: $(CROSS))
7382
endif

0 commit comments

Comments
 (0)