Skip to content
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
65 changes: 65 additions & 0 deletions .github/actions/prepare-llvm-cache/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: Prepare LLVM Cache
description: Restore or build the cached LLVM toolchain.

inputs:
llvm-commit:
description: LLVM commit to build.
required: true

runs:
using: composite
steps:

- name: Restore LLVM Repository Cache
id: restore-llvm-project-cache
uses: actions/cache/restore@v4
with:
path: ${{ github.workspace }}/llvm-project/
key: llvm-project-${{ runner.os }}-${{ inputs.llvm-commit }}

- name: Clone LLVM
if: steps.restore-llvm-project-cache.outputs.cache-hit != 'true'
shell: bash
run: |
git clone --filter=blob:none --no-checkout https://github.com/llvm/llvm-project.git llvm-project
cd llvm-project
git fetch --depth 1 origin ${{ inputs.llvm-commit }}
git checkout FETCH_HEAD

- name: Save LLVM Project Cache
if: steps.restore-llvm-project-cache.outputs.cache-hit != 'true'
uses: actions/cache/save@v4
with:
path: ${{ github.workspace }}/llvm-project/
key: llvm-project-${{ runner.os }}-${{ inputs.llvm-commit }}


- name: Restore LLVM Build Cache
id: restore-llvm-cache
uses: actions/cache/restore@v4
with:
path: ${{ github.workspace }}/llvm-build/
key: llvm-${{ runner.os }}-${{ inputs.llvm-commit }}

- name: Build LLVM
if: steps.restore-llvm-cache.outputs.cache-hit != 'true'
shell: bash
working-directory: ${{ github.workspace }}/llvm-project
run: |
builddir="${{ github.workspace }}/llvm-build/"
cmake -G Ninja \
-B "$builddir" \
-S llvm \
-DLLVM_ENABLE_PROJECTS="clang" \
-DCMAKE_BUILD_TYPE=Release \
-DLLVM_ENABLE_ASSERTIONS=OFF \
-DLLDB_INCLUDE_TESTS=OFF \
-DLIBCLC_TARGETS_TO_BUILD="RISCV;X86"
cmake --build "$builddir"

- name: Save LLVM Build Cache
if: steps.restore-llvm-cache.outputs.cache-hit != 'true'
uses: actions/cache/save@v4
with:
path: ${{ github.workspace }}/llvm-build/
key: llvm-${{ runner.os }}-${{ inputs.llvm-commit }}
91 changes: 50 additions & 41 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
name: ASPIS main CI
env:
LLVM_COMMIT: 2078da43e25a4623cab2d0d60decddf709aaea28 # llvmorg-21.1.8
CMAKE_VERSION: 4.3.0
MOLD_LINKER_FLAGS: -fuse-ld=mold
CCACHE_DIR: ${{ github.workspace }}/.ccache
CCACHE_MAXSIZE: 10G
CCACHE_BASEDIR: ${{ github.workspace }}
CCACHE_COMPILERCHECK: content
CCACHE_NOHASHDIR: "true"
on: [push]
jobs:
compile-ASPIS:
Expand All @@ -8,64 +17,64 @@ jobs:
uses: actions/checkout@v4
with:
path: ASPIS
- name: Cache LLVM build
uses: actions/cache@v4
id: llvm-cache

- name: Install system dependencies
run: |
sudo apt update
sudo apt install -y cmake ninja-build build-essential mold curl ca-certificates ccache

- name: Prepare LLVM Cache
uses: ./ASPIS/.github/actions/prepare-llvm-cache
with:
path: /mnt/build/
key: llvm-build-${{ hashFiles('llvm-project/**', 'ASPIS/CMakeLists.txt') }}
restore-keys: |
llvm-build-
- name: Checking out LLVM project
uses: actions/checkout@master
if: steps.llvm-cache.outputs.cache-hit != 'true'
llvm-commit: ${{ env.LLVM_COMMIT }}

- name: Restore ccache
id: restore-ccache
uses: actions/cache/restore@v4
with:
repository: llvm/llvm-project
ref: llvmorg-21.1.8
path: llvm-project
- name: Compiling LLVM
if: steps.llvm-cache.outputs.cache-hit != 'true'
shell: bash
working-directory: ./llvm-project
run: |
builddir="/mnt/build/"
sudo mkdir -p $builddir
sudo chmod 777 $builddir
cmake -G Ninja \
-B "$builddir" \
-S llvm \
-DLLVM_ENABLE_PROJECTS="clang" \
-DCMAKE_BUILD_TYPE=Release \
-DLLVM_ENABLE_ASSERTIONS=OFF \
-DLLDB_INCLUDE_TESTS=OFF \
-DLIBCLC_TARGETS_TO_BUILD="RISCV;X86"
cmake --build "$builddir"
path: ${{ env.CCACHE_DIR }}
key: ccache-${{ runner.os }}-${{ github.ref_name }}-${{ env.LLVM_COMMIT }}-${{ env.CMAKE_VERSION }}-${{ github.sha }}
restore-keys: |
ccache-${{ runner.os }}-${{ github.ref_name }}-${{ env.LLVM_COMMIT }}-${{ env.CMAKE_VERSION }}-
ccache-${{ runner.os }}-${{ env.LLVM_COMMIT }}-${{ env.CMAKE_VERSION }}-

- name: Compiling ASPIS
shell: bash
working-directory: ./ASPIS
working-directory: ${{ github.workspace }}/ASPIS
run: |
mkdir build
cmake -B build -DLLVM_DIR=/mnt/build/lib/cmake/llvm/
cmake --build build
ccache --set-config=max_size=${CCACHE_MAXSIZE}
ccache --zero-stats
ccache --show-config
ccache --show-stats

mkdir build
cmake -B build -DLLVM_DIR=${{ github.workspace }}/llvm-build/lib/cmake/llvm/
cmake --build build

- name: Save ccache
if: steps.build-llvm.outcome == 'success' && steps.restore-ccache.outputs.cache-hit != 'true'
uses: actions/cache/save@v4
with:
path: ${{ env.CCACHE_DIR }}
key: ccache-${{ runner.os }}-${{ github.ref_name }}-${{ env.LLVM_COMMIT }}-${{ env.CMAKE_VERSION }}-${{ github.sha }}

- name: Cache pip
uses: actions/cache@v4
id: pip-cache
with:
path: ~/.cache/pip
key: pip-${{ hashFiles('ASPIS/testing/requirements.txt') }}
key: pip-${{ hashFiles('${{ github.workspace }}/ASPIS/testing/requirements.txt') }}
restore-keys: |
pip-
- name: Install Python requirements
shell: bash
if: steps.llvm-cache.outputs.cache-hit != 'true'
working-directory: ./ASPIS/testing
if: steps.restore-ccache.outputs.cache-hit != 'true'
working-directory: ${{ github.workspace }}/ASPIS/testing
run: |
pip install -r requirements.txt
- name: Testing ASPIS
shell: bash
working-directory: ./ASPIS/testing
working-directory: ${{ github.workspace }}/ASPIS/testing
run: |
pytest test.py --tests-file config/tests.toml
pytest test.py --tests-file config/racfed+eddi.toml
pytest test.py --tests-file config/racfed.toml
pytest test.py

8 changes: 4 additions & 4 deletions testing/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ This directory contains utilities and scripts for testing ASPIS.

## Local Testing

For local testing, use the `test.py` script. Configure your tests using `tests.toml`. Configure the llvm_bin flag in `llvm_bin.toml`.
For local testing, use the `test.py` script. Configure your tests using `complete_testing.toml`. Configure the llvm_bin flag in `llvm_bin.toml`.
Then run:
```bash
pytest test.py
pytest test.py --no-header -v
```

> To run pytest the modules listed in requirements.txt must be installed.
Expand All @@ -26,12 +26,12 @@ Test config files must be `.toml` files with the following structure for each te
[[tests]]
test_name = <name_for_test>
source_file = <relative_path_to_src_file>
expected_output = <output_expected>
aspis_options = <compilation_flags>
```

> `<relative_path_to_src_file>` is a relative path from `./tests/` folder

All the combinations of ASPIS protection mechanisms will be used for each different test.

### Flags

It is possible to write different configuration test files.
Expand Down
2 changes: 1 addition & 1 deletion testing/config/llvm.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#llvm_bin = "<path/to/your/llvm/bin>"
llvm_bin = "/mnt/build/bin/"
llvm_bin = "/home/runner/work/ASPIS/ASPIS/llvm-build/bin"
108 changes: 0 additions & 108 deletions testing/config/racfed+eddi.toml

This file was deleted.

Loading
Loading