diff --git a/.github/workflows/build-binaries.yml b/.github/workflows/build-binaries.yml index 922462ab9..1da0443b5 100644 --- a/.github/workflows/build-binaries.yml +++ b/.github/workflows/build-binaries.yml @@ -12,10 +12,27 @@ jobs: matrix: # Build debug and/or production debug: [''] # '' if production, 'debug' for debug os: [macos-11, ubuntu-20.04, windows-latest] + cross: ['', aarch64] + exclude: + - os: windows-latest + cross: aarch64 + - os: macos-11 + cross: aarch64 runs-on: ${{ matrix.os }} steps: - run: git config --global core.autocrlf input shell: bash + - name: Unpack cross toolchain from AWS S3 + if: ${{ matrix.cross != '' }} + env: + AWS_ACCESS_KEY_ID: ${{secrets.GHA_CACHE_ACCESS_KEY_ID}} + AWS_SECRET_ACCESS_KEY: ${{secrets.GHA_CACHE_SECRET}} + AWS_DEFAULT_REGION: eu-west-1 + run: | + aws s3 cp . s3://adacore-gha-tray-eu-west-1/libadalang/ --recursive --exclude "*" --include "*.tar.bz2" --sse=AES256 + sudo apt install -y libc6-dev-arm64-cross linux-libc-dev-arm64-cross binutils-aarch64-linux-gnu + sudo tar xavf ${{ matrix.cross }}-${{ runner.os }}-gcc-13.2.tar.bz2 -C / + sudo tar xavf ${{ matrix.cross }}-${{ runner.os }}-gmp-6.2.1.tar.bz2 -C / - name: Force Alire to use preinstalled MSYS2 if: ${{ runner.os == 'Windows' }} shell: bash @@ -57,7 +74,6 @@ jobs: with: repository: AdaCore/gpr path: gpr2 - ref: edge - name: Get gprconfig kb uses: actions/checkout@v3 with: @@ -86,11 +102,11 @@ jobs: python-version: '3.10' - name: Build Libadalang and its dependencies shell: bash - run: utils/gh-build-binaries.sh "${{ matrix.debug }}" ${{ runner.os }} + run: utils/gh-build-binaries.sh "${{ matrix.debug }}" ${{ runner.os }} "${{ matrix.cross }}" - name: Keep artifacts uses: actions/upload-artifact@v3 with: - name: ${{ runner.os }}-${{ matrix.debug }} + name: ${{ runner.os }}-${{ matrix.debug }}${{ matrix.cross }} path: '*.tar.gz' - name: AWS S3 upload if: ${{ github.repository == 'AdaCore/libadalang' }} diff --git a/utils/gh-build-binaries.sh b/utils/gh-build-binaries.sh index cf9bbec70..40102922f 100755 --- a/utils/gh-build-binaries.sh +++ b/utils/gh-build-binaries.sh @@ -2,6 +2,7 @@ set -x -e DEBUG=$1 # Value is '' or 'debug' RUNNER_OS=$2 # ${{ runner.os }} is Linux, Windiws, maxOS +CROSS=$3 # '' for native, aarch64 for ARM cross export prefix=/tmp/ADALIB_DIR export CPATH=/usr/local/include export LIBRARY_PATH=/usr/local/lib @@ -23,6 +24,9 @@ pip install langkit/ eval `langkit/manage.py setenv | grep -v ^PATH=` alr --non-interactive get xmlada +TARGET=${CROSS:+$CROSS-linux} # '' or aarch64-linux +TARGET_OPTION=${TARGET:+--target=$TARGET} # '' or --target=aarch64-linux + build_archive() { LIBRARY_TYPE=$1 @@ -30,42 +34,47 @@ build_archive() cd xmlada* ./configure --prefix=$prefix ${DEBUG:+--enable-build=Debug} make $LIBRARY_TYPE install-$LIBRARY_TYPE \ - GPRBUILD_OPTIONS="-cargs -g1 -gnatwn -gargs" + GPRBUILD_OPTIONS="-cargs -g1 -gnatwn -gargs $TARGET_OPTION" cd .. make -C gprbuild prefix=$prefix BUILD=${DEBUG:-production} \ - GPRBUILD_OPTIONS="-cargs:C -Dst_mtim=st_mtimespec -gargs" \ + GPRBUILD_OPTIONS="-cargs:C -Dst_mtim=st_mtimespec -gargs $TARGET_OPTION" \ libgpr.build.$2 libgpr.install.$2 BUILD=`echo $DEBUG| tr [a-z] [A-Z]` # Convert to uppercase make -C gnatcoll-core prefix=$prefix BUILD=${BUILD:-PROD} LIBRARY_TYPES=$LIBRARY_TYPE \ - GPRBUILD_OPTIONS="-cargs -g1 -gargs" build install - ADAFLAGS=-g1 CFLAGS=-g1 python gnatcoll-bindings/iconv/setup.py build ${DEBUG:+--debug} -j0 --prefix=$prefix --library-types=$LIBRARY_TYPE + GPRBUILD_OPTIONS="-cargs -g1 -gargs" ${TARGET:+TARGET=$TARGET} build install + ADAFLAGS=-g1 CFLAGS=-g1 python gnatcoll-bindings/iconv/setup.py build \ + ${DEBUG:+--debug} -j0 --prefix=$prefix --library-types=$LIBRARY_TYPE $TARGET_OPTION python gnatcoll-bindings/iconv/setup.py install - ADAFLAGS=-g1 CFLAGS=-g1 python gnatcoll-bindings/gmp/setup.py build ${DEBUG:+--debug} -j0 --prefix=$prefix --library-types=$LIBRARY_TYPE + ADAFLAGS=-g1 CFLAGS=-g1 python gnatcoll-bindings/gmp/setup.py build \ + ${DEBUG:+--debug} -j0 --prefix=$prefix --library-types=$LIBRARY_TYPE $TARGET_OPTION python gnatcoll-bindings/gmp/setup.py install BUILD=${DEBUG:+dev} # Convert debug to dev sed -i -e 's/, "-flto"//' langkit/langkit/adasat/adasat.gpr # LTO fails on GNAT from Alire - gprbuild -p -P langkit/langkit/adasat/adasat.gpr -XLIBRARY_TYPE=$LIBRARY_TYPE -XBUILD_MODE=${BUILD:-prod} + gprbuild -p -P langkit/langkit/adasat/adasat.gpr -XLIBRARY_TYPE=$LIBRARY_TYPE -XBUILD_MODE=${BUILD:-prod} $TARGET_OPTION gprinstall -p -P langkit/langkit/adasat/adasat.gpr -XLIBRARY_TYPE=$LIBRARY_TYPE -XBUILD_MODE=${BUILD:-prod} --prefix=$prefix - langkit/manage.py build-langkit-support --library-types=$LIBRARY_TYPE --build-mode ${BUILD:-prod} + langkit/manage.py build-langkit-support --library-types=$LIBRARY_TYPE --build-mode ${BUILD:-prod} --gargs="$TARGET_OPTION" langkit/manage.py install-langkit-support $prefix --library-types=$LIBRARY_TYPE --build-mode ${BUILD:-prod} make -C gpr2 setup prefix=$prefix GPR2_BUILD=${DEBUG:-release} \ - GPRBUILD_OPTIONS="-cargs -g1 -gargs" GPR2KBDIR=./gprconfig_kb/db \ + GPRBUILD_OPTIONS="-cargs -g1 -gargs $TARGET_OPTION" GPR2KBDIR=./gprconfig_kb/db \ build-lib-$LIBRARY_TYPE install-lib-$LIBRARY_TYPE # Build libadalang static library ./manage.py generate GPR_PROJECT_PATH=$prefix/share/gpr \ - ./manage.py build --disable-all-mains --library-types=$LIBRARY_TYPE --build-mode ${BUILD:-prod} --disable-java + ./manage.py build --disable-all-mains --library-types=$LIBRARY_TYPE \ + --build-mode ${BUILD:-prod} --disable-java --gargs="$TARGET_OPTION" + + ./manage.py install --disable-all-mains --library-types=$LIBRARY_TYPE \ + --build-mode ${BUILD:-prod} $prefix - ./manage.py install --disable-all-mains --library-types=$LIBRARY_TYPE --build-mode ${BUILD:-prod} $prefix - tar czf libadalang-$RUNNER_OS-`basename $GITHUB_REF`${DEBUG:+-dbg}-$LIBRARY_TYPE.tar.gz -C $prefix . + tar czf libadalang-$RUNNER_OS-`basename $GITHUB_REF`${CROSS:+-$CROSS}${DEBUG:+-dbg}-$LIBRARY_TYPE.tar.gz -C $prefix . } # Disable SAL for static libadalang library