diff --git a/.github/workflows/asan_ubsan_build.yml b/.github/workflows/asan_ubsan_build.yml new file mode 100644 index 000000000..f1206aea4 --- /dev/null +++ b/.github/workflows/asan_ubsan_build.yml @@ -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 + #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* diff --git a/justfile b/justfile index e054c9562..305d4b760 100644 --- a/justfile +++ b/justfile @@ -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 }} @@ -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 }} + # initialize a containerized development environment init: #!/usr/bin/env sh