Skip to content

Commit

Permalink
Add ASAN/UBSAN recipe to just, make a CI that runs it
Browse files Browse the repository at this point in the history
  • Loading branch information
tvami committed Sep 24, 2024
1 parent 6c08a49 commit 838c1a9
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 0 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/asan_ubsan_build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@

name: Build with ASAN/UBSAN

on:
workflow_dispatch:
pull_request:
branches: [trunk]
types: [opened, ready_for_review]

env:
LDMX_DOCKER_TAG: ldmx/dev:latest
LDMX_NUM_EVENTS: 7500

jobs:
build-with-asan-ubsan:
runs-on: ubuntu-latest
outputs:
job_matrix: ${{steps.gen-mat.outputs.job_matrix}}
steps:
- name: Checkout ldmx-sw
uses: actions/checkout@v4
with:
submodules: 'recursive'
fetch-depth: 0

- name: Install just
uses: extractions/setup-just@v2
with:
just-version: 1.26.0

- name: Compile and Install ldmx-sw
run: |
just install-denv init configure-asan-ubsan
just build
just fire ${GITHUB_WORKSPACE}/.github/validation_samples/ecal_pn/config.py
shell: bash

14 changes: 14 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,22 @@ install-denv:
configure *CONFIG:
denv cmake -B build -S . -DADDITIONAL_WARNINGS=ON -DENABLE_CLANG_TIDY=ON {{ CONFIG }}

# configure minimal option for faster compilation
configure-quick *CONFIG:
denv cmake -B build -S . {{ CONFIG }}

# Configure with Address Sanitizer (ASAN) and UndefinedBehaviorSanitizer (UBSan)
configure-asan-ubsan: (configure-quick "-DENABLE_SANITIZER_UNDEFINED_BEHAVIOR=ON -DENABLE_SANITIZER_ADDRESS=ON")

# This is the same as just configure but reports all (non-3rd-party) warnings as errors
configure-force-error *CONFIG: (configure "-DWARNINGS_AS_ERRORS=ON" CONFIG)

# This is an alternative compiler (clang) together with enabling the LTO sanitizer
# This is very helpful but for now it optimizes away our module linking, use for testing only
configure-clang-lto: (configure "-DENABLE_LTO=ON -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_C_COMPILER=clang")

configure-gdb: (configure-quick "-DCMAKE_BUILD_TYPE=Debug")

# compile and install ldmx-sw
build ncpu=num_cpus():
denv cmake --build build --target install -- -j{{ ncpu }}
Expand All @@ -82,6 +91,11 @@ test *ARGS:
fire config_py *ARGS:
denv fire {{ config_py }} {{ ARGS }}

# run gdb on a config file
[no-cd]
gdb-fire config_py *ARGS:
denv gdb fire {{ config_py }} {{ ARGS }}

# initialize a containerized development environment
init:
#!/usr/bin/env sh
Expand Down

0 comments on commit 838c1a9

Please sign in to comment.