Skip to content

Fixes CI for macos arm64 runner (migrate to the github M1 runner). (#72) #101

Fixes CI for macos arm64 runner (migrate to the github M1 runner). (#72)

Fixes CI for macos arm64 runner (migrate to the github M1 runner). (#72) #101

name: libclang-linux-aarch64
on: [push, pull_request]
env:
LLVM_VER: 18.1.1
concurrency:
group: ${{ github.repository }}-${{ github.head_ref || github.sha }}-${{ github.workflow }}
cancel-in-progress: true
jobs:
build-and-deploy:
if: "!contains(github.event.head_commit.message, 'skip ci')"
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
- name: free disk spaces
run: |
./.github/free-disk-space.sh || true
- uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: install wheel dependencies
run: |
pip3 install wheel
- name: get llvm-project
run: |
wget -q https://github.com/llvm/llvm-project/releases/download/llvmorg-$LLVM_VER/llvm-project-$LLVM_VER.src.tar.xz
tar xf llvm-project-$LLVM_VER.src.tar.xz
mv llvm-project-$LLVM_VER.src llvm-project-$LLVM_VER
- name: install cross compilation toolchain
run: |
sudo apt-get update
sudo apt-get install -y \
binutils-aarch64-linux-gnu \
gcc-8 \
g++-8 \
gcc-8-aarch64-linux-gnu \
g++-8-aarch64-linux-gnu
- name: build host llvmtblgen/clangtblgen
run: |
mkdir llvm-project-$LLVM_VER/build-host
cd llvm-project-$LLVM_VER/build-host
cmake ../llvm \
-DLLVM_ENABLE_PROJECTS=clang \
-DBUILD_SHARED_LIBS=OFF \
-DLLVM_ENABLE_ZLIB=OFF \
-DLLVM_ENABLE_ZSTD=OFF \
-DLLVM_ENABLE_TERMINFO=OFF \
-DLLVM_TARGETS_TO_BUILD=X86 \
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DCMAKE_CXX_FLAGS_RELWITHDEBINFO="-O2 -g -DNDEBUG -static-libgcc -static-libstdc++" \
-DCMAKE_C_COMPILER=gcc-8 \
-DCMAKE_CXX_COMPILER=g++-8
make clang-tblgen llvm-tblgen -j$(nproc)
# copy the artifacts to an absolute path
sudo cp ./bin/* /usr/bin/
- name: make build directory
run: mkdir -p llvm-project-$LLVM_VER/build
- name: cmake
run: |
cd llvm-project-$LLVM_VER/build
cmake ../llvm \
-DLLVM_ENABLE_PROJECTS=clang \
-DBUILD_SHARED_LIBS=OFF \
-DLLVM_ENABLE_ZLIB=OFF \
-DLLVM_ENABLE_ZSTD=OFF \
-DLLVM_ENABLE_TERMINFO=OFF \
-DCMAKE_SYSTEM_NAME=Linux \
-DLLVM_DEFAULT_TARGET_TRIPLE=aarch64-linux-gnu \
-DLLVM_TARGET_ARCH=AArch64 \
-DLLVM_TARGETS_TO_BUILD=AArch64 \
-DLLVM_TABLEGEN=/usr/bin/llvm-tblgen \
-DCLANG_TABLEGEN=/usr/bin/clang-tblgen \
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DCMAKE_CXX_FLAGS_RELWITHDEBINFO="-O2 -g -DNDEBUG -static-libgcc -static-libstdc++" \
-DCMAKE_C_FLAGS="-include $(realpath ../../force_glibc_2_17.h)" \
-DCMAKE_CXX_FLAGS="-include $(realpath ../../force_glibc_2_17.h)" \
-DCMAKE_EXE_LINKER_FLAGS="-lm" \
-DCMAKE_SHARED_LINKER_FLAGS="-lm" \
-DCMAKE_C_COMPILER=aarch64-linux-gnu-gcc-8 \
-DCMAKE_CXX_COMPILER=aarch64-linux-gnu-g++-8
- name: build
run: |
cd llvm-project-$LLVM_VER/build
make libclang -j$(nproc)
aarch64-linux-gnu-strip lib/libclang.so
- name: print dependencies
run: |
du -csh $(realpath llvm-project-$LLVM_VER/build/lib/libclang.so)
file $(realpath llvm-project-$LLVM_VER/build/lib/libclang.so)
strings llvm-project-$LLVM_VER/build/lib/libclang.so | grep GLIBC
nm --dynamic --undefined-only --with-symbol-versions llvm-project-$LLVM_VER/build/lib/libclang.so
- name: create and print sha512sum
run: |
cd llvm-project-$LLVM_VER/build/lib
sha512sum libclang.so > libclang.so.$LLVM_VER.linux-aarch64.sha512sum
echo "Checksum is: "
cat libclang.so.$LLVM_VER.linux-aarch64.sha512sum
tar zcvfh libclang.so.$LLVM_VER.linux-aarch64.tar.gz libclang.so libclang.so.$LLVM_VER.linux-aarch64.sha512sum
shasum -a512 libclang.so.$LLVM_VER.linux-aarch64.tar.gz
- uses: actions/upload-artifact@v4
with:
name: libclang.so.${{env.LLVM_VER}}.linux-aarch64.tar.gz
path: llvm-project-${{env.LLVM_VER}}/build/lib/libclang.so.${{env.LLVM_VER}}.linux-aarch64.tar.gz
- name: generate wheel package
run: |
cp llvm-project-$LLVM_VER/build/lib/libclang.so native/
python3 setup_ext.py bdist_wheel --universal --plat-name=manylinux2014_aarch64
- uses: actions/upload-artifact@v4
with:
name: wheel-${{env.LLVM_VER}}-manylinux2014_aarch64
path: dist/*.whl
- name: Publish to PyPI
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages_dir: dist/
password: ${{ secrets.PYPI_TOKEN }}
verbose: true
print_hash: true