From ccc5706959e066b97365b8fffa59ab0fc991fd15 Mon Sep 17 00:00:00 2001 From: Ilya Yanok Date: Fri, 17 Jan 2025 23:03:29 +0100 Subject: [PATCH] gha/linux: cross-compile ARM64 libs & package them --- .github/actions/5a-linux-arm64/action.yml | 53 +++++++++++++++++++++++ .github/workflows/main.yml | 3 ++ 2 files changed, 56 insertions(+) create mode 100644 .github/actions/5a-linux-arm64/action.yml diff --git a/.github/actions/5a-linux-arm64/action.yml b/.github/actions/5a-linux-arm64/action.yml new file mode 100644 index 0000000000..2a706a47f7 --- /dev/null +++ b/.github/actions/5a-linux-arm64/action.yml @@ -0,0 +1,53 @@ +name: "Linux: Cross-compile ARM64 libraries & copy to install dir" +runs: + using: composite + steps: + + - name: Install Cross-Compile Support (ARM64) + uses: cyberjunk/gha-ubuntu-cross@v5 + with: + arch: arm64 + + # - name: Install libx11-dev for ARM64 + #run: sudo apt-get install libx11-dev:arm64 + + - shell: bash + run: | + set -eux + cd .. + + # keep using our own lld as a linker + sudo rm /usr/bin/aarch64-linux-gnu-ld + sudo ln -sf /usr/bin/ld /usr + + arch='aarch64' + triple="$arch-linux-gnu" + + export CC=clang + ./installed/bin/ldc-build-runtime --ninja \ + --buildDir="build-libs-$arch" \ + --dFlags="-mtriple=$triple -gcc=clang" \ + --cFlags="--target=$triple" \ + --linkerFlags="--target=$triple" \ + --ldcSrcDir="$PWD/ldc" + + mkdir "installed/lib-$arch" + cp -rv "build-libs-$arch"/lib/* "installed/lib-$arch/" + + section=" + \"($arch|arm64).*-linux-gnu\": + { + switches = [ + \"-defaultlib=phobos2-ldc,druntime-ldc\", + \"--mcpu=neoverse-n1\", + \"-mattr=+crc\", + \"-gcc=$arch-linux-gnu-gcc\", + \"-linker=gold\", + ]; + lib-dirs = [ + \"%%ldcbinarypath%%/../lib-$arch\", + ]; + rpath = \"%%ldcbinarypath%%/../lib-$arch\"; + };" + echo "$section" >> installed/etc/ldc2.conf + cat installed/etc/ldc2.conf diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index c4d1dfb434..d8ce6599e4 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -119,6 +119,9 @@ jobs: # with: # arch: ${{ matrix.arch }} + - name: "Linux: Cross-compile ARM64 libraries, copy to install dir & extend ldc2.conf" + if: runner.os == 'Linux' + uses: ./.github/actions/5a-linux-arm64 - name: Run a few integration tests against the installed compiler uses: ./.github/actions/6-integration-test # - name: 'macOS: Run iOS cross-compilation integration test'