Skip to content

Commit

Permalink
Build LAL for AArch64 with cross toolchain
Browse files Browse the repository at this point in the history
We need it to build ada_language_server for aarch64-linux. There is
no GitHub Action runner for aarch64, so we will use the cross toolchain.

Refs eng/ide/ada_language_server#1251
Refs eng/ide/ada_language_server#1249 for removing `edge` branch of `gpr`.
  • Loading branch information
reznikmm committed Nov 28, 2023
1 parent 99c21d6 commit 5ae4a68
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 14 deletions.
22 changes: 19 additions & 3 deletions .github/workflows/build-binaries.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -57,7 +74,6 @@ jobs:
with:
repository: AdaCore/gpr
path: gpr2
ref: edge
- name: Get gprconfig kb
uses: actions/checkout@v3
with:
Expand Down Expand Up @@ -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' }}
Expand Down
31 changes: 20 additions & 11 deletions utils/gh-build-binaries.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -23,49 +24,57 @@ 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
rm -rf $prefix
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
Expand Down

0 comments on commit 5ae4a68

Please sign in to comment.