Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

llvm build (#2012) #2013

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
94 changes: 94 additions & 0 deletions .github/workflows/build-llvm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
name: LLVM Build

on:
workflow_dispatch:
pull_request:
paths:
- llvm-build/*
- .github/workflows/build-llvm.yml

env:
SCCACHE_DIR: ${{ github.workspace }}/sccache


jobs:

build:
name: Build on ${{ matrix.config.runner }}
runs-on: ${{ matrix.config.runs_on }}
# container: pytorch/manylinuxaarch64-builder:cpu-aarch64-main

timeout-minutes: 240 # 4 hours

strategy:
fail-fast: true
matrix:
config:
- {runner: 'AlmaLinux 8', runs_on: 'linux.arm64.2xlarge', target-os: 'almalinux', arch: 'arm64'}


steps:

- name: Checkout Repo
uses: actions/checkout@v4
with:
path: llvm-build

- name: Fetch LLVM Commit Hash
shell: bash
run: |
LLVM_COMMIT_HASH="82f5acfbec65e1a645d902f746253eeaf0bd2d70"
echo "Found LLVM commit hash: ${LLVM_COMMIT_HASH}"
echo "llvm_commit_hash=${LLVM_COMMIT_HASH}" >> ${GITHUB_ENV}

SHORT_LLVM_COMMIT_HASH="${LLVM_COMMIT_HASH:0:8}"
echo "Short LLVM commit hash: ${SHORT_LLVM_COMMIT_HASH}"
echo "short_llvm_commit_hash=${SHORT_LLVM_COMMIT_HASH}" >> ${GITHUB_ENV}

INSTALL_DIR="llvm-${SHORT_LLVM_COMMIT_HASH}-${{ matrix.config.target-os }}-${{ matrix.config.arch }}"
echo "LLVM installation directory name: ${INSTALL_DIR}"
echo "llvm_install_dir=${INSTALL_DIR}" >> ${GITHUB_ENV}

- name: Checkout LLVM
uses: actions/checkout@v4
with:
repository: llvm/llvm-project
path: llvm-project
ref: ${{ env.llvm_commit_hash }}

- name: Install Prerequisites
shell: bash
run: |
python3 -m pip install cmake ninja sccache
mkdir -p ${{ env.SCCACHE_DIR }}
rm -rf ${{ env.SCCACHE_DIR }}/*


- name: Configure, Build, Test, and Install LLVM (AlmaLinux)
run: |
# if this step crashes, it can leave behind a stale docker container
docker container prune -f
# docker rmi -f $(docker images -q)

docker build --tag llvm-build --build-arg llvm_dir=llvm-project \
-f llvm-build/.github/workflows/llvm-build/almalinux.Dockerfile .

# Create temporary container to copy cache and installed artifacts.
CONTAINER_ID=$(docker create llvm-build)
docker cp "${CONTAINER_ID}:/install" "${{ env.llvm_install_dir }}"
tar czf "${{ env.llvm_install_dir }}.tar.gz" "${{ env.llvm_install_dir }}"

# We remove the existing directory, otherwise docker will
# create a subdirectory inside the existing directory.
rm -rf "${{ env.SCCACHE_DIR }}"
docker cp "${CONTAINER_ID}:/sccache" "${{ env.SCCACHE_DIR }}"
sudo chown -R "$(id -u -n):$(id -g -n)" "${{ env.SCCACHE_DIR }}"

docker rm "${CONTAINER_ID}"

- name: Upload Build Artifacts
uses: actions/upload-artifact@v4
with:
name: llvm-${{ matrix.config.target-os }}-${{ matrix.config.arch }}
path: |
${{ github.workspace }}/llvm-*-${{ matrix.config.target-os }}-${{ matrix.config.arch }}.tar.gz
40 changes: 40 additions & 0 deletions .github/workflows/llvm-build/almalinux.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
FROM almalinux:8
ARG llvm_dir=llvm-project
# Add the cache artifacts and the LLVM source tree to the container
ADD sccache /sccache
ADD "${llvm_dir}" /source/llvm-project
ENV SCCACHE_DIR="/sccache"
ENV SCCACHE_CACHE_SIZE="2G"

RUN dnf install --assumeyes llvm-toolset
RUN dnf install --assumeyes python38-pip python38-devel git

RUN python3 -m pip install --upgrade pip
RUN python3 -m pip install --upgrade cmake ninja sccache lit

# Install MLIR's Python Dependencies
RUN python3 -m pip install -r /source/llvm-project/mlir/python/requirements.txt

# Configure, Build, Test, and Install LLVM
RUN cmake -GNinja -Bbuild \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_C_COMPILER=clang \
-DCMAKE_CXX_COMPILER=clang++ \
-DCMAKE_ASM_COMPILER=clang \
-DCMAKE_C_COMPILER_LAUNCHER=sccache \
-DCMAKE_CXX_COMPILER_LAUNCHER=sccache \
-DCMAKE_CXX_FLAGS="-Wno-everything" \
-DCMAKE_LINKER=lld \
-DCMAKE_INSTALL_PREFIX="/install" \
-DLLVM_BUILD_UTILS=ON \
-DLLVM_BUILD_TOOLS=ON \
-DLLVM_ENABLE_ASSERTIONS=ON \
-DMLIR_ENABLE_BINDINGS_PYTHON=ON \
-DLLVM_ENABLE_PROJECTS=mlir \
-DLLVM_ENABLE_TERMINFO=OFF \
-DLLVM_INSTALL_UTILS=ON \
-DLLVM_TARGET_ARCH=AArch64 \
-DLLVM_TARGETS_TO_BUILD="host;NVPTX;AMDGPU" \
/source/llvm-project/llvm

RUN ninja -C build install
Loading