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

Add ASAN/UBSAN recipe to just, make a CI that runs it + adding GDB #1474

Merged
merged 15 commits into from
Sep 27, 2024
Merged
49 changes: 49 additions & 0 deletions .github/workflows/asan_ubsan_build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@

name: Build with ASAN and UBSAN

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

env:
LDMX_DOCKER_TAG: ldmx/dev:latest

jobs:
build-with-asan-ubsan:
runs-on: ubuntu-latest
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
shell: bash

- name: Run ecal_pn config
tvami marked this conversation as resolved.
Show resolved Hide resolved
#continue-on-error: true
run: |
just setenv LDMX_NUM_EVENTS=15
just setenv LDMX_RUN_NUMBER=7500
#just setenv ASAN_OPTIONS=log_path=output.log
just setenv ASAN_OPTIONS=detect_leaks=0
just fire ${GITHUB_WORKSPACE}/.github/validation_samples/ecal_pn/config.py
shell: bash

# For the future, we could try to save the output of ASAN/UBSAN
# - name: Upload log artifact
# uses: actions/upload-artifact@v4
# with:
# name: ASAN_UBSAN_output
# path: output.log*
27 changes: 22 additions & 5 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -59,16 +59,28 @@ install-denv:

# configure how ldmx-sw will be built
# added ADDITIONAL_WARNINGS and CLANG_TIDY to help improve code quality
configure *CONFIG:
denv cmake -B build -S . -DADDITIONAL_WARNINGS=ON -DENABLE_CLANG_TIDY=ON {{ CONFIG }}
# base configure command defining how cmake is called, private so only experts call it
[private]
configure-base *CONFIG:
denv cmake -B build -S . {{ CONFIG }}

# default configure of build when developing
configure *CONFIG: (configure-base "-DADDITIONAL_WARNINGS=ON -DENABLE_CLANG_TIDY=ON" CONFIG)

# configure minimal option for faster compilation
configure-quick: (configure-base)

# configure with Address Sanitizer (ASAN) and UndefinedBehaviorSanitizer (UBSan)
configure-asan-ubsan: (configure-base "-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)
configure-force-error: (configure "-DWARNINGS_AS_ERRORS=ON")

# 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
# Use alternative compiler and enable LTO (test compiling only, won't run properly)
configure-clang-lto: (configure "-DENABLE_LTO=ON -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_C_COMPILER=clang")

# Keep debug symbols so running with gdb provides more helpful detail
configure-gdb: (configure-base "-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 +94,11 @@ test *ARGS:
fire config_py *ARGS:
denv fire {{ config_py }} {{ ARGS }}

# run gdb on a config file
[no-cd]
debug config_py *ARGS:
denv gdb fire {{ config_py }} {{ ARGS }}
tvami marked this conversation as resolved.
Show resolved Hide resolved

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