add DI support #999
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build | |
on: | |
push: | |
branches: [main] | |
pull_request: | |
branches: [main] | |
schedule: | |
- cron: 00 4 * * * | |
env: | |
CARGO_TERM_COLOR: always | |
jobs: | |
llvm: | |
runs-on: ubuntu-20.04 | |
name: llvm | |
steps: | |
- name: Cache | |
id: cache-llvm | |
uses: actions/cache@v3 | |
with: | |
path: llvm-install | |
key: llvm-0 | |
lookup-only: true | |
- name: Install Tools | |
if: steps.cache-llvm.outputs.cache-hit != 'true' | |
run: | | |
wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | \ | |
gpg --dearmor - | \ | |
sudo tee /usr/share/keyrings/kitware-archive-keyring.gpg >/dev/null | |
echo 'deb [signed-by=/usr/share/keyrings/kitware-archive-keyring.gpg] https://apt.kitware.com/ubuntu/ focal main' | \ | |
sudo tee /etc/apt/sources.list.d/kitware.list >/dev/null | |
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add - | |
echo -e deb http://apt.llvm.org/focal/ llvm-toolchain-focal main | sudo tee /etc/apt/sources.list.d/llvm.list | |
sudo apt-get update | |
sudo apt-get -y install cmake ninja-build clang lld | |
- name: Checkout LLVM Source | |
if: steps.cache-llvm.outputs.cache-hit != 'true' | |
uses: actions/checkout@v3 | |
with: | |
repository: aya-rs/llvm-project | |
ref: rustc/16.0-2023-04-05 | |
path: llvm-project | |
- name: Configure LLVM | |
if: steps.cache-llvm.outputs.cache-hit != 'true' | |
run: | | |
cmake \ | |
-S llvm-project/llvm \ | |
-B llvm-build \ | |
-G Ninja \ | |
-DCMAKE_BUILD_TYPE=RelWithDebInfo \ | |
-DCMAKE_C_COMPILER=clang \ | |
-DCMAKE_CXX_COMPILER=clang++ \ | |
-DCMAKE_INSTALL_PREFIX="${{ github.workspace }}/llvm-install" \ | |
-DLLVM_ENABLE_ASSERTIONS=ON \ | |
-DLLVM_ENABLE_PROJECTS= \ | |
-DLLVM_ENABLE_RUNTIMES= \ | |
-DLLVM_INSTALL_UTILS=ON \ | |
-DLLVM_TARGETS_TO_BUILD=BPF \ | |
-DLLVM_USE_LINKER=lld | |
- name: Install LLVM | |
if: steps.cache-llvm.outputs.cache-hit != 'true' | |
env: | |
# Create symlinks rather than copies to conserve disk space. At the time of this writing, | |
# GitHub-hosted runners have 14GB of SSD space | |
# (https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners#supported-runners-and-hardware-resources). | |
# | |
# Since the LLVM build creates a bunch of symlinks (and this setting does not turn those | |
# into symlinks-to-symlinks), use absolute symlinks so we can distinguish the two cases. | |
CMAKE_INSTALL_MODE: ABS_SYMLINK | |
run: cmake --build llvm-build --target install | |
- name: Rewrite LLVM Symlinks | |
if: steps.cache-llvm.outputs.cache-hit != 'true' | |
# Move targets over the symlinks that point to them. | |
# | |
# This whole dance would be simpler if CMake supported CMAKE_INSTALL_MODE=MOVE. | |
run: | | |
find llvm-install -type l -execdir sh -eux -c ' | |
for link in "$@"; do | |
target=$(readlink "$link") | |
case $target in | |
/*) mv "$target" "$link" ;; | |
esac | |
done | |
' sh {} + | |
build: | |
runs-on: ubuntu-20.04 | |
strategy: | |
fail-fast: false | |
matrix: | |
rust: | |
- stable | |
- beta | |
- nightly | |
llvm: | |
- 16 | |
name: rustc=${{ matrix.rust }} llvm=${{ matrix.llvm }} | |
needs: llvm | |
env: | |
RUST_BACKTRACE: full | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Install Rust ${{ matrix.rust }} | |
if: matrix.rust != 'nightly' | |
uses: dtolnay/rust-toolchain@master | |
with: | |
toolchain: ${{ matrix.rust }} | |
- name: Install Rust ${{ matrix.rust }} | |
if: matrix.rust == 'nightly' | |
uses: dtolnay/rust-toolchain@master | |
with: | |
toolchain: ${{ matrix.rust }} | |
components: rust-src | |
- uses: Swatinem/rust-cache@v2 | |
- name: Check (default features, no system LLVM) | |
if: ${{ false }} # TODO: remove this when https://reviews.llvm.org/D136637 and https://reviews.llvm.org/D138415 are included in rustc's LLVM. | |
run: cargo check | |
- name: Build (default features, no system LLVM) | |
if: ${{ false }} # TODO: remove this when https://reviews.llvm.org/D136637 and https://reviews.llvm.org/D138415 are included in rustc's LLVM. | |
run: cargo build | |
- name: Install LLVM | |
if: ${{ false }} # TODO: remove this when https://reviews.llvm.org/D136637 and https://reviews.llvm.org/D138415 are included in an LLVM release. | |
run: | | |
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add - | |
echo -e deb http://apt.llvm.org/focal/ llvm-toolchain-focal-${{ matrix.llvm }} main | sudo tee /etc/apt/sources.list.d/llvm.list | |
sudo apt-get update | |
sudo apt-get -y install \ | |
llvm-${{ matrix.llvm }}-dev \ | |
llvm-${{ matrix.llvm }}-tools \ | |
libclang-${{ matrix.llvm }}-dev \ | |
libpolly-${{ matrix.llvm }}-dev | |
- name: Restore LLVM | |
id: cache-llvm | |
uses: actions/cache/restore@v3 | |
with: | |
path: llvm-install | |
key: llvm-0 | |
fail-on-cache-miss: true | |
- name: Add LLVM to PATH | |
run: | | |
echo "${{ github.workspace }}/llvm-install/bin" >> $GITHUB_PATH | |
echo "$PATH" | |
# TODO: Remove this when we're no longer building LLVM from source; llvm-sys statically links against LLVM, so we must not use the cache. | |
- name: Clean llvm-sys | |
run: cargo clean -p llvm-sys | |
- uses: taiki-e/install-action@cargo-hack | |
- name: Check | |
run: cargo hack check --feature-powerset | |
- name: Build | |
run: cargo hack build --feature-powerset --exclude-features rust-llvm | |
- name: Test | |
if: matrix.rust == 'nightly' | |
run: cargo hack test --feature-powerset --exclude-features rust-llvm |